本文整理汇总了Python中tempest.services.compute.xml.common.Element.append方法的典型用法代码示例。如果您正苦于以下问题:Python Element.append方法的具体用法?Python Element.append怎么用?Python Element.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tempest.services.compute.xml.common.Element
的用法示例。
在下文中一共展示了Element.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: auth
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例2: _metadata_body
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
def _metadata_body(self, meta):
post_body = Element('metadata')
for k, v in meta.items():
data = Element('meta', key=k)
data.append(Text(v))
post_body.append(data)
return post_body
示例3: create_security_group_rule
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
def create_security_group_rule(self, parent_group_id, ip_proto, from_port, to_port, **kwargs):
"""
Creating a new security group rules.
parent_group_id :ID of Security group
ip_protocol : ip_proto (icmp, tcp, udp).
from_port: Port at start of range.
to_port : Port at end of range.
Following optional keyword arguments are accepted:
cidr : CIDR for address range.
group_id : ID of the Source group
"""
group_rule = Element("security_group_rule")
elements = dict()
elements["cidr"] = kwargs.get("cidr")
elements["group_id"] = kwargs.get("group_id")
elements["parent_group_id"] = parent_group_id
elements["ip_protocol"] = ip_proto
elements["from_port"] = from_port
elements["to_port"] = to_port
for k, v in elements.items():
if v is not None:
element = Element(k)
element.append(Text(content=str(v)))
group_rule.append(element)
url = "os-security-group-rules"
resp, body = self.post(url, str(Document(group_rule)), self.headers)
body = self._parse_body(etree.fromstring(body))
return resp, body
示例4: set_image_metadata_item
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例5: update_network
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例6: update_pool
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例7: _metadata_body
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
def _metadata_body(self, meta):
post_body = Element('metadata')
for k, v in meta.items():
data = Element('meta', key=k)
# Escape value to allow for special XML chars
data.append(Text(escape(v)))
post_body.append(data)
return post_body
示例8: set_server_metadata_item
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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))
示例9: update_member
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例10: update_router
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例11: create_network
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例12: create_security_group
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例13: create_router
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例14: update_health_monitor
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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
示例15: update_port
# 需要导入模块: from tempest.services.compute.xml.common import Element [as 别名]
# 或者: from tempest.services.compute.xml.common.Element import append [as 别名]
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