本文整理汇总了Python中traffic.openstack.common.jsonutils.to_primitive函数的典型用法代码示例。如果您正苦于以下问题:Python to_primitive函数的具体用法?Python to_primitive怎么用?Python to_primitive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_primitive函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: prep_resize
def prep_resize(self, ctxt, image, instance, instance_type, host,
reservations=None):
instance_p = jsonutils.to_primitive(instance)
instance_type_p = jsonutils.to_primitive(instance_type)
self.cast(ctxt, self.make_msg('prep_resize',
instance=instance_p, instance_type=instance_type_p,
image=image, reservations=reservations),
_compute_topic(self.topic, ctxt, host, None))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:8,代码来源:trpcapi.py
示例2: prep_resize
def prep_resize(self, ctxt, instance, instance_type, image,
request_spec, filter_properties, reservations):
instance_p = jsonutils.to_primitive(instance)
instance_type_p = jsonutils.to_primitive(instance_type)
self.cast(ctxt, self.make_msg('prep_resize',
instance=instance_p, instance_type=instance_type_p,
image=image, request_spec=request_spec,
filter_properties=filter_properties,
reservations=reservations))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:9,代码来源:rpcapi.py
示例3: get_host
def get_host(self, ctxt, instance, instance_type, image,
request_spec, filter_properties, reservations):
instance_p = jsonutils.to_primitive(instance)
instance_type_p = jsonutils.to_primitive(instance_type)
return self.call(ctxt, self.make_msg('get_host',
instance=instance_p, instance_type=instance_type_p,
image=image, request_spec=request_spec,
filter_properties=filter_properties,
reservations=reservations))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:9,代码来源:rpcapi.py
示例4: post_live_migration_at_destination
def post_live_migration_at_destination(self, ctxt, instance,
block_migration, host):
instance_p = jsonutils.to_primitive(instance)
return self.call(ctxt,
self.make_msg('post_live_migration_at_destination',
instance=instance_p, block_migration=block_migration),
_compute_topic(self.topic, ctxt, host, None))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:7,代码来源:trpcapi.py
示例5: live_migration
def live_migration(self, ctxt, instance, dest, block_migration, host,
migrate_data=None):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('live_migration', instance=instance_p,
dest=dest, block_migration=block_migration,
migrate_data=migrate_data),
topic=_compute_topic(self.topic, ctxt, host, None))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:7,代码来源:trpcapi.py
示例6: resize_instance
def resize_instance(self, ctxt, instance, migration_id, image,
reservations=None):
topic = _compute_topic(self.topic, ctxt, None, instance)
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('resize_instance',
instance=instance_p, migration_id=migration_id,
image=image, reservations=reservations), topic)
开发者ID:fengkaicnic,项目名称:traffic,代码行数:7,代码来源:trpcapi.py
示例7: revert_resize
def revert_resize(self, ctxt, instance, migration_id, host,
reservations=None):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('revert_resize',
instance=instance_p, migration_id=migration_id,
reservations=reservations),
topic=_compute_topic(self.topic, ctxt, host, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:7,代码来源:trpcapi.py
示例8: finish_resize
def finish_resize(self, ctxt, instance, migration_id, image, disk_info,
host, reservations=None):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('finish_resize',
instance=instance_p, migration_id=migration_id,
image=image, disk_info=disk_info, reservations=reservations),
topic=_compute_topic(self.topic, ctxt, host, None))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:7,代码来源:trpcapi.py
示例9: attach_image
def attach_image(self, ctxt, instance, image_id, mountpoint):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('attach_image',
instance=instance_p, image_id=image_id,
mountpoint=mountpoint),
topic=_compute_topic(self.topic, ctxt, None, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:7,代码来源:trpcapi.py
示例10: confirm_resize
def confirm_resize(self, ctxt, instance, migration_id, host,
reservations=None, cast=True):
rpc_method = self.cast if cast else self.call
instance_p = jsonutils.to_primitive(instance)
return rpc_method(ctxt, self.make_msg('confirm_resize',
instance=instance_p, migration_id=migration_id,
reservations=reservations),
topic=_compute_topic(self.topic, ctxt, host, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:8,代码来源:trpcapi.py
示例11: snapshot_instance
def snapshot_instance(self, ctxt, instance, image_id, image_type,
backup_type, rotation):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('snapshot_instance',
instance=instance_p, image_id=image_id,
image_type=image_type, backup_type=backup_type,
rotation=rotation),
topic=_compute_topic(self.topic, ctxt, None, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:8,代码来源:trpcapi.py
示例12: live_migration
def live_migration(self, ctxt, block_migration, disk_over_commit,
instance, dest):
# NOTE(comstud): Call vs cast so we can get exceptions back, otherwise
# this call in the scheduler driver doesn't return anything.
instance_p = jsonutils.to_primitive(instance)
return self.call(ctxt, self.make_msg('live_migration',
block_migration=block_migration,
disk_over_commit=disk_over_commit, instance=instance_p,
dest=dest))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:9,代码来源:rpcapi.py
示例13: check_can_live_migrate_destination
def check_can_live_migrate_destination(self, ctxt, instance, destination,
block_migration, disk_over_commit):
instance_p = jsonutils.to_primitive(instance)
return self.call(ctxt,
self.make_msg('check_can_live_migrate_destination',
instance=instance_p,
block_migration=block_migration,
disk_over_commit=disk_over_commit),
topic=_compute_topic(self.topic,
ctxt, destination, None))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:10,代码来源:trpcapi.py
示例14: rebuild_instance
def rebuild_instance(self, ctxt, instance, new_pass, injected_files,
image_ref, orig_image_ref, orig_sys_metadata):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('rebuild_instance',
instance=instance_p, new_pass=new_pass,
injected_files=injected_files, image_ref=image_ref,
orig_image_ref=orig_image_ref,
orig_sys_metadata=orig_sys_metadata),
topic=_compute_topic(self.topic, ctxt, None, instance),
version='2.1')
开发者ID:fengkaicnic,项目名称:traffic,代码行数:10,代码来源:trpcapi.py
示例15: run_instance
def run_instance(self, ctxt, instance, host, request_spec,
filter_properties, requested_networks,
injected_files, admin_password,
is_first_time):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('run_instance', instance=instance_p,
request_spec=request_spec, filter_properties=filter_properties,
requested_networks=requested_networks,
injected_files=injected_files, admin_password=admin_password,
is_first_time=is_first_time),
topic=_compute_topic(self.topic, ctxt, host, None))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:11,代码来源:trpcapi.py
示例16: notify
def notify(context, publisher_id, event_type, priority, payload):
"""Sends a notification using the specified driver
:param publisher_id: the source worker_type.host of the message
:param event_type: the literal type of event (ex. Instance Creation)
:param priority: patterned after the enumeration of Python logging
levels in the set (DEBUG, WARN, INFO, ERROR, CRITICAL)
:param payload: A python dictionary of attributes
Outgoing message format includes the above parameters, and appends the
following:
message_id
a UUID representing the id for this notification
timestamp
the GMT timestamp the notification was sent at
The composite message will be constructed as a dictionary of the above
attributes, which will then be sent via the transport mechanism defined
by the driver.
Message example::
{'message_id': str(uuid.uuid4()),
'publisher_id': 'compute.host1',
'timestamp': timeutils.utcnow(),
'priority': 'WARN',
'event_type': 'compute.create_instance',
'payload': {'instance_id': 12, ... }}
"""
if priority not in log_levels:
raise BadPriorityException(
_('%s not in valid priorities') % priority)
# Ensure everything is JSON serializable.
payload = jsonutils.to_primitive(payload, convert_instances=True)
msg = dict(message_id=str(uuid.uuid4()),
publisher_id=publisher_id,
event_type=event_type,
priority=priority,
payload=payload,
timestamp=str(timeutils.utcnow()))
for driver in _get_drivers():
try:
driver.notify(context, msg)
except Exception, e:
LOG.exception(_("Problem '%(e)s' attempting to "
"send to notification system. Payload=%(payload)s") %
locals())
开发者ID:fengkaicnic,项目名称:traffic,代码行数:53,代码来源:api.py
示例17: refresh_instance_security_rules
def refresh_instance_security_rules(self, ctxt, host, instance):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('refresh_instance_security_rules',
instance=instance_p),
topic=_compute_topic(self.topic, ctxt, instance['host'],
instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:6,代码来源:trpcapi.py
示例18: unrescue_instance
def unrescue_instance(self, ctxt, instance):
instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('unrescue_instance',
instance=instance_p),
topic=_compute_topic(self.topic, ctxt, None, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:5,代码来源:trpcapi.py
示例19: stop_instance
def stop_instance(self, ctxt, instance, cast=True):
rpc_method = self.cast if cast else self.call
instance_p = jsonutils.to_primitive(instance)
return rpc_method(ctxt, self.make_msg('stop_instance',
instance=instance_p),
topic=_compute_topic(self.topic, ctxt, None, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:6,代码来源:trpcapi.py
示例20: reserve_block_device_name
def reserve_block_device_name(self, ctxt, instance, device):
instance_p = jsonutils.to_primitive(instance)
return self.call(ctxt, self.make_msg('reserve_block_device_name',
instance=instance_p, device=device),
topic=_compute_topic(self.topic, ctxt, None, instance))
开发者ID:fengkaicnic,项目名称:traffic,代码行数:5,代码来源:trpcapi.py
注:本文中的traffic.openstack.common.jsonutils.to_primitive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论