本文整理汇总了Python中tempest.services.compute.xml.common.Element类的典型用法代码示例。如果您正苦于以下问题:Python Element类的具体用法?Python Element怎么用?Python Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Element类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: auth
def auth(self, user, password, tenant):
passwordCreds = Element("passwordCredentials", username=user, password=password)
auth = Element("auth", tenantName=tenant)
auth.append(passwordCreds)
headers = {"Content-Type": "application/xml"}
resp, body = self.post(self.auth_url, headers=headers, body=str(Document(auth)))
return resp, body
开发者ID:Grindizer,项目名称:tempest,代码行数:7,代码来源:identity_client.py
示例2: _get_element
def _get_element(self, name, value):
if value is None:
xml_elem = Element(name)
xml_elem.add_attr("xsi:nil", "true")
return xml_elem
else:
return Element(name, value)
开发者ID:kdemina,项目名称:tempest,代码行数:7,代码来源:network_client.py
示例3: set_flavor_extra_spec
def set_flavor_extra_spec(self, flavor_id, specs):
"""Sets extra Specs to the mentioned flavor."""
extra_specs = Element("extra_specs")
for key in specs.keys():
extra_specs.add_attr(key, specs[key])
resp, body = self.post("flavors/%s/flavor-extra-specs" % flavor_id, str(Document(extra_specs)), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
开发者ID:BeenzSyed,项目名称:tempest,代码行数:8,代码来源:flavors_client.py
示例4: update_subnet
def update_subnet(self, subnet_id, name):
uri = '%s/subnets/%s' % (self.uri_prefix, str(subnet_id))
subnet = Element("subnet")
p2 = Element("name", name)
subnet.append(p2)
resp, body = self.put(uri, str(Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例5: set_server_metadata_item
def set_server_metadata_item(self, server_id, key, meta):
doc = Document()
for k, v in meta.items():
meta_element = Element("meta", key=k)
meta_element.append(Text(v))
doc.append(meta_element)
resp, body = self.put("servers/%s/metadata/%s" % (str(server_id), key), str(doc), self.headers)
return resp, xml_to_json(etree.fromstring(body))
开发者ID:vijaytripathi,项目名称:tempest,代码行数:8,代码来源:servers_client.py
示例6: set_image_metadata_item
def set_image_metadata_item(self, image_id, key, meta):
"""Sets the value for a specific image metadata key."""
for k, v in meta.items():
post_body = Element("meta", key=key)
post_body.append(Text(v))
resp, body = self.put("images/%s/metadata/%s" % (str(image_id), key), str(Document(post_body)), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
开发者ID:hanlind,项目名称:tempest,代码行数:8,代码来源:images_client.py
示例7: create_security_group
def create_security_group(self, name):
uri = '%s/security-groups' % (self.uri_prefix)
post_body = Element("security_group")
p2 = Element("name", name)
post_body.append(p2)
resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例8: create_router
def create_router(self, name, **kwargs):
uri = '%s/routers' % (self.uri_prefix)
router = Element("router")
router.append(Element("name", name))
deep_dict_to_xml(router, kwargs)
resp, body = self.post(uri, str(Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例9: update_health_monitor
def update_health_monitor(self, admin_state_up, uuid):
uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, str(uuid))
put_body = Element("health_monitor")
p2 = Element("admin_state_up", admin_state_up)
put_body.append(p2)
resp, body = self.put(uri, str(Document(put_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例10: create_network
def create_network(self, name):
uri = '%s/networks' % (self.uri_prefix)
post_body = Element("network")
p2 = Element("name", name)
post_body.append(p2)
resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例11: update_pool
def update_pool(self, pool_id, new_name):
uri = '%s/lb/pools/%s' % (self.uri_prefix, str(pool_id))
put_body = Element("pool")
p2 = Element("name", new_name)
put_body.append(p2)
resp, body = self.put(uri, str(Document(put_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例12: update_member
def update_member(self, admin_state_up, member_id):
uri = '%s/lb/members/%s' % (self.uri_prefix, str(member_id))
put_body = Element("member")
p2 = Element("admin_state_up", admin_state_up)
put_body.append(p2)
resp, body = self.put(uri, str(Document(put_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例13: update_vip
def update_vip(self, vip_id, new_name):
uri = '%s/lb/vips/%s' % (self.uri_prefix, str(vip_id))
put_body = Element("vip")
p2 = Element("name", new_name)
put_body.append(p2)
resp, body = self.put(uri, str(Document(put_body)), self.headers)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:romcheg,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例14: update_port
def update_port(self, port_id, name):
uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
port = Element("port")
p2 = Element("name", name)
port.append(p2)
resp, body = self.put(uri, str(Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例15: update_router
def update_router(self, router_id, **kwargs):
uri = '%s/routers/%s' % (self.uri_prefix, router_id)
router = Element("router")
for element, content in kwargs.iteritems():
router.append(Element(element, content))
resp, body = self.put(uri, str(Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例16: update_network
def update_network(self, net_id, name):
uri = '%s/networks/%s' % (self.uri_prefix, str(net_id))
network = Element("network")
p2 = Element("name", name)
network.append(p2)
resp, body = self.put(uri, str(Document(network)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:8,代码来源:network_client.py
示例17: serialize
def serialize(self, body):
#TODO(enikanorov): implement better json to xml conversion
# expecting the dict with single key
root = body.keys()[0]
post_body = Element(root)
for name, attr in body[root].items():
elt = Element(name, attr)
post_body.append(elt)
return str(Document(post_body))
开发者ID:ironbits,项目名称:tempest,代码行数:9,代码来源:network_client.py
示例18: update_snapshot_metadata_item
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
"""Update metadata item for the snapshot."""
for k, v in meta_item.items():
put_body = Element('meta', key=k)
put_body.append(Text(v))
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
resp, body = self.put(url, str(Document(put_body)), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
开发者ID:LIS,项目名称:LIS-Tempest,代码行数:9,代码来源:snapshots_client.py
示例19: update_agent
def update_agent(self, agent_id, agent_info):
uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
agent = Element('agent')
for (key, value) in agent_info.items():
p = Element(key, value)
agent.append(p)
resp, body = self.put(uri, str(Document(agent)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
开发者ID:vuntz,项目名称:tempest,代码行数:9,代码来源:network_client.py
示例20: update_volume_metadata_item
def update_volume_metadata_item(self, volume_id, id, meta_item):
"""Update metadata item for the volume."""
for k, v in meta_item.items():
put_body = Element('meta', key=k)
put_body.append(Text(v))
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
resp, body = self.put(url, str(Document(put_body)))
body = xml_to_json(etree.fromstring(body))
return resp, body
开发者ID:bswartz,项目名称:tempest,代码行数:9,代码来源:volumes_client.py
注:本文中的tempest.services.compute.xml.common.Element类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论