• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.xml_to_json函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tempest.services.compute.xml.common.xml_to_json函数的典型用法代码示例。如果您正苦于以下问题:Python xml_to_json函数的具体用法?Python xml_to_json怎么用?Python xml_to_json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了xml_to_json函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update_server

    def update_server(self, server_id, name=None, meta=None, access_ip_v4=None,
                      access_ip_v6=None, disk_config=None):
        doc = Document()
        server = Element("server")
        doc.append(server)

        if name is not None:
            server.add_attr("name", name)
        if access_ip_v4 or access_ip_v6:
            server.add_attr('xmlns:os-access-ips',
                            "http://docs.openstack.org/compute/ext/"
                            "os-access-ips/api/v3")
        if access_ip_v4 is not None:
            server.add_attr("os-access-ips:access_ip_v4", access_ip_v4)
        if access_ip_v6 is not None:
            server.add_attr("os-access-ips:access_ip_v6", access_ip_v6)
        if disk_config is not None:
            server.add_attr('xmlns:os-disk-config', "http://docs.openstack.org"
                            "/compute/ext/disk_config/api/v3")
            server.add_attr("os-disk-config:disk_config", disk_config)
        if meta is not None:
            metadata = Element("metadata")
            server.append(metadata)
            for k, v in meta:
                meta = Element("meta", key=k)
                meta.append(Text(v))
                metadata.append(meta)

        resp, body = self.put('servers/%s' % str(server_id),
                              str(doc), self.headers)
        return resp, xml_to_json(etree.fromstring(body))
开发者ID:BeenzSyed,项目名称:tempest,代码行数:31,代码来源:servers_client.py


示例2: _parse_creds

 def _parse_creds(self, node):
     array = []
     for child in node.getchildren():
         tag_list = child.tag.split('}', 1)
         if tag_list[1] == "credential":
             array.append(common.xml_to_json(child))
     return array
开发者ID:arnaudleg,项目名称:tempest,代码行数:7,代码来源:credentials_client.py


示例3: set_image_metadata_item

 def set_image_metadata_item(self, image_id, key, meta):
     """Sets the value for a specific image metadata key"""
     post_body = json.dumps({'meta': meta})
     resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
                           post_body, self.headers)
     body = xml_to_json(etree.fromstring(body))
     return resp, body['meta']
开发者ID:eghobo,项目名称:tempest,代码行数:7,代码来源:images_client.py


示例4: create_volume_type

    def create_volume_type(self, name, **kwargs):
        """
        Creates a new Volume_type.
        name(Required): Name of volume_type.
        Following optional keyword arguments are accepted:
        extra_specs: A dictionary of values to be used as extra_specs.
        """
        vol_type = Element("volume_type", xmlns=XMLNS_11)
        if name:
            vol_type.add_attr('name', name)

        extra_specs = kwargs.get('extra_specs')
        if extra_specs:
            _extra_specs = Element('extra_specs')
            vol_type.append(_extra_specs)
            for key, value in extra_specs.items():
                spec = Element('extra_spec')
                spec.add_attr('key', key)
                spec.append(Text(value))
                _extra_specs.append(spec)

        resp, body = self.post('types', str(Document(vol_type)),
                               self.headers)
        body = xml_to_json(etree.fromstring(body))
        return resp, body
开发者ID:Grindizer,项目名称:tempest,代码行数:25,代码来源:volume_types_client.py


示例5: get_console_output

 def get_console_output(self, server_id, length):
     post_body = Element("os-getConsoleOutput", length=length)
     resp, body = self.post("/servers/%s/action" % server_id,
                            headers=self.headers,
                            body=str(Document(post_body)))
     body = xml_to_json(etree.fromstring(body))
     return resp, body
开发者ID:TimurNurlygayanov,项目名称:tempest,代码行数:7,代码来源:console_output_client.py


示例6: set_image_metadata

 def set_image_metadata(self, image_id, meta):
     """Sets the metadata for an image"""
     post_body = json.dumps({'metadata': meta})
     resp, body = self.put('images/%s/metadata' % str(image_id),
                           post_body, self.headers)
     body = xml_to_json(etree.fromstring(body))
     return resp, body['metadata']
开发者ID:eghobo,项目名称:tempest,代码行数:7,代码来源:images_client.py


示例7: _parse_domains

 def _parse_domains(self, node):
     array = []
     for child in node.getchildren():
         tag_list = child.tag.split("}", 1)
         if tag_list[1] == "domain":
             array.append(xml_to_json(child))
     return array
开发者ID:rockyg,项目名称:tempest,代码行数:7,代码来源:identity_client.py


示例8: upload_volume

 def upload_volume(self, volume_id, image_name, disk_format):
     """Uploads a volume in Glance."""
     post_body = Element("os-volume_upload_image", image_name=image_name, disk_format=disk_format)
     url = "volumes/%s/action" % str(volume_id)
     resp, body = self.post(url, str(Document(post_body)), self.headers)
     volume = xml_to_json(etree.fromstring(body))
     return resp, volume
