def delete(self, transfer_id):
        """Delete a volume transfer.

        :param transfer_id: The :class:`VolumeTransfer` to delete.
        """
        if self.api_version.matches('3.55'):
            return self._delete(
                "/volume-transfers/%s" % base.getid(transfer_id))

        return self._delete("/os-volume-transfer/%s" % base.getid(transfer_id))
    def delete_metadata(self, volume, keys):
        """Delete specified keys from volumes metadata.

        :param volume: The :class:`Volume`.
        :param keys: A list of keys to be removed.
        """
        data = self._get("/volumes/%s/metadata" % base.getid(volume))
        metadata = data._info.get("metadata", {})
        if set(keys).issubset(metadata.keys()):
            for k in keys:
                metadata.pop(k)
            body = {'metadata': metadata}
            kwargs = {'headers': {'If-Match': data._checksum}}
            return self._update("/volumes/%s/metadata" % base.getid(volume),
                                body, **kwargs)
 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 get(self, volume_type):
        """Get a specific volume type.

        :param volume_type: The ID of the :class:`VolumeType` to get.
        :rtype: :class:`VolumeType`
        """
        return self._get("/types/%s" % base.getid(volume_type), "volume_type")
    def delete(self, volume_type):
        """
        Delete a specific volume_type.

        :param volume_type: The ID of the :class:`VolumeType` to get.
        """
        self._delete("/types/%s" % base.getid(volume_type))
 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)
