当前位置: 首页>>代码示例>>Python>>正文


Python common.xml_to_json函数代码示例

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


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


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