def test_tuple_with_meta(self): resp = create_response_obj_with_header() obj = common_base.TupleWithMeta((), resp) self.assertEqual((), obj) # Check request_ids attribute is added to obj self.assertTrue(hasattr(obj, 'request_ids')) self.assertEqual([REQUEST_ID], obj.request_ids)
def _action(self, action, snapshot, info=None, **kwargs): """Perform a snapshot action.""" body = {action: info} self.run_hooks('modify_body_for_action', body, **kwargs) url = '/snapshots/%s/action' % base.getid(snapshot) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def _action(self, action, backup, info=None, **kwargs): """Perform a volume backup action.""" body = {action: info} self.run_hooks('modify_body_for_action', body, **kwargs) url = '/backups/%s/action' % base.getid(backup) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def _action(self, action, volume_type, info, **kwargs): """Perform a volume type action.""" body = {action: info} self.run_hooks('modify_body_for_action', body, **kwargs) url = '/types/%s/action' % base.getid(volume_type) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def disassociate_all(self, qos_specs): """Disassociate all entities from specific qos specs. :param qos_specs: The qos specs to be associated with """ resp, body = self.api.client.get("/qos-specs/%s/disassociate_all" % base.getid(qos_specs)) return common_base.TupleWithMeta((resp, body), resp)
def clean(self, **filters): url = self.base_url + '/cleanup' resp, body = self.api.client.post(url, body=filters) cleaning = Service.list_factory(self, body['cleaning']) unavailable = Service.list_factory(self, body['unavailable']) result = common_base.TupleWithMeta((cleaning, unavailable), resp) return result
def _action(self, action, volume, info=None, **kwargs): """Perform a volume "action." :returns: tuple (response, body) """ body = {action: info} self.run_hooks('modify_body_for_action', body, **kwargs) url = '/volumes/%s/action' % base.getid(volume) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def list_replication_targets(self, group): """List replication targets for a group. :param group: the :class:`Group` to list replication targets. """ body = {'list_replication_targets': {}} self.run_hooks('modify_body_for_action', body, 'group') url = '/groups/%s/action' % base.getid(group) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def disable_replication(self, group): """disables replication for a group. :param group: the :class:`Group` to disable replication. """ body = {'disable_replication': {}} self.run_hooks('modify_body_for_action', body, 'group') url = '/groups/%s/action' % base.getid(group) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def delete(self, consistencygroup, force=False): """Delete a consistency group. :param Consistencygroup: The :class:`Consistencygroup` to delete. """ body = {'consistencygroup': {'force': force}} self.run_hooks('modify_body_for_action', body, 'consistencygroup') url = '/consistencygroups/%s/delete' % base.getid(consistencygroup) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def disassociate(self, qos_specs, vol_type_id): """Disassociate qos specs from volume type. :param qos_specs: The qos specs to be associated with :param vol_type_id: The volume type id to be associated with """ resp, body = self.api.client.get( "/qos-specs/%s/disassociate?vol_type_id=%s" % (base.getid(qos_specs), vol_type_id)) return common_base.TupleWithMeta((resp, body), resp)
def delete(self, group, delete_volumes=False): """Delete a group. :param group: the :class:`Group` to delete. :param delete_volumes: delete volumes in the group. """ body = {'delete': {'delete-volumes': delete_volumes}} self.run_hooks('modify_body_for_action', body, 'group') url = '/groups/%s/action' % base.getid(group) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def _action(self, action, group, info=None, **kwargs): """Perform a group "action." :param action: an action to be performed on the group :param group: a group to perform the action on :param info: details of the action :param **kwargs: other parameters """ body = {action: info} self.run_hooks('modify_body_for_action', body, **kwargs) url = '/groups/%s/action' % base.getid(group) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def failover_replication(self, group, allow_attached_volume=False, secondary_backend_id=None): """fails over replication for a group. :param group: the :class:`Group` to failover. :param allow attached volumes: allow attached volumes in the group. :param secondary_backend_id: secondary backend id. """ body = { 'failover_replication': { 'allow_attached_volume': allow_attached_volume, 'secondary_backend_id': secondary_backend_id } } self.run_hooks('modify_body_for_action', body, 'group') url = '/groups/%s/action' % base.getid(group) resp, body = self.api.client.post(url, body=body) return common_base.TupleWithMeta((resp, body), resp)
def _delete(self, url): resp, body = self.api.client.delete(url) return common_base.TupleWithMeta((resp, body), resp)