Beispiel #7
0
    def delete(self, volume):
        """
        Delete a volume.

        :param volume: The :class:`Volume` to delete.
        """
        self._delete("/volumes/%s" % base.getid(volume))
    def get(self, qos_specs):
        """Get a specific qos specs.

        :param qos_specs: The ID of the :class:`QoSSpecs` to get.
        :rtype: :class:`QoSSpecs`
        """
        return self._get("/qos-specs/%s" % base.getid(qos_specs), "qos_specs")
 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 delete(self, snapshot):
        """
        Delete a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        self._delete("/snapshots/%s" % base.getid(snapshot))
    def disassociate_all(self, qos_specs):
        """Disassociate all entities from specific qos specs.

        :param qos_specs: The qos specs to be associated with
        """
        self.api.client.get("/qos-specs/%s/disassociate_all" %
                            base.getid(qos_specs))
Beispiel #12
0
    def get_keys(self):
        """Get extra specs from a volume type.

        :param vol_type: The :class:`VolumeType` to get extra specs from
        """
        _resp, body = self.manager.api.client.get("/types/%s/extra_specs" % base.getid(self))
        return body["extra_specs"]
 def _action(self, action, cgsnapshot, info=None, **kwargs):
     """Perform a cgsnapshot "action."
     """
     body = {action: info}
     self.run_hooks('modify_body_for_action', body, **kwargs)
     url = '/cgsnapshots/%s/action' % base.getid(cgsnapshot)
     return self.api.client.post(url, body=body)
 def _action(self, action, volume, info=None, **kwargs):
     """Perform a volume "action."
     """
     body = {action: info}
     self.run_hooks('modify_body_for_action', body, **kwargs)
     url = '/volumes/%s/action' % base.getid(volume)
     return self.api.client.post(url, body=body)
 def _action(self, action, consistencygroup, info=None, **kwargs):
     """Perform a consistencygroup "action."
     """
     body = {action: info}
     self.run_hooks("modify_body_for_action", body, **kwargs)
     url = "/consistencygroups/%s/action" % base.getid(consistencygroup)
     return self.api.client.post(url, body=body)
    def set_metadata(self, volume, metadata):
        """Update/Set a volumes metadata.

        :param volume: The :class:`Volume`.
        :param metadata: A list of keys to be set.
        """
        body = {"metadata": metadata}
        return self._create("/volumes/%s/metadata" % base.getid(volume), body, "metadata")
Beispiel #17
0
    def set_keys(self, metadata):
        """Set extra specs on a volume type.

        :param type : The :class:`VolumeType` to set extra spec on
        :param metadata: A dict of key/value pairs to be set
        """
        body = {"extra_specs": metadata}
        return self.manager._create("/types/%s/extra_specs" % base.getid(self), body, "extra_specs", return_raw=True)
    def delete_metadata(self, volume, keys):
        """Delete specified keys from volumes metadata.

        :param volume: The :class:`Volume`.
        :param keys: A list of keys to be removed.
        """
        for k in keys:
            self._delete("/volumes/%s/metadata/%s" % (base.getid(volume), k))
    def update_all_metadata(self, volume, metadata):
        """Update all metadata of a volume.

        :param volume: The :class:`Volume`.
        :param metadata: A list of keys to be updated.
        """
        body = {"metadata": metadata}
        return self._update("/volumes/%s/metadata" % base.getid(volume), body)
Beispiel #20
0
    def get(self, volume_type):
        """
        Get the volume encryption type for the specified volume type.

        :param volume_type: the volume type to query
        :return: an instance of :class: VolumeEncryptionType
        """
        return self._get("/types/%s/encryption" % base.getid(volume_type))
    def associate(self, qos_specs, vol_type_id):
        """Associate a volume type with specific qos specs.

        :param qos_specs: The qos specs to be associated with
        :param vol_type_id: The volume type id to be associated with
        """
        self.api.client.get("/qos-specs/%s/associate?vol_type_id=%s" %
                            (base.getid(qos_specs), vol_type_id))
    def get_associations(self, qos_specs):
        """Get associated entities of a qos specs.

        :param qos_specs: The id of the :class: `QoSSpecs`
        :return: a list of entities that associated with specific qos specs.
        """
        return self._list("/qos-specs/%s/associations" % base.getid(qos_specs),
                          "qos_associations")
    def get(self, group_type):
        """Get a specific group type.

        :param group_type: The ID of the :class:`GroupType` to get.
        :rtype: :class:`GroupType`
        """
        return self._get("/group_types/%s" % base.getid(group_type),
                         "group_type")
    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
        """
        self.api.client.get("/qos-specs/%s/disassociate?vol_type_id=%s" %
                            (base.getid(qos_specs), vol_type_id))
    def extend(self, volume, new_size):
        """Extend the size of the specified volume.

        :param volume: The UUID of the volume to extend.
        :param new_size: The requested size to extend volume to.
        """
        return self._action('os-extend',
                            base.getid(volume),
                            {'new_size': new_size})
    def update_all_metadata(self, snapshot, metadata):
        """Update_all snapshot metadata.

        :param snapshot: The :class:`Snapshot`.
        :param metadata: A list of keys to be updated.
        """
        body = {'metadata': metadata}
        return self._update("/snapshots/%s/metadata" % base.getid(snapshot),
                            body)
    def delete_metadata(self, snapshot, keys):
        """Delete specified keys from snapshot metadata.

        :param snapshot: The :class:`Snapshot`.
        :param keys: A list of keys to be removed.
        """
        snapshot_id = base.getid(snapshot)
        for k in keys:
            self._delete("/snapshots/%s/metadata/%s" % (snapshot_id, k))
    def delete(self, qos_specs, force=False):
        """Delete a specific qos specs.

        :param qos_specs: The ID of the :class:`QoSSpecs` to be removed.
        :param force: Flag that indicates whether to delete target qos specs
                      if it was in-use.
        """
        self._delete("/qos-specs/%s?force=%s" %
                     (base.getid(qos_specs), force))
    def get_keys(self):
        """Get group specs from a group type.

        :param type: The :class:`GroupType` to get specs from
        """
        _resp, body = self.manager.api.client.get(
            "/group_types/%s/group_specs" %
            base.getid(self))
        return body["group_specs"]
    def set_metadata(self, snapshot, metadata):
        """Update/Set a snapshots metadata.

        :param snapshot: The :class:`Snapshot`.
        :param metadata: A list of keys to be set.
        """
        body = {'metadata': metadata}
        return self._create("/snapshots/%s/metadata" % base.getid(snapshot),
                            body, "metadata")
