本文整理汇总了Python中cloudcafe.compute.common.models.link.Links类的典型用法代码示例。如果您正苦于以下问题:Python Links类的具体用法?Python Links怎么用?Python Links使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Links类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
'''Helper method to turn ElementTree instance to Image instance.'''
cls._remove_xml_etree_namespace(element, Constants.XML_API_NAMESPACE)
image_dict = element.attrib
image_min = ImageMin(**image_dict)
image_min.links = Links._xml_ele_to_obj(element)
return image_min
示例2: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
flavor_dict = element.attrib
links = Links._xml_ele_to_obj(element)
flavor_min = FlavorMin(id=flavor_dict.get('id'),
name=flavor_dict.get('name'),
links=links)
return flavor_min
示例3: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
"""Helper method to turn ElementTree instance to Flavor instance."""
flavor_dict = element.attrib
if 'vcpus' in flavor_dict:
flavor_dict['vcpus'] = (flavor_dict.get('vcpus') and
int(flavor_dict.get('vcpus')))
if 'disk' in flavor_dict:
flavor_dict['disk'] = (flavor_dict.get('disk') and
int(flavor_dict.get('disk')))
if 'rxtx_factor' in flavor_dict:
flavor_dict['rxtx_factor'] = flavor_dict.get('rxtx_factor') \
and float(flavor_dict.get('rxtx_factor'))
if 'ram' in flavor_dict:
flavor_dict['ram'] = flavor_dict.get('ram') \
and int(flavor_dict.get('ram'))
if 'swap' in flavor_dict:
flavor_dict['swap'] = flavor_dict.get('swap') \
and int(flavor_dict.get('swap'))
links = Links._xml_ele_to_obj(element)
flavor = Flavor(flavor_dict.get('id'), flavor_dict.get('name'),
flavor_dict.get('ram'), flavor_dict.get('disk'),
flavor_dict.get('vcpus'), flavor_dict.get('swap'),
flavor_dict.get('rxtx_factor'), links)
return flavor
示例4: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
image_dict = element.attrib
if 'minDisk' in image_dict:
image_dict['minDisk'] = (image_dict.get('minDisk')
and int(image_dict.get('minDisk')))
if 'progress' in image_dict:
image_dict['progress'] = (image_dict.get('progress')
and int(image_dict.get('progress')))
if 'minRam' in image_dict:
image_dict['minRam'] = (image_dict.get('minRam')
and int(image_dict.get('minRam')))
links = None
metadata = None
server = None
if element.find('link') is not None:
links = Links._xml_ele_to_obj(element)
if element.find('metadata') is not None:
metadata = Metadata._xml_ele_to_obj(element.find('metadata'))
if element.find('server') is not None:
# Prevents circular import issue import just in time
from cloudcafe.compute.servers_api.models.servers import ServerMin
server = ServerMin._xml_ele_to_obj(element)
image = Image(
disk_config=image_dict.get('diskConfig'),
size=image_dict.get('size'), id=image_dict.get('id'),
name=image_dict.get('name'), status=image_dict.get('status'),
updated=image_dict.get('updated'),
created=image_dict.get('created'),
min_disk=image_dict.get('minDisk'),
min_ram=image_dict.get('minRam'),
progress=image_dict.get('progress'),
links=links, metadata=metadata, server=server)
return image
示例5: _dict_to_obj
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
示例6: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
'''Helper method to turn ElementTree instance to Server instance.'''
if element.find('server') is not None:
element = element.find('server')
server_dict = element.attrib
servermin = ServerMin(**server_dict)
servermin.links = Links._xml_ele_to_obj(element)
return servermin
示例7: _dict_to_obj
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
示例8: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
"""Helper method to turn ElementTree instance to Server instance."""
server = element.attrib
addresses = None
flavor = None
image = None
metadata = None
links = Links._xml_ele_to_obj(element)
if element.find("addresses") is not None:
addresses = Addresses._xml_ele_to_obj(element.find("addresses"))
if element.find("flavor") is not None:
flavor = Flavor._xml_ele_to_obj(element.find("flavor"))
if element.find("image") is not None:
image = Image._xml_ele_to_obj(element.find("image"))
if element.find("metadata") is not None:
metadata = Metadata._xml_ele_to_obj(element.find("metadata"))
if "progress" in server:
progress = server.get("progress") and int(server.get("progress"))
else:
progress = None
server = Server(
id=server.get("id"),
disk_config=server.get("diskConfig"),
power_state=server.get("power_state"),
progress=progress,
task_state=server.get("task_state").lower(),
vm_state=server.get("vm_state"),
name=server.get("name"),
tenant_id=server.get("tenant_id"),
status=server.get("status"),
updated=server.get("updated"),
created=server.get("created"),
host_id=server.get("hostId"),
user_id=server.get("userId"),
accessIPv4=server.get("accessIPv4"),
config_drive=server.get("config_drive"),
accessIPv6=server.get("accessIPv6"),
addresses=addresses,
flavor=flavor,
image=image,
links=links,
metadata=metadata,
admin_pass=server.get("adminPass"),
key_name=server.get("key_name"),
host=server.get("host"),
instance_name=server.get("instance_name"),
hypervisor_name=server.get("hypervisor_hostname"),
)
return server
示例9: _dict_to_obj
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
示例10: _dict_to_obj
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
示例11: _dict_to_obj
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
示例12: _dict_to_obj
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
示例13: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
"""Helper method to turn ElementTree instance to Server instance."""
server_dict = element.attrib
addresses = None
flavor = None
image = None
links = None
metadata = None
links = Links._xml_ele_to_obj(element)
if element.find("addresses") is not None:
addresses = Addresses._xml_ele_to_obj(element.find("addresses"))
if element.find("flavor") is not None:
flavor = Flavor._xml_ele_to_obj(element.find("flavor"))
if element.find("image") is not None:
image = Image._xml_ele_to_obj(element.find("image"))
if element.find("metadata") is not None:
metadata = Metadata._xml_ele_to_obj(element)
if "progress" in server_dict:
progress = server_dict.get("progress") and int(server_dict.get("progress"))
if "tenantId" in server_dict:
tenant_id = server_dict.get("tenantId")
if "userId" in server_dict:
user_id = server_dict.get("userId")
server = Server(
server_dict["id"],
server_dict["diskConfig"],
server_dict["power_state"],
progress,
server_dict["task_state"],
server_dict["vm_state"],
server_dict["name"],
tenant_id,
server_dict["status"],
server_dict["updated"],
server_dict["created"],
server_dict["hostId"],
user_id,
server_dict["accessIPv4"],
server_dict["accessIPv6"],
addresses,
flavor,
image,
links,
metadata,
)
return server
示例14: _dict_to_obj
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
示例15: _xml_ele_to_obj
def _xml_ele_to_obj(cls, element):
"""Helper method to turn ElementTree instance to Server instance."""
server = element.attrib
addresses = None
flavor = None
image = None
metadata = None
fault = None
links = Links._xml_ele_to_obj(element)
if element.find('addresses') is not None:
addresses = Addresses._xml_ele_to_obj(element.find('addresses'))
if element.find('flavor') is not None:
flavor = Flavor._xml_ele_to_obj(element.find('flavor'))
if element.find('image'):
image = Image._xml_ele_to_obj(element.find('image'))
if element.find('metadata') is not None:
metadata = Metadata._xml_ele_to_obj(element.find('metadata'))
if element.find('fault') is not None:
fault = Fault._xml_ele_to_obj(element.find('fault'))
if 'progress' in server:
progress = (server.get('progress')
and int(server.get('progress')))
else:
progress = None
server = Server(
id=server.get('id'), disk_config=server.get('diskConfig'),
power_state=server.get('power_state'), progress=progress,
task_state=server.get('task_state').lower(),
vm_state=server.get('vm_state'), name=server.get('name'),
tenant_id=server.get('tenant_id'), status=server.get('status'),
updated=server.get('updated'), created=server.get('created'),
host_id=server.get('hostId'), user_id=server.get('userId'),
accessIPv4=server.get('accessIPv4'),
config_drive=server.get('config_drive'),
accessIPv6=server.get('accessIPv6'), addresses=addresses,
flavor=flavor, image=image, links=links, metadata=metadata,
admin_pass=server.get('adminPass'),
key_name=server.get('key_name'), host=server.get('host'),
instance_name=server.get('instance_name'),
hypervisor_name=server.get('hypervisor_hostname'),
security_groups=server.get('security_groups'),
fault=fault)
return server