开发者ID:notmyname,项目名称:tempest,代码行数:7,代码来源:volumes_client.py


示例9: update_volume

    def update_volume(self, volume_id, **kwargs):
        """Updates the Specified Volume."""
        put_body = Element("volume", xmlns=XMLNS_11, **kwargs)

        resp, body = self.put("volumes/%s" % volume_id, str(Document(put_body)), self.headers)
        body = xml_to_json(etree.fromstring(body))
        return resp, body
开发者ID:notmyname,项目名称:tempest,代码行数:7,代码来源:volumes_client.py


示例10: create_volume

    def create_volume(self, size, display_name=None, metadata=None):
        """Creates a new Volume.

        :param size: Size of volume in GB. (Required)
        :param display_name: Optional Volume Name.
        :param metadata: An optional dictionary of values for metadata.
        """
        volume = Element("volume",
                         xmlns=XMLNS_11,
                         size=size)
        if display_name:
            volume.add_attr('display_name', display_name)

        if metadata:
            _metadata = Element('metadata')
            volume.append(_metadata)
            for key, value in metadata.items():
                meta = Element('meta')
                meta.add_attr('key', key)
                meta.append(Text(value))
                _metadata.append(meta)

        resp, body = self.post('os-volumes', str(Document(volume)),
                               self.headers)
        body = xml_to_json(etree.fromstring(body))
        return resp, body
开发者ID:Grindizer,项目名称:tempest,代码行数:26,代码来源:volumes_extensions_client.py


示例11: _parse_array

 def _parse_array(self, node):
     array = []
     for child in node.getchildren():
         tag_list = child.tag.split('}', 1)
         if tag_list[1] == "endpoint":
             array.append(xml_to_json(child))
     return array
开发者ID:Grindizer,项目名称:tempest,代码行数:7,代码来源:endpoints_client.py


示例12: create_volume

    def create_volume(self, size, **kwargs):
        """Creates a new Volume.

        :param size: Size of volume in GB. (Required)
        :param name: Optional Volume Name.
        :param metadata: An optional dictionary of values for metadata.
        :param volume_type: Optional Name of volume_type for the volume
        :param snapshot_id: When specified the volume is created from
                            this snapshot
        :param imageRef: When specified the volume is created from this
                         image
        """
        # NOTE(afazekas): it should use a volume namespace
        volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)

        if 'metadata' in kwargs:
            _metadata = common.Element('metadata')
            volume.append(_metadata)
            for key, value in kwargs['metadata'].items():
                meta = common.Element('meta')
                meta.add_attr('key', key)
                meta.append(common.Text(value))
                _metadata.append(meta)
            attr_to_add = kwargs.copy()
            del attr_to_add['metadata']
        else:
            attr_to_add = kwargs

        for key, value in attr_to_add.items():
            volume.add_attr(key, value)

        resp, body = self.post('volumes', str(common.Document(volume)))
        body = common.xml_to_json(etree.fromstring(body))
        return resp, body
开发者ID:arnaudleg,项目名称:tempest,代码行数:34,代码来源:volumes_client.py


示例13: create_flavor

 def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
     """Creates a new flavor or instance type."""
     flavor = Element("flavor",
                      xmlns=XMLNS_11,
                      ram=ram,
                      vcpus=vcpus,
                      disk=disk,
                      id=flavor_id,
                      name=name)
     if kwargs.get('rxtx'):
         flavor.add_attr('rxtx_factor', kwargs.get('rxtx'))
     if kwargs.get('swap'):
         flavor.add_attr('swap', kwargs.get('swap'))
     if kwargs.get('ephemeral'):
         flavor.add_attr('OS-FLV-EXT-DATA:ephemeral',
                         kwargs.get('ephemeral'))
     if kwargs.get('is_public'):
         flavor.add_attr('os-flavor-access:is_public',
                         kwargs.get('is_public'))
     flavor.add_attr('xmlns:OS-FLV-EXT-DATA', XMLNS_OS_FLV_EXT_DATA)
     flavor.add_attr('xmlns:os-flavor-access', XMLNS_OS_FLV_ACCESS)
     resp, body = self.post('flavors', str(Document(flavor)), self.headers)
     body = xml_to_json(etree.fromstring(body))
     flavor = self._format_flavor(body)
     return resp, flavor
开发者ID:DmitryIakunchikov,项目名称:tempest,代码行数:25,代码来源:flavors_client.py