Beispiel #31
0
    def unset_keys(self, keys):
        """Unset extra specs on a volue type.

        :param type_id: The :class:`VolumeType` to unset extra spec on
        :param keys: A list of keys to be unset
        """

        # NOTE(jdg): This wasn't actually doing all of the keys before
        # the return in the loop resulted in ony ONE key being unset.
        # since on success the return was NONE, we'll only interrupt the loop
        # and return if there's an error
        for k in keys:
            resp = self.manager._delete(
                "/types/%s/extra_specs/%s" % (
                base.getid(self), k))
            if resp is not None:
                return resp
Beispiel #32
0
    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)
Beispiel #33
0
    def list(self, search_opts=None):
        """
        List all volume encryption types.

        :param search_opts: Search options to filter out volume
                            encryption types
        :return: a list of :class: VolumeEncryptionType instances
        """
        # Since the encryption type is a volume type extension, we cannot get
        # all encryption types without going through all volume types.
        volume_types = self.api.volume_types.list()
        encryption_types = []
        for volume_type in volume_types:
            encryption_type = self._get("/types/%s/encryption" %
                                        base.getid(volume_type))
            if hasattr(encryption_type, 'volume_type_id'):
                encryption_types.append(encryption_type)
        return encryption_types
Beispiel #34
0
    def unset_keys(self, keys):
        """Unset extra specs on a volue type.

        :param type_id: The :class:`VolumeType` to unset extra spec on
        :param keys: A list of keys to be unset
        """

        # NOTE(jdg): This wasn't actually doing all of the keys before
        # the return in the loop resulted in only ONE key being unset,
        # since on success the return was ListWithMeta class, we'll only
        # interrupt the loop and if an exception is raised.
        response_list = []
        for k in keys:
            resp, body = self.manager._delete("/types/%s/extra_specs/%s" %
                                              (base.getid(self), k))
            response_list.append(resp)

        return common_base.ListWithMeta([], response_list)
    def update(self, volume_type, name=None, description=None, is_public=None):
        """Update the name and/or description for a volume type.

        :param volume_type: The ID of the :class:`VolumeType` to update.
        :param name: Descriptive name of the volume type.
        :param description: Description of the the volume type.
        :rtype: :class:`VolumeType`
        """

        body = {
            "volume_type": {
                "name": name,
                "description": description
            }
        }
        if is_public is not None:
            body["volume_type"]["is_public"] = is_public

        return self._update("/types/%s" % base.getid(volume_type),
                            body, response_key="volume_type")
Beispiel #36
0
    def list(self, search_opts=None):
        """
        List all volume encryption types.

        :param volume_types: a list of volume types
        :return: a list of :class: VolumeEncryptionType instances
        """
        # Since the encryption type is a volume type extension, we cannot get
        # all encryption types without going through all volume types.
        volume_types = self.api.volume_types.list()
        encryption_types = []
        list_of_resp = []
        for volume_type in volume_types:
            encryption_type = self._get("/types/%s/encryption" %
                                        base.getid(volume_type))
            if hasattr(encryption_type, 'volume_type_id'):
                encryption_types.append(encryption_type)

            list_of_resp.extend(encryption_type.request_ids)

        return common_base.ListWithMeta(encryption_types, list_of_resp)
Beispiel #37
0
    def force_delete(self, snapshot):
        """Force delete a snapshot ignoring its current state.

        :param snapshot: The :class:`Snapshot` to force delete.
        """
        return self._action('os-force_delete', base.getid(snapshot))
Beispiel #38
0
 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)
     return self.api.client.post(url, body=body)
Beispiel #39
0
    def delete(self, group_type):
        """Deletes a specific group_type.

        :param group_type: The name or ID of the :class:`GroupType` to get.
        """
        return self._delete("/group_types/%s" % base.getid(group_type))
 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)
     return self.api.client.post(url, body=body)
