本文整理汇总了Python中nova.api.openstack.xmlutil.make_flat_dict函数的典型用法代码示例。如果您正苦于以下问题:Python make_flat_dict函数的具体用法?Python make_flat_dict怎么用?Python make_flat_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_flat_dict函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: make_hypervisor
def make_hypervisor(elem):
pci_stats = xmlutil.TemplateElement('%s:pci_stats' % Pci.alias,
colon_ns=True)
elem.append(pci_stats)
pci_stat = xmlutil.make_flat_dict('%s:pci_stat' % Pci.alias,
selector='%s:pci_stats' % Pci.alias,
colon_ns=True,
root=pci_stats,
ignore_sub_dicts=True)
extra = xmlutil.make_flat_dict('extra_info', selector='extra_info')
pci_stat.append(extra)
pci_stats.append(pci_stat)
开发者ID:LiangShang,项目名称:nova,代码行数:12,代码来源:pci.py
示例2: test_make_flat_dict
def test_make_flat_dict(self):
expected_xml = ("<?xml version='1.0' encoding='UTF-8'?>\n"
'<wrapper><a>foo</a><b>bar</b></wrapper>')
root = xmlutil.make_flat_dict('wrapper')
tmpl = xmlutil.MasterTemplate(root, 1)
result = tmpl.serialize(dict(wrapper=dict(a='foo', b='bar')))
self.assertEqual(result, expected_xml)
expected_xml = ("<?xml version='1.0' encoding='UTF-8'?>\n"
'<ns0:wrapper xmlns:ns0="ns"><ns0:a>foo</ns0:a><ns0:b>bar</ns0:b>'
"</ns0:wrapper>")
root = xmlutil.make_flat_dict('wrapper', ns='ns')
tmpl = xmlutil.MasterTemplate(root, 1)
result = tmpl.serialize(dict(wrapper=dict(a='foo', b='bar')))
self.assertEqual(result, expected_xml)
开发者ID:AsherBond,项目名称:nova,代码行数:15,代码来源:test_xmlutil.py
示例3: construct
def construct(self):
root = xmlutil.TemplateElement('host')
elem = xmlutil.make_flat_dict('resource', selector='host',
subselector='resource')
root.append(elem)
return xmlutil.MasterTemplate(root, 1)
开发者ID:StackOps,项目名称:nova,代码行数:7,代码来源:hosts.py
示例4: test_make_flat_dict_with_dicts
def test_make_flat_dict_with_dicts(self):
# Our test object to serialize
obj = {"device": {"id": 1,
"extra_info": {"key1": "value1",
"key2": "value2"}}}
expected_xml = (("<?xml version='1.0' encoding='UTF-8'?>\n"
'<device><id>1</id><extra_info><key2>value2</key2>'
'<key1>value1</key1></extra_info></device>'))
root = xmlutil.make_flat_dict('device', selector='device',
ignore_sub_dicts=True)
extra = xmlutil.make_flat_dict('extra_info', selector='extra_info')
root.append(extra)
master = xmlutil.MasterTemplate(root, 1)
result = master.serialize(obj)
self.assertEqual(expected_xml, result)
开发者ID:AsherBond,项目名称:nova,代码行数:17,代码来源:test_xmlutil.py
示例5: test_make_flat_dict_with_colon_tagname_support
def test_make_flat_dict_with_colon_tagname_support(self):
# Our test object to serialize
obj = {'extra_specs': {'foo:bar': '999'}}
expected_xml = (("<?xml version='1.0' encoding='UTF-8'?>\n"
'<extra_specs><foo:bar xmlns:foo="foo">999</foo:bar>'
'</extra_specs>'))
# Set up our master template
root = xmlutil.make_flat_dict('extra_specs', colon_ns=True)
master = xmlutil.MasterTemplate(root, 1)
result = master.serialize(obj)
self.assertEqual(expected_xml, result)
开发者ID:AsherBond,项目名称:nova,代码行数:11,代码来源:test_xmlutil.py
示例6: make_volume
def make_volume(elem):
elem.set("id")
elem.set("status")
elem.set("size")
elem.set("availabilityZone")
elem.set("createdAt")
elem.set("displayName")
elem.set("displayDescription")
elem.set("volumeType")
elem.set("snapshotId")
attachments = xmlutil.SubTemplateElement(elem, "attachments")
attachment = xmlutil.SubTemplateElement(attachments, "attachment", selector="attachments")
make_attachment(attachment)
metadata = xmlutil.make_flat_dict("metadata")
elem.append(metadata)
开发者ID:nanodayo,项目名称:nova,代码行数:17,代码来源:volumes.py
示例7: make_volume
def make_volume(elem):
elem.set('id')
elem.set('status')
elem.set('size')
elem.set('availabilityZone')
elem.set('createdAt')
elem.set('displayName')
elem.set('displayDescription')
elem.set('volumeType')
attachments = xmlutil.SubTemplateElement(elem, 'attachments')
attachment = xmlutil.SubTemplateElement(attachments, 'attachment',
selector='attachments')
make_attachment(attachment)
metadata = xmlutil.make_flat_dict('metadata')
elem.append(metadata)
开发者ID:Lezval,项目名称:nova,代码行数:17,代码来源:volumes.py
示例8: construct
def construct(self):
return xmlutil.MasterTemplate(xmlutil.make_flat_dict('cloudpipe'), 1)
开发者ID:xtoddx,项目名称:nova,代码行数:2,代码来源:cloudpipe.py
示例9: make_voltype
def make_voltype(elem):
elem.set("id")
elem.set("name")
extra_specs = xmlutil.make_flat_dict("extra_specs", selector="extra_specs")
elem.append(extra_specs)
开发者ID:russellb,项目名称:nova,代码行数:5,代码来源:types.py
示例10: construct
def construct(self):
root = xmlutil.TemplateElement("host")
elem = xmlutil.make_flat_dict("resource", selector="host", subselector="resource")
root.append(elem)
return xmlutil.MasterTemplate(root, 1)
开发者ID:B-Rich,项目名称:nova-1,代码行数:6,代码来源:hosts.py
示例11: construct
def construct(self):
extra_specs_dict = xmlutil.make_flat_dict('extra_specs', colon_ns=True)
return xmlutil.MasterTemplate(extra_specs_dict, 1)
开发者ID:BATYD-Turksat,项目名称:nova_servo,代码行数:3,代码来源:flavors_extraspecs.py
示例12: test_make_flat_dict
def test_make_flat_dict(self):
expected_xml = "<?xml version='1.0' encoding='UTF-8'?>\n" "<wrapper><a>foo</a><b>bar</b></wrapper>"
root = xmlutil.make_flat_dict("wrapper")
tmpl = xmlutil.MasterTemplate(root, 1)
result = tmpl.serialize(dict(wrapper=dict(a="foo", b="bar")))
self.assertEqual(result, expected_xml)
开发者ID:rbenali,项目名称:nova,代码行数:6,代码来源:test_xmlutil.py
示例13: construct
def construct(self):
root = xmlutil.make_flat_dict('extra_specs', selector='extra_specs')
return xmlutil.MasterTemplate(root, 1)
开发者ID:CorCornelisse,项目名称:nova,代码行数:3,代码来源:volumetypes.py
注:本文中的nova.api.openstack.xmlutil.make_flat_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论