Ejemplo n.º 1
0
 def test_tuple_with_meta(self):
     resp = create_response_obj_with_header()
     expected_tuple = (1, 2)
     obj = base.TupleWithMeta(expected_tuple, resp)
     self.assertEqual(expected_tuple, obj)
     # Check request_ids attribute is added to obj
     self.assertTrue(hasattr(obj, 'request_ids'))
     self.assertEqual(fakes.FAKE_REQUEST_ID_LIST, obj.request_ids)
Ejemplo n.º 2
0
 def test_unset_keys(self, mock_delete):
     f = self.cs.flavors.get(1)
     keys = ['k1', 'k2']
     mock_delete.return_value = base.TupleWithMeta(
         (), fakes.FAKE_REQUEST_ID_LIST)
     fu = f.unset_keys(keys)
     self.assert_request_id(fu, fakes.FAKE_REQUEST_ID_LIST)
     mock_delete.assert_has_calls([
         mock.call("/flavors/1/os-extra_specs/k1;k2"),
     ])
Ejemplo n.º 3
0
    def host_action(self, host, action):
        """
        Perform an action on a host.

        :param host: The host to perform an action
        :param actiob: The action to perform
        returns: An instance of novaclient.base.TupleWithMeta
        """
        url = '/os-hosts/{0}/{1}'.format(host, action)
        resp, body = self.api.client.get(url)
        return base.TupleWithMeta((resp, body), resp)
Ejemplo n.º 4
0
    def host_action(self, host, action):
        """
        DEPRECATED Perform an action on a host.

        :param host: The host to perform an action
        :param action: The action to perform
        :returns: An instance of novaclient.base.TupleWithMeta
        """
        warnings.warn(HOSTS_DEPRECATION_WARNING, DeprecationWarning)
        url = '/os-hosts/%s/%s' % (host, action)
        resp, body = self.api.client.get(url)
        return base.TupleWithMeta((resp, body), resp)
Ejemplo n.º 5
0
    def unset_keys(self, keys):
        """Unset extra specs on a flavor.

        :param keys: A list of keys to be unset
        :returns: An instance of novaclient.base.TupleWithMeta
        """
        result = base.TupleWithMeta((), None)
        for k in keys:
            ret = self.manager._delete("/flavors/%s/os-extra_specs/%s" %
                                       (base.getid(self), k))
            result.append_request_ids(ret.request_ids)

        return result
Ejemplo n.º 6
0
    def get(self):
        """
        Get the own Floating IP DNS domain.

        :returns: An instance of novaclient.base.TupleWithMeta or
                  novaclient.base.ListWithMeta
        """
        entries = self.manager.domains()
        for entry in entries:
            if entry.get('domain') == self.domain:
                return entry

        return base.TupleWithMeta((), entries.request_ids)
Ejemplo n.º 7
0
    def delete_meta(self, image, keys):
        """
        Delete metadata from an image

        :param image: The :class:`Image` to delete metadata
        :param keys: A list of metadata keys to delete from the image
        :returns: An instance of novaclient.base.TupleWithMeta
        """
        result = base.TupleWithMeta((), None)
        for k in keys:
            ret = self._delete("/images/%s/metadata/%s" %
                               (base.getid(image), k))
            result.append_request_ids(ret.request_ids)

        return result
Ejemplo n.º 8
0
    def delete_meta(self, image, keys):
        """
        DEPRECATED: Delete metadata from an image

        :param image: The :class:`Image` to delete metadata
        :param keys: A list of metadata keys to delete from the image
        :returns: An instance of novaclient.base.TupleWithMeta
        """
        warnings.warn(
            'The novaclient.v2.images module is deprecated and will be '
            'removed after Nova 15.0.0 is released. Use python-glanceclient '
            'or python-openstacksdk instead.', DeprecationWarning)
        result = base.TupleWithMeta((), None)
        for k in keys:
            ret = self._delete("/images/%s/metadata/%s" %
                               (base.getid(image), k))
            result.append_request_ids(ret.request_ids)

        return result