本文整理汇总了Python中cloudcafe.compute.common.models.link.Links._dict_to_obj方法的典型用法代码示例。如果您正苦于以下问题:Python Links._dict_to_obj方法的具体用法?Python Links._dict_to_obj怎么用?Python Links._dict_to_obj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudcafe.compute.common.models.link.Links
的用法示例。
在下文中一共展示了Links._dict_to_obj方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, json_dict):
links = None
metadata = None
server = None
if 'links' in json_dict:
links = Links._dict_to_obj(json_dict['links'])
if 'metadata' in json_dict:
metadata = Metadata._dict_to_obj(json_dict['metadata'])
if 'server' in json_dict:
# Prevents circular import issue import just in time
from cloudcafe.compute.servers_api.models.servers import ServerMin
server = ServerMin._dict_to_obj(json_dict['server'])
image = Image(
disk_config=json_dict.get('OS-DCF:diskConfig'),
size=json_dict.get('OS-EXT-IMG-SIZE:size'),
id=json_dict.get('id'), name=json_dict.get('name'),
status=json_dict.get('status'),
updated=json_dict.get('updated'),
created=json_dict.get('created'),
min_disk=json_dict.get('minDisk'),
min_ram=json_dict.get('minRam'),
progress=json_dict.get('progress'),
links=links, metadata=metadata, server=server)
return image
示例2: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, flavor_dict):
"""Helper method to turn dictionary into Server instance."""
flavor = Flavor(id=flavor_dict.get('id'),
name=flavor_dict.get('name'),
ram=flavor_dict.get('ram'),
disk=flavor_dict.get('disk'),
vcpus=flavor_dict.get('vcpus'))
flavor.links = Links._dict_to_obj(flavor_dict['links'])
return flavor
示例3: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
"""Helper method to turn dictionary into Server instance."""
addresses = None
flavor = None
image = None
links = None
metadata = None
fault = None
if 'links' in server_dict:
links = Links._dict_to_obj(server_dict['links'])
if 'addresses' in server_dict:
addresses = Addresses._dict_to_obj(server_dict['addresses'])
if 'flavor' in server_dict:
flavor = FlavorMin._dict_to_obj(server_dict['flavor'])
if 'image' in server_dict and server_dict.get('image'):
image = ImageMin._dict_to_obj(server_dict['image'])
if 'metadata' in server_dict:
metadata = Metadata._dict_to_obj(server_dict['metadata'])
if 'fault' in server_dict:
fault = Fault._dict_to_obj(server_dict['fault'])
server = Server(
id=server_dict.get('id') or server_dict.get('uuid'),
disk_config=server_dict.get('OS-DCF:diskConfig'),
power_state=server_dict.get('OS-EXT-STS:power_state'),
progress=server_dict.get('progress', 0),
task_state=server_dict.get('OS-EXT-STS:task_state'),
vm_state=server_dict.get('OS-EXT-STS:vm_state'),
name=server_dict.get('name'),
config_drive=server_dict.get('config_drive'),
tenant_id=server_dict.get('tenant_id'),
status=server_dict.get('status'),
updated=server_dict.get('updated'),
created=server_dict.get('created'),
host_id=server_dict.get('hostId'),
user_id=server_dict.get('user_id'),
accessIPv4=server_dict.get('accessIPv4'),
accessIPv6=server_dict.get('accessIPv6'), addresses=addresses,
flavor=flavor, image=image, links=links, metadata=metadata,
admin_pass=server_dict.get('adminPass'),
key_name=server_dict.get('key_name'),
host=server_dict.get('OS-EXT-SRV-ATTR:host'),
instance_name=server_dict.get('OS-EXT-SRV-ATTR:instance_name'),
hypervisor_name=server_dict.get(
'OS-EXT-SRV-ATTR:hypervisor_hostname'),
security_groups=server_dict.get('security_groups'),
fault=fault)
return server
示例4: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, json_dict):
image = Image(json_dict.get('OS-DCF:diskConfig'), json_dict.get('id'),
json_dict.get('name'), json_dict.get('status'),
json_dict.get('updated'), json_dict.get('created'),
json_dict.get('minDisk'), json_dict.get('minRam'),
json_dict.get('progress'))
if 'links' in json_dict:
image.links = Links._dict_to_obj(json_dict['links'])
if 'metadata' in json_dict:
image.metadata = Metadata._dict_to_obj(json_dict['metadata'])
if 'server' in json_dict:
from cloudcafe.compute.servers_api.models.servers import ServerMin
image.server = ServerMin._dict_to_obj(json_dict['server'])
return image
示例5: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, flavor_dict):
spec = 'OS-FLV-WITH-EXT-SPECS:extra_specs'
extra_specs = (FlavorExtraSpecs._dict_to_obj(flavor_dict.get(spec))
if flavor_dict.get(spec) else None)
flavor = Flavor(
id=flavor_dict.get('id'), name=flavor_dict.get('name'),
ram=flavor_dict.get('ram'), disk=flavor_dict.get('disk'),
vcpus=flavor_dict.get('vcpus'), swap=flavor_dict.get('swap'),
rxtx_factor=flavor_dict.get('rxtx_factor'),
ephemeral_disk=flavor_dict.get('OS-FLV-EXT-DATA:ephemeral'),
links=Links._dict_to_obj(flavor_dict['links']),
extra_specs=extra_specs)
return flavor
示例6: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
"""Helper method to turn dictionary into Server instance."""
addresses = None
flavor = None
image = None
links = None
metadata = None
if "links" in server_dict:
links = Links._dict_to_obj(server_dict["links"])
if "addresses" in server_dict:
addresses = Addresses._dict_to_obj(server_dict["addresses"])
if "flavor" in server_dict:
flavor = FlavorMin._dict_to_obj(server_dict["flavor"])
if "image" in server_dict:
image = ImageMin._dict_to_obj(server_dict["image"])
if "metadata" in server_dict:
metadata = Metadata._dict_to_obj(server_dict["metadata"])
server = Server(
id=server_dict.get("id") or server_dict.get("uuid"),
disk_config=server_dict.get("OS-DCF:diskConfig"),
power_state=server_dict.get("OS-EXT-STS:power_state"),
progress=server_dict.get("progress", 0),
task_state=server_dict.get("OS-EXT-STS:task_state"),
vm_state=server_dict.get("OS-EXT-STS:vm_state"),
name=server_dict.get("name"),
config_drive=server_dict.get("config_drive"),
tenant_id=server_dict.get("tenant_id"),
status=server_dict.get("status"),
updated=server_dict.get("updated"),
created=server_dict.get("created"),
host_id=server_dict.get("hostId"),
user_id=server_dict.get("user_id"),
accessIPv4=server_dict.get("accessIPv4"),
accessIPv6=server_dict.get("accessIPv6"),
addresses=addresses,
flavor=flavor,
image=image,
links=links,
metadata=metadata,
admin_pass=server_dict.get("adminPass"),
key_name=server_dict.get("key_name"),
host=server_dict.get("OS-EXT-SRV-ATTR:host"),
instance_name=server_dict.get("OS-EXT-SRV-ATTR:instance_name"),
hypervisor_name=server_dict.get("OS-EXT-SRV-ATTR:hypervisor_hostname"),
)
return server
示例7: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
"""Helper method to turn dictionary into Server instance."""
addresses = None
flavor = None
image = None
links = None
metadata = None
if "links" in server_dict:
links = Links._dict_to_obj(server_dict["links"])
if "addresses" in server_dict:
addresses = Addresses._dict_to_obj(server_dict["addresses"])
if "flavor" in server_dict:
flavor = FlavorMin._dict_to_obj(server_dict["flavor"])
if "image" in server_dict:
image = ImageMin._dict_to_obj(server_dict["image"])
if "metadata" in server_dict:
metadata = Metadata._dict_to_obj(server_dict["metadata"])
server = Server(
server_dict["id"],
server_dict.get("OS-DCF:diskConfig"),
server_dict.get("OS-EXT-STS:power_state"),
server_dict.get("progress", 0),
server_dict.get("OS-EXT-STS:task_state"),
server_dict.get("OS-EXT-STS:vm_state"),
server_dict.get("name"),
server_dict.get("tenant_id"),
server_dict.get("status"),
server_dict.get("updated"),
server_dict.get("created"),
server_dict.get("hostId"),
server_dict.get("user_id"),
server_dict.get("accessIPv4"),
server_dict.get("accessIPv6"),
addresses,
flavor,
image,
links,
metadata,
server_dict.get("adminPass"),
)
for each in server_dict:
if each.startswith("{"):
newkey = re.split("}", each)[1]
setattr(server, newkey, server_dict[each])
return server
示例8: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
'''Helper method to turn dictionary into Server instance.'''
servermin = ServerMin(**server_dict)
if hasattr(servermin, 'links'):
servermin.links = Links._dict_to_obj(servermin.links)
'''
Parse for those keys which have the namespace prefixed,
strip the namespace out
and take only the actual values such as diskConfig,
power_state and assign to server obj
'''
for each in server_dict:
if each.startswith("{"):
newkey = re.split("}", each)[1]
setattr(servermin, newkey, server_dict[each])
return servermin
示例9: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
'''Helper method to turn dictionary into Server instance.'''
addresses = None
flavor = None
image = None
links = None
metadata = None
if 'links' in server_dict:
links = Links._dict_to_obj(server_dict['links'])
if 'addresses' in server_dict:
addresses = Addresses._dict_to_obj(server_dict['addresses'])
if 'flavor' in server_dict:
flavor = FlavorMin._dict_to_obj(server_dict['flavor'])
if 'image' in server_dict:
image = ImageMin._dict_to_obj(server_dict['image'])
if 'metadata' in server_dict:
metadata = Metadata._dict_to_obj(server_dict['metadata'])
server = Server(
id=server_dict.get('id') or server_dict.get('uuid'),
disk_config=server_dict.get('OS-DCF:diskConfig'),
power_state=server_dict.get('OS-EXT-STS:power_state'),
progress=server_dict.get('progress', 0),
task_state=server_dict.get('OS-EXT-STS:task_state'),
vm_state=server_dict.get('OS-EXT-STS:vm_state'),
name=server_dict.get('name'),
tenant_id=server_dict.get('tenant_id'),
status=server_dict.get('status'),
updated=server_dict.get('updated'),
created=server_dict.get('created'),
host_id=server_dict.get('hostId'),
user_id=server_dict.get('user_id'),
accessIPv4=server_dict.get('accessIPv4'),
accessIPv6=server_dict.get('accessIPv6'), addresses=addresses,
flavor=flavor, image=image, links=links, metadata=metadata,
admin_pass=server_dict.get('adminPass'),
key_name=server_dict.get('key_name'))
return server
示例10: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
'''Helper method to turn dictionary into Server instance.'''
addresses = None
flavor = None
image = None
links = None
metadata = None
if 'links' in server_dict:
links = Links._dict_to_obj(server_dict['links'])
if 'addresses' in server_dict:
addresses = Addresses._dict_to_obj(server_dict['addresses'])
if 'flavor' in server_dict:
flavor = FlavorMin._dict_to_obj(server_dict['flavor'])
if 'image' in server_dict:
image = ImageMin._dict_to_obj(server_dict['image'])
if 'metadata' in server_dict:
metadata = Metadata._dict_to_obj(server_dict['metadata'])
server = Server(
server_dict['id'], server_dict.get('OS-DCF:diskConfig'),
server_dict.get('OS-EXT-STS:power_state'),
server_dict.get('progress', 0),
server_dict.get('OS-EXT-STS:task_state'),
server_dict.get('OS-EXT-STS:vm_state'),
server_dict.get('name'), server_dict.get('tenant_id'),
server_dict.get('status'), server_dict.get('updated'),
server_dict.get('created'), server_dict.get('hostId'),
server_dict.get('user_id'), server_dict.get('accessIPv4'),
server_dict.get('accessIPv6'), addresses, flavor,
image, links, metadata, server_dict.get('adminPass'))
for each in server_dict:
if each.startswith("{"):
newkey = re.split("}", each)[1]
setattr(server, newkey, server_dict[each])
return server
示例11: _dict_to_obj
# 需要导入模块: from cloudcafe.compute.common.models.link import Links [as 别名]
# 或者: from cloudcafe.compute.common.models.link.Links import _dict_to_obj [as 别名]
def _dict_to_obj(cls, server_dict):
links = Links._dict_to_obj(server_dict['links'])
server = ServerMin(id=server_dict.get('id'),
name=server_dict.get('name'), links=links)
return server