本文整理汇总了Python中nova.api.openstack.xmlutil.make_links函数的典型用法代码示例。如果您正苦于以下问题:Python make_links函数的具体用法?Python make_links怎么用?Python make_links使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_links函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_app
def make_app(elem, detailed=False):
elem.set('name')
elem.set('id')
global XML_WARNING
if not XML_WARNING:
LOG.warn(_LW('XML support has been deprecated and may be removed '
'as early as the Juno release.'))
XML_WARNING = True
if detailed:
elem.set('network_bandwidth')
elem.set('memory_mb')
elem.set('disk_gb')
# Attach image node
image = xmlutil.SubTemplateElement(elem, 'image', selector='image')
image.set('id')
xmlutil.make_links(image, 'links')
# Attach fault node
make_fault(elem)
# Attach metadata node
elem.append(common.MetadataTemplate())
xmlutil.make_links(elem, 'links')
示例2: test__serialize_with_empty_datum_selector
def test__serialize_with_empty_datum_selector(self):
# Our test object to serialize
obj = {
'test': {
'name': 'foobar',
'image': ''
},
}
root = xmlutil.TemplateElement('test', selector='test',
name='name')
master = xmlutil.MasterTemplate(root, 1)
root_slave = xmlutil.TemplateElement('test', selector='test')
image = xmlutil.SubTemplateElement(root_slave, 'image',
selector='image')
image.set('id')
xmlutil.make_links(image, 'links')
slave = xmlutil.SlaveTemplate(root_slave, 1)
master.attach(slave)
siblings = master._siblings()
result = master._serialize(None, obj, siblings)
self.assertEqual(result.tag, 'test')
self.assertEqual(result[0].tag, 'image')
self.assertEqual(result[0].get('id'), str(obj['test']['image']))
示例3: make_network
def make_network(elem, detailed=False):
elem.set('name')
elem.set('id')
if detailed:
elem.set('name')
elem.set('vms')
xmlutil.make_links(elem, 'links')
示例4: make_flavor
def make_flavor(elem, detailed=False):
elem.set('name')
elem.set('id')
if detailed:
elem.set('ram')
elem.set('disk')
elem.set('vcpus', xmlutil.EmptyStringSelector('vcpus'))
xmlutil.make_links(elem, 'links')
示例5: make_ext
def make_ext(elem):
elem.set("name")
elem.set("namespace")
elem.set("alias")
elem.set("updated")
desc = xmlutil.SubTemplateElement(elem, "description")
desc.text = "description"
xmlutil.make_links(elem, "links")
示例6: make_flavor
def make_flavor(elem, detailed=False):
elem.set("name")
elem.set("id")
if detailed:
elem.set("ram")
elem.set("disk")
for attr in ("vcpus", "swap", "rxtx_factor"):
elem.set(attr, xmlutil.EmptyStringSelector(attr))
xmlutil.make_links(elem, "links")
示例7: make_flavor
def make_flavor(elem, detailed=False):
elem.set('name')
elem.set('id')
if detailed:
elem.set('ram')
elem.set('disk')
elem.set('vcpus', xmlutil.EmptyStringSelector('vcpus'))
# NOTE(vish): this was originally added without a namespace
elem.set('swap', xmlutil.EmptyStringSelector('swap'))
xmlutil.make_links(elem, 'links')
示例8: make_flavor
def make_flavor(elem, detailed=False):
elem.set('name')
elem.set('id')
if detailed:
elem.set('ram')
elem.set('disk')
elem.set('vcpus')
elem.set('swap')
elem.set('ephemeral')
elem.set('disabled')
xmlutil.make_links(elem, 'links')
示例9: make_version
def make_version(elem):
elem.set("id")
elem.set("status")
elem.set("updated")
mts = MediaTypesTemplateElement("media-types")
elem.append(mts)
mt = xmlutil.SubTemplateElement(mts, "media-type", selector="media-types")
mt.set("base")
mt.set("type")
xmlutil.make_links(elem, "links")
示例10: make_image
def make_image(elem, detailed=False):
elem.set('name')
elem.set('id')
if detailed:
elem.set('updated')
elem.set('created')
elem.set('status')
elem.set('progress')
elem.set('minRam')
elem.set('minDisk')
server = xmlutil.SubTemplateElement(elem, 'server', selector='server')
server.set('id')
xmlutil.make_links(server, 'links')
elem.append(common.MetadataTemplate())
xmlutil.make_links(elem, 'links')
示例11: make_server
def make_server(elem, detailed=False):
elem.set('name')
elem.set('id')
if detailed:
elem.set('userId', 'user_id')
elem.set('tenantId', 'tenant_id')
elem.set('updated')
elem.set('created')
elem.set('hostId')
elem.set('accessIPv4')
elem.set('accessIPv6')
elem.set('status')
elem.set('progress')
# Attach image node
image = xmlutil.SubTemplateElement(elem, 'image', selector='image')
image.set('id')
xmlutil.make_links(image, 'links')
# Attach flavor node
flavor = xmlutil.SubTemplateElement(elem, 'flavor', selector='flavor')
flavor.set('id')
xmlutil.make_links(flavor, 'links')
# Attach fault node
make_fault(elem)
# Attach metadata node
elem.append(common.MetadataTemplate())
# Attach addresses node
elem.append(ips.AddressesTemplate())
xmlutil.make_links(elem, 'links')
示例12: test_make_links
def test_make_links(self):
elem = xmlutil.TemplateElement('image', selector='image')
self.assertTrue(repr(xmlutil.make_links(elem, 'links')))
示例13: construct
def construct(self):
root = xmlutil.TemplateElement('servers')
elem = xmlutil.SubTemplateElement(root, 'server', selector='servers')
make_server(elem)
xmlutil.make_links(root, 'servers_links')
return xmlutil.MasterTemplate(root, 1, nsmap=server_nsmap)
示例14: construct
def construct(self):
root = xmlutil.TemplateElement('images')
elem = xmlutil.SubTemplateElement(root, 'image', selector='images')
make_image(elem)
xmlutil.make_links(root, 'images_links')
return xmlutil.MasterTemplate(root, 1, nsmap=image_nsmap)