tempest.lib.common.rest_client.ResponseBody

Here are the examples of the python api tempest.lib.common.rest_client.ResponseBody taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

199 Examples 7

Example 1

Project: neutron-lbaas Source File: network_client.py
    def _shower(self, resource_name):
        def _show(resource_id, **fields):
            # fields is a dict which key is 'fields' and value is a
            # list of field's name. An example:
            # {'fields': ['id', 'name']}
            plural = self.pluralize(resource_name)
            uri = '%s/%s' % (self.get_uri(plural), resource_id)
            if fields:
                uri += '?' + parse.urlencode(fields, doseq=1)
            resp, body = self.get(uri)
            body = self.deserialize_single(body)
            self.expected_success(200, resp.status)
            return rest_client.ResponseBody(resp, body)

        return _show

Example 2

Project: neutron-lbaas Source File: network_client.py
    def create_bulk_network(self, names, shared=False):
        network_list = [{'name': name, 'shared': shared} for name in names]
        post_data = {'networks': network_list}
        body = self.serialize_list(post_data, "networks", "network")
        uri = self.get_uri("networks")
        resp, body = self.post(uri, body)
        body = {'networks': self.deserialize_list(body)}
        self.expected_success(201, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 3

Project: ceilometer Source File: images_client.py
    def show_schema(self, schema):
        url = 'v2/schemas/%s' % schema
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 4

Project: cinder Source File: consistencygroups_client.py
    def list_cgsnapshots(self, detail=False):
        """Information for all the tenant's consistency group snapshotss."""
        url = "cgsnapshots"
        if detail:
            url += "/detail"
        resp, body = self.get(url)
        body = json.loads(body)
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 5

Project: ceilometer Source File: images_client.py
    def update_namespace(self, namespace, **kwargs):
        """Update a namespace.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v2.html#updateNamespace-v2
        """
        # NOTE: On Glance API, we need to pass namespace on both URI
        # and a request body.
        params = {'namespace': namespace}
        params.update(kwargs)
        data = json.dumps(params)
        url = '/v2/metadefs/namespaces/%s' % namespace
        resp, body = self.put(url, body=data)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 6

Project: ceilometer Source File: images_client.py
    def store_image_file(self, image_id, data):
        url = 'v2/images/%s/file' % image_id
        headers = {'Content-Type': 'application/octet-stream'}
        resp, body = self.http.raw_request('PUT', url, headers=headers,
                                           body=data)
        self.expected_success(204, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 7

Project: neutron-lbaas Source File: network_client.py
    def get_subnetpool(self, id):
        uri = self.get_uri("subnetpools")
        subnetpool_uri = '%s/%s' % (uri, id)
        resp, body = self.get(subnetpool_uri)
        body = {'subnetpool': self.deserialize_list(body)}
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 8

Project: ceilometer Source File: images_client.py
Function: check_image
    def check_image(self, image_id):
        """Check image metadata."""
        url = 'v1/images/%s' % image_id
        resp, __ = self.head(url)
        self.expected_success(200, resp.status)
        body = self._image_meta_from_headers(resp)
        return rest_client.ResponseBody(resp, body)

Example 9

Project: neutron-lbaas Source File: network_client.py
    def update_quotas(self, tenant_id, **kwargs):
        put_body = {'quota': kwargs}
        body = json.dumps(put_body)
        uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
        resp, body = self.put(uri, body)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body['quota'])

Example 10

Project: ceilometer Source File: images_client.py
Function: list_shared_images
    def list_shared_images(self, tenant_id):
        """List shared images with the specified tenant"""
        url = 'v1/shared-images/%s' % tenant_id
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 11

Project: cinder Source File: consistencygroups_client.py
    def create_cgsnapshot(self, consistencygroup_id, **kwargs):
        """Creates a consistency group snapshot."""
        post_body = {'consistencygroup_id': consistencygroup_id}
        if kwargs.get('name'):
            post_body['name'] = kwargs.get('name')
        if kwargs.get('description'):
            post_body['description'] = kwargs.get('description')
        post_body = json.dumps({'cgsnapshot': post_body})
        resp, body = self.post('cgsnapshots', post_body)
        body = json.loads(body)
        self.expected_success(202, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 12

Project: cinder Source File: consistencygroups_client.py
    def create_consistencygroup_from_src(self, **kwargs):
        """Creates a consistency group from source."""
        post_body = {}
        if kwargs.get('cgsnapshot_id'):
            post_body['cgsnapshot_id'] = kwargs.get('cgsnapshot_id')
        if kwargs.get('source_cgid'):
            post_body['source_cgid'] = kwargs.get('source_cgid')
        if kwargs.get('name'):
            post_body['name'] = kwargs.get('name')
        if kwargs.get('description'):
            post_body['description'] = kwargs.get('description')
        post_body = json.dumps({'consistencygroup-from-src': post_body})
        resp, body = self.post('consistencygroups/create_from_src', post_body)
        body = json.loads(body)
        self.expected_success(202, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 13

Project: ceilometer Source File: images_client.py
    def list_images(self, params=None):
        url = 'v2/images'

        if params:
            url += '?%s' % urllib.urlencode(params)

        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 14

Project: neutron-lbaas Source File: network_client.py
    def _lister(self, plural_name):
        def _list(**filters):
            uri = self.get_uri(plural_name)
            if filters:
                uri += '?' + parse.urlencode(filters, doseq=1)
            resp, body = self.get(uri)
            result = {plural_name: self.deserialize_list(body)}
            self.expected_success(200, resp.status)
            return rest_client.ResponseBody(resp, result)

        return _list

Example 15

Project: ceilometer Source File: images_client.py
Function: create_image
    def create_image(self, **kwargs):
        headers = {}
        data = kwargs.pop('data', None)
        headers.update(self._image_meta_to_headers(kwargs))

        if data is not None:
            return self._create_with_data(headers, data)

        resp, body = self.post('v1/images', None, headers)
        self.expected_success(201, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 16

Project: neutron-lbaas Source File: network_client.py
Function: update_r
    def _updater(self, resource_name):
        def _update(res_id, **kwargs):
            plural = self.pluralize(resource_name)
            uri = '%s/%s' % (self.get_uri(plural), res_id)
            post_data = self.serialize({resource_name: kwargs})
            resp, body = self.put(uri, post_data)
            body = self.deserialize_single(body)
            self.expected_success(200, resp.status)
            return rest_client.ResponseBody(resp, body)

        return _update

Example 17

Project: ceilometer Source File: images_client.py
    def create_image_member(self, image_id, **kwargs):
        """Create an image member.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v2.html#createImageMember-v2
        """
        url = 'v2/images/%s/members' % image_id
        data = json.dumps(kwargs)
        resp, body = self.post(url, data)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 18

Project: neutron-lbaas Source File: network_client.py
    def list_subnetpools(self):
        uri = self.get_uri("subnetpools")
        resp, body = self.get(uri)
        body = {'subnetpools': self.deserialize_list(body)}
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 19

Project: ceilometer Source File: client.py
Function: create_sample
    def create_sample(self, meter_name, sample_list):
        uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
        body = self.serialize(sample_list)
        resp, body = self.post(uri, body)
        self.expected_success(200, resp.status)
        body = self.deserialize(body)
        return rest_client.ResponseBody(resp, body)

Example 20

Project: neutron-lbaas Source File: network_client.py
    def create_bulk_port(self, port_list):
        post_data = {'ports': port_list}
        body = self.serialize_list(post_data, 'ports', 'port')
        uri = self.get_uri('ports')
        resp, body = self.post(uri, body)
        body = {'ports': self.deserialize_list(body)}
        self.expected_success(201, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 21

Project: ceilometer Source File: images_client.py
    def create_namespace(self, **kwargs):
        """Create a namespace.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v2.html#createNamespace-v2
        """
        data = json.dumps(kwargs)
        resp, body = self.post('/v2/metadefs/namespaces', data)
        self.expected_success(201, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 22

Project: ceilometer Source File: images_client.py
    def show_namespace(self, namespace):
        url = '/v2/metadefs/namespaces/%s' % namespace
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 23

Project: ceilometer Source File: client.py
Function: show_resource
    def show_resource(self, resource_id):
        uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
        resp, body = self.get(uri)
        self.expected_success(200, resp.status)
        body = self.deserialize(body)
        return rest_client.ResponseBody(resp, body)

Example 24

Project: cinder Source File: consistencygroups_client.py
    def create_consistencygroup(self, volume_types, **kwargs):
        """Creates a consistency group."""
        post_body = {'volume_types': volume_types}
        if kwargs.get('availability_zone'):
            post_body['availability_zone'] = kwargs.get('availability_zone')
        if kwargs.get('name'):
            post_body['name'] = kwargs.get('name')
        if kwargs.get('description'):
            post_body['description'] = kwargs.get('description')
        post_body = json.dumps({'consistencygroup': post_body})
        resp, body = self.post('consistencygroups', post_body)
        body = json.loads(body)
        self.expected_success(202, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 25

Project: ceilometer Source File: images_client.py
Function: add_member
    def add_member(self, member_id, image_id, **kwargs):
        """Add a member to an image.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v1.html#addMember-v1
        """
        url = 'v1/images/%s/members/%s' % (image_id, member_id)
        body = json.dumps({'member': kwargs})
        resp, __ = self.put(url, body)
        self.expected_success(204, resp.status)
        return rest_client.ResponseBody(resp)

Example 26

Project: cinder Source File: consistencygroups_client.py
    def list_consistencygroups(self, detail=False):
        """Information for all the tenant's consistency groups."""
        url = "consistencygroups"
        if detail:
            url += "/detail"
        resp, body = self.get(url)
        body = json.loads(body)
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 27

Project: cinder Source File: consistencygroups_client.py
    def delete_consistencygroup(self, cg_id):
        """Delete a consistency group."""
        post_body = {'force': True}
        post_body = json.dumps({'consistencygroup': post_body})
        resp, body = self.post('consistencygroups/%s/delete' % cg_id,
                               post_body)
        self.expected_success(202, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 28

Project: ceilometer Source File: images_client.py
    def create_image(self, **kwargs):
        """Create an image.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v2.html#createImage-v2
        """
        data = json.dumps(kwargs)
        resp, body = self.post('v2/images', data)
        self.expected_success(201, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 29

Project: cinder Source File: consistencygroups_client.py
    def show_cgsnapshot(self, cgsnapshot_id):
        """Returns the details of a single consistency group snapshot."""
        url = "cgsnapshots/%s" % str(cgsnapshot_id)
        resp, body = self.get(url)
        body = json.loads(body)
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 30

Project: ceilometer Source File: images_client.py
    def _update_with_data(self, image_id, headers, data):
        url = '/v1/images/%s' % image_id
        resp, body_iter = self.http.raw_request('PUT', url, headers=headers,
                                                body=data)
        self._error_checker(resp, body_iter)
        body = json.loads(''.join([c for c in body_iter]))
        return rest_client.ResponseBody(resp, body)

Example 31

Project: networking-vsphere Source File: manager.py
    def _delete_server(self, server=None):
        rs_client = self._connect_server()
        resp, body = rs_client.delete("servers/%s" % str(server))
        clients = self.manager
        self.addCleanup(waiters.wait_for_server_termination,
                        clients.servers_client,
                        server)
        self.addCleanup_with_wait(
            waiter_callable=waiters.wait_for_server_termination,
            thing_id=server, thing_id_param='server_id',
            cleanup_callable=test_utils.call_and_ignore_notfound_exc,
            cleanup_args=[clients.servers_client.delete_server, server],
            waiter_client=clients.servers_client)

        rest_client.ResponseBody(resp, body)

Example 32

Project: ceilometer Source File: images_client.py
    def show_image(self, image_id):
        url = 'v2/images/%s' % image_id
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 33

Project: neutron-lbaas Source File: network_client.py
Function: deleter
    def _deleter(self, resource_name):
        def _delete(resource_id):
            plural = self.pluralize(resource_name)
            uri = '%s/%s' % (self.get_uri(plural), resource_id)
            resp, body = self.delete(uri)
            self.expected_success(204, resp.status)
            return rest_client.ResponseBody(resp, body)

        return _delete

Example 34

Project: aodh Source File: client.py
Function: update_alarm
    def update_alarm(self, alarm_id, **kwargs):
        uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
        body = self.serialize(kwargs)
        resp, body = self.put(uri, body)
        self.expected_success(200, resp.status)
        body = self.deserialize(body)
        return rest_client.ResponseBody(resp, body)

Example 35

Project: neutron-lbaas Source File: network_client.py
    def _creater(self, resource_name):
        def _create(**kwargs):
            plural = self.pluralize(resource_name)
            uri = self.get_uri(plural)
            post_data = self.serialize({resource_name: kwargs})
            resp, body = self.post(uri, post_data)
            body = self.deserialize_single(body)
            self.expected_success(201, resp.status)
            return rest_client.ResponseBody(resp, body)

        return _create

Example 36

Project: ceilometer Source File: images_client.py
    def list_image_members(self, image_id):
        url = 'v2/images/%s/members' % image_id
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 37

Project: neutron-lbaas Source File: network_client.py
Function: create_subnetpool
    def create_subnetpool(self, post_data):
        body = self.serialize_list(post_data, "subnetpools", "subnetpool")
        uri = self.get_uri("subnetpools")
        resp, body = self.post(uri, body)
        body = {'subnetpool': self.deserialize_list(body)}
        self.expected_success(201, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 38

Project: ceilometer Source File: images_client.py
Function: update_image
    def update_image(self, image_id, **kwargs):
        headers = {}
        data = kwargs.pop('data', None)
        headers.update(self._image_meta_to_headers(kwargs))

        if data is not None:
            return self._update_with_data(image_id, headers, data)

        url = 'v1/images/%s' % image_id
        resp, body = self.put(url, None, headers)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 39

Project: neutron-lbaas Source File: network_client.py
Function: delete_subnetpool
    def delete_subnetpool(self, id):
        uri = self.get_uri("subnetpools")
        subnetpool_uri = '%s/%s' % (uri, id)
        resp, body = self.delete(subnetpool_uri)
        self.expected_success(204, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 40

Project: ceilometer Source File: images_client.py
    def update_image_member(self, image_id, member_id, **kwargs):
        """Update an image member.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v2.html#updateImageMember-v2
        """
        url = 'v2/images/%s/members/%s' % (image_id, member_id)
        data = json.dumps(kwargs)
        resp, body = self.put(url, data)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 41

Project: neutron-lbaas Source File: network_client.py
Function: update_subnetpool
    def update_subnetpool(self, id, post_data):
        body = self.serialize_list(post_data, "subnetpools", "subnetpool")
        uri = self.get_uri("subnetpools")
        subnetpool_uri = '%s/%s' % (uri, id)
        resp, body = self.put(subnetpool_uri, body)
        body = {'subnetpool': self.deserialize_list(body)}
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 42

Project: aodh Source File: client.py
Function: delete_alarm
    def delete_alarm(self, alarm_id):
        uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
        resp, body = self.delete(uri)
        self.expected_success(204, resp.status)
        if body:
            body = self.deserialize(body)
        return rest_client.ResponseBody(resp, body)

Example 43

Project: neutron-lbaas Source File: network_client.py
    def create_bulk_subnet(self, subnet_list):
        post_data = {'subnets': subnet_list}
        body = self.serialize_list(post_data, 'subnets', 'subnet')
        uri = self.get_uri('subnets')
        resp, body = self.post(uri, body)
        body = {'subnets': self.deserialize_list(body)}
        self.expected_success(201, resp.status)
        return rest_client.ResponseBody(resp, body)

Example 44

Project: ceilometer Source File: images_client.py
    def list_resource_types(self):
        url = '/v2/metadefs/resource_types'
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 45

Project: ceilometer Source File: images_client.py
Function: list_image_members
    def list_image_members(self, image_id):
        url = 'v1/images/%s/members' % image_id
        resp, body = self.get(url)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 46

Project: aodh Source File: client.py
    def show_alarm(self, alarm_id):
        uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
        resp, body = self.get(uri)
        self.expected_success(200, resp.status)
        body = self.deserialize(body)
        return rest_client.ResponseBody(resp, body)

Example 47

Project: aodh Source File: client.py
Function: create_alarm
    def create_alarm(self, **kwargs):
        uri = "%s/alarms" % self.uri_prefix
        body = self.serialize(kwargs)
        resp, body = self.post(uri, body)
        self.expected_success(201, resp.status)
        body = self.deserialize(body)
        return rest_client.ResponseBody(resp, body)

Example 48

Project: ceilometer Source File: images_client.py
    def _create_with_data(self, headers, data):
        resp, body_iter = self.http.raw_request('POST', '/v1/images',
                                                headers=headers, body=data)
        self._error_checker(resp, body_iter)
        body = json.loads(''.join([c for c in body_iter]))
        return rest_client.ResponseBody(resp, body)

Example 49

Project: ceilometer Source File: images_client.py
    def update_image(self, image_id, patch):
        """Update an image.

        Available params: see http://developer.openstack.org/
                              api-ref-image-v2.html#updateImage-v2
        """
        data = json.dumps(patch)
        headers = {"Content-Type": "application/openstack-images-v2.0"
                                   "-json-patch"}
        resp, body = self.patch('v2/images/%s' % image_id, data, headers)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)

Example 50

Project: cinder Source File: consistencygroups_client.py
    def show_consistencygroup(self, cg_id):
        """Returns the details of a single consistency group."""
        url = "consistencygroups/%s" % str(cg_id)
        resp, body = self.get(url)
        body = json.loads(body)
        self.expected_success(200, resp.status)
        return rest_client.ResponseBody(resp, body)
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4