Beispiel #41
0
loader=loading.get_plugin_loader('password')
auth=loader.load_from_options(auth_url=keystone_url_180_12,username="******",password="******",project_name="admin")
sess=session.Session(auth=auth)
cinder=client.Client(version="2.0",session=sess)
spec1={
    "total_iops_sec":"2000"
}
spec2={
    "total_bytes_sec":"2048000"
}
consumer1="front-end"
consumer2="back-end"
qos1=cinder.qos_specs.create(name="high_read_low_write",specs=spec1,consumer=consumer1)
qos2=cinder.qos_specs.create(name="read_write",specs=spec2,consumer=consumer1)
type1=cinder.volume_types.create(name="cmcc3",description="iops")
type2=cinder.volume_types.create(name="cmcc4",description="bw")
tspec1={
    "volume_backend_name":"DEFAULT"
}
tspec2={
    "volume_backend_name":"DEFAULT"
}
type1.set_keys(tspec1)
type2.set_keys(tspec2)
q_a_t1=cinder.qos_specs.associate(qos1,base.getid(type1))
q_a_t2=cinder.qos_specs.associate(qos2,base.getid(type2))

volume1=cinder.volumes.create(name="cmcc3",size=10,volume_type=base.getid(type1),availability_zone="nova")
volume2=cinder.volumes.create(name="cmcc4",size=10,volume_type=base.getid(type2),availability_zone="nova")

# def set_qos(cinder,""):
    def delete(self, backup):
        """Delete a volume backup.

        :param backup: The :class:`VolumeBackup` to delete.
        """
        return self._delete("/backups/%s" % base.getid(backup))
Beispiel #43
0
 def set_bootable(self, volume, flag):
     return self._action('os-set_bootable',
                         base.getid(volume),
                         {'bootable': flag})
Beispiel #44
0
    def force_delete(self, volume):
        """Delete the specified volume ignoring its current state.

        :param volume: The :class:`Volume` to force-delete.
        """
        return self._action('os-force_delete', base.getid(volume))
Beispiel #45
0
    def delete(self, group_snapshot):
        """Delete a group_snapshot.

        :param group_snapshot: The :class:`GroupSnapshot` to delete.
        """
        return self._delete("/group_snapshots/%s" % base.getid(group_snapshot))
Beispiel #46
0
    def test_getid(self):
        self.assertEqual(4, base.getid(4))

        class TmpObject(object):
            id = 4
        self.assertEqual(4, base.getid(TmpObject))
Beispiel #47
0
    def delete(self, volume_type):
        """Deletes a specific volume_type.

        :param volume_type: The name or ID of the :class:`VolumeType` to get.
        """
        return self._delete("/types/%s" % base.getid(volume_type))
 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)
     return self.api.client.post(url, body=body)
Beispiel #49
0
 def force_delete(self, volume):
     return self._action('os-force_delete', base.getid(volume))
Beispiel #50
0
    def delete(self, cgsnapshot):
        """Delete a cgsnapshot.

        :param cgsnapshot: The :class:`Cgsnapshot` to delete.
        """
        return self._delete("/cgsnapshots/%s" % base.getid(cgsnapshot))
Beispiel #51
0
    def delete(self, message):
        """Delete a message."""

        loc = "/messages/%s" % base.getid(message)

        return self._delete(loc)
Beispiel #52
0
 def update_readonly_flag(self, volume, flag):
     return self._action('os-update_readonly_flag',
                         base.getid(volume),
                         {'readonly': flag})
Beispiel #53
0
    def delete(self, transfer_id):
        """Delete a volume transfer.

        :param transfer_id: The :class:`VolumeTransfer` to delete.
        """
        self._delete("/os-volume-transfer/%s" % base.getid(transfer_id))
 def list(self, volume_type):
     return self._list(
         '/types/%s/os-volume-type-access' % base.getid(volume_type),
         'volume_type_access')
    def delete(self, snapshot):
        """Delete a snapshot.

        :param snapshot: The :class:`Snapshot` to delete.
        """
        self._delete("/snapshots/%s" % base.getid(snapshot))
Beispiel #56
0
 def delete(self, attachment):
     """Delete an attachment by ID."""
     return self._delete("/attachments/%s" % base.getid(attachment))
Beispiel #57
0
    def delete(self, volume):
        """Delete a volume.

        :param volume: The :class:`Volume` to delete.
        """
        self._delete("/volumes/%s" % base.getid(volume))
 def update_snapshot_status(self, snapshot, update_dict):
     return self._action('os-update_snapshot_status',
                         base.getid(snapshot), update_dict)
 def extend(self, volume, new_size):
     return self._action('os-extend', base.getid(volume),
                         {'new_size': new_size})