示例14: update_server

    def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
                      accessIPv6=None, disk_config=None):
        doc = Document()
        server = Element("server")
        doc.append(server)

        if name is not None:
            server.add_attr("name", name)
        if accessIPv4 is not None:
            server.add_attr("accessIPv4", accessIPv4)
        if accessIPv6 is not None:
            server.add_attr("accessIPv6", accessIPv6)
        if disk_config is not None:
            server.add_attr('xmlns:OS-DCF', "http://docs.openstack.org/"
                            "compute/ext/disk_config/api/v1.1")
            server.add_attr("OS-DCF:diskConfig", disk_config)
        if meta is not None:
            metadata = Element("metadata")
            server.append(metadata)
            for k, v in meta:
                meta = Element("meta", key=k)
                meta.append(Text(v))
                metadata.append(meta)

        resp, body = self.put('servers/%s' % str(server_id), str(doc))
        return resp, xml_to_json(etree.fromstring(body))
开发者ID:suxin1234,项目名称:tempest,代码行数:26,代码来源:servers_client.py


示例15: update_image_metadata_item

 def update_image_metadata_item(self, image_id, key, meta):
     """Sets the value for a specific image metadata key."""
     post_body = Document('meta', Text(meta), key=key)
     resp, body = self.put('images/%s/metadata/%s' % (str(image_id), key),
                           post_body, self.headers)
     body = xml_to_json(etree.fromstring(body))
     return resp, body['meta']
开发者ID:SinSiXX,项目名称:tempest,代码行数:7,代码来源:images_client.py


示例16: show_host_detail

    def show_host_detail(self, hostname):
        """Show detail information for the host."""

        resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
        node = etree.fromstring(body)
        body = [xml_to_json(x) for x in node.getchildren()]
        return resp, body
开发者ID:aimonb,项目名称:tempest,代码行数:7,代码来源:hosts_client.py


示例17: update_quota_set

    def update_quota_set(self, tenant_id, force=None,
                         injected_file_content_bytes=None,
                         metadata_items=None, ram=None, floating_ips=None,
                         fixed_ips=None, key_pairs=None, instances=None,
                         security_group_rules=None, injected_files=None,
                         cores=None, injected_file_path_bytes=None,
                         security_groups=None):
        """
        Updates the tenant's quota limits for one or more resources
        """
        post_body = Element("quota_set",
                            xmlns=XMLNS_11)

        if force is not None:
            post_body.add_attr('force', force)

        if injected_file_content_bytes is not None:
            post_body.add_attr('injected_file_content_bytes',
                               injected_file_content_bytes)

        if metadata_items is not None:
            post_body.add_attr('metadata_items', metadata_items)

        if ram is not None:
            post_body.add_attr('ram', ram)

        if floating_ips is not None:
            post_body.add_attr('floating_ips', floating_ips)

        if fixed_ips is not None:
            post_body.add_attr('fixed_ips', fixed_ips)

        if key_pairs is not None:
            post_body.add_attr('key_pairs', key_pairs)

        if instances is not None:
            post_body.add_attr('instances', instances)

        if security_group_rules is not None:
            post_body.add_attr('security_group_rules', security_group_rules)

        if injected_files is not None:
            post_body.add_attr('injected_files', injected_files)

        if cores is not None:
            post_body.add_attr('cores', cores)

        if injected_file_path_bytes is not None:
            post_body.add_attr('injected_file_path_bytes',
                               injected_file_path_bytes)

        if security_groups is not None:
            post_body.add_attr('security_groups', security_groups)

        resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
                              str(Document(post_body)),
                              self.headers)
        body = xml_to_json(etree.fromstring(body))
        body = self._format_quota(body)
        return resp, body
开发者ID:LIS,项目名称:LIS-Tempest,代码行数:60,代码来源:quotas_client.py


示例18: reboot_host

    def reboot_host(self, hostname):
        """Reboot a host."""

        resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
        node = etree.fromstring(body)
        body = [xml_to_json(x) for x in node.getchildren()]
        return resp, body
开发者ID:andrewsben,项目名称:tempest,代码行数:7,代码来源:hosts_client.py


示例19: show_host_detail

    def show_host_detail(self, hostname):
        """Show detail information for the host."""

        resp, body = self.get("os-hosts/%s" % str(hostname))
        node = etree.fromstring(body)
        body = [xml_to_json(node)]
        return resp, body
开发者ID:andrewsben,项目名称:tempest,代码行数:7,代码来源:hosts_client.py


示例20: accept_volume_transfer

 def accept_volume_transfer(self, transfer_id, transfer_auth_key):
     """Accept a volume transfer."""
     post_body = Element("accept", auth_key=transfer_auth_key)
     url = 'os-volume-transfer/%s/accept' % transfer_id
     resp, body = self.post(url, str(Document(post_body)))
     volume = xml_to_json(etree.fromstring(body))
     return resp, volume
开发者ID:bswartz,项目名称:tempest,代码行数:7,代码来源:volumes_client.py



注:本文中的tempest.services.compute.xml.common.xml_to_json函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.Document类代码示例发布时间:2022-05-27
下一篇:
Python log.setup函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap