deleted volume v1
This commit is contained in:
parent
77dffa2c99
commit
e69f2bea62
@ -1,76 +0,0 @@
|
||||
# Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Volume Backups interface (1.1 extension).
|
||||
"""
|
||||
|
||||
from manilaclient import base
|
||||
|
||||
|
||||
class VolumeBackup(base.Resource):
|
||||
"""A volume backup is a block level backup of a volume."""
|
||||
def __repr__(self):
|
||||
return "<VolumeBackup: %s>" % self.id
|
||||
|
||||
def delete(self):
|
||||
"""Delete this volume backup."""
|
||||
return self.manager.delete(self)
|
||||
|
||||
|
||||
class VolumeBackupManager(base.ManagerWithFind):
|
||||
"""Manage :class:`VolumeBackup` resources."""
|
||||
resource_class = VolumeBackup
|
||||
|
||||
def create(self, volume_id, container=None,
|
||||
name=None, description=None):
|
||||
"""Create a volume backup.
|
||||
|
||||
:param volume_id: The ID of the volume to backup.
|
||||
:param container: The name of the backup service container.
|
||||
:param name: The name of the backup.
|
||||
:param description: The description of the backup.
|
||||
:rtype: :class:`VolumeBackup`
|
||||
"""
|
||||
body = {'backup': {'volume_id': volume_id,
|
||||
'container': container,
|
||||
'name': name,
|
||||
'description': description}}
|
||||
return self._create('/backups', body, 'backup')
|
||||
|
||||
def get(self, backup_id):
|
||||
"""Show details of a volume backup.
|
||||
|
||||
:param backup_id: The ID of the backup to display.
|
||||
:rtype: :class:`VolumeBackup`
|
||||
"""
|
||||
return self._get("/backups/%s" % backup_id, "backup")
|
||||
|
||||
def list(self, detailed=True):
|
||||
"""Get a list of all volume backups.
|
||||
|
||||
:rtype: list of :class:`VolumeBackup`
|
||||
"""
|
||||
if detailed is True:
|
||||
return self._list("/backups/detail", "backups")
|
||||
else:
|
||||
return self._list("/backups", "backups")
|
||||
|
||||
def delete(self, backup):
|
||||
"""Delete a volume backup.
|
||||
|
||||
:param backup: The :class:`VolumeBackup` to delete.
|
||||
"""
|
||||
self._delete("/backups/%s" % base.getid(backup))
|
@ -1,43 +0,0 @@
|
||||
# Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""Volume Backups Restore interface (1.1 extension).
|
||||
|
||||
This is part of the Volume Backups interface.
|
||||
"""
|
||||
|
||||
from manilaclient import base
|
||||
|
||||
|
||||
class VolumeBackupsRestore(base.Resource):
|
||||
"""A Volume Backups Restore represents a restore operation."""
|
||||
def __repr__(self):
|
||||
return "<VolumeBackupsRestore: %s>" % self.id
|
||||
|
||||
|
||||
class VolumeBackupRestoreManager(base.ManagerWithFind):
|
||||
"""Manage :class:`VolumeBackupsRestore` resources."""
|
||||
resource_class = VolumeBackupsRestore
|
||||
|
||||
def restore(self, backup_id, volume_id=None):
|
||||
"""Restore a backup to a volume.
|
||||
|
||||
:param backup_id: The ID of the backup to restore.
|
||||
:param volume_id: The ID of the volume to restore the backup to.
|
||||
:rtype: :class:`Restore`
|
||||
"""
|
||||
body = {'restore': {'volume_id': volume_id}}
|
||||
return self._create("/backups/%s/restore" % backup_id,
|
||||
body, "restore")
|
@ -1,130 +0,0 @@
|
||||
# Copyright 2011 Denali Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Volume snapshot interface (1.1 extension).
|
||||
"""
|
||||
|
||||
import urllib
|
||||
from manilaclient import base
|
||||
|
||||
|
||||
class Snapshot(base.Resource):
|
||||
"""
|
||||
A Snapshot is a point-in-time snapshot of an openstack volume.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "<Snapshot: %s>" % self.id
|
||||
|
||||
def delete(self):
|
||||
"""
|
||||
Delete this snapshot.
|
||||
"""
|
||||
self.manager.delete(self)
|
||||
|
||||
def update(self, **kwargs):
|
||||
"""
|
||||
Update the display_name or display_description for this snapshot.
|
||||
"""
|
||||
self.manager.update(self, **kwargs)
|
||||
|
||||
@property
|
||||
def progress(self):
|
||||
return self._info.get('os-extended-snapshot-attributes:progress')
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
return self._info.get('os-extended-snapshot-attributes:project_id')
|
||||
|
||||
|
||||
class SnapshotManager(base.ManagerWithFind):
|
||||
"""
|
||||
Manage :class:`Snapshot` resources.
|
||||
"""
|
||||
resource_class = Snapshot
|
||||
|
||||
def create(self, volume_id, force=False,
|
||||
display_name=None, display_description=None):
|
||||
|
||||
"""
|
||||
Create a snapshot of the given volume.
|
||||
|
||||
:param volume_id: The ID of the volume to snapshot.
|
||||
:param force: If force is True, create a snapshot even if the volume is
|
||||
attached to an instance. Default is False.
|
||||
:param display_name: Name of the snapshot
|
||||
:param display_description: Description of the snapshot
|
||||
:rtype: :class:`Snapshot`
|
||||
"""
|
||||
body = {'snapshot': {'volume_id': volume_id,
|
||||
'force': force,
|
||||
'display_name': display_name,
|
||||
'display_description': display_description}}
|
||||
return self._create('/snapshots', body, 'snapshot')
|
||||
|
||||
def get(self, snapshot_id):
|
||||
"""
|
||||
Get a snapshot.
|
||||
|
||||
:param snapshot_id: The ID of the snapshot to get.
|
||||
:rtype: :class:`Snapshot`
|
||||
"""
|
||||
return self._get("/snapshots/%s" % snapshot_id, "snapshot")
|
||||
|
||||
def list(self, detailed=True, search_opts=None):
|
||||
"""
|
||||
Get a list of all snapshots.
|
||||
|
||||
:rtype: list of :class:`Snapshot`
|
||||
"""
|
||||
|
||||
if search_opts is None:
|
||||
search_opts = {}
|
||||
|
||||
qparams = {}
|
||||
|
||||
for opt, val in search_opts.iteritems():
|
||||
if val:
|
||||
qparams[opt] = val
|
||||
|
||||
query_string = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
||||
|
||||
detail = ""
|
||||
if detailed:
|
||||
detail = "/detail"
|
||||
|
||||
return self._list("/snapshots%s%s" % (detail, query_string),
|
||||
"snapshots")
|
||||
|
||||
def delete(self, snapshot):
|
||||
"""
|
||||
Delete a snapshot.
|
||||
|
||||
:param snapshot: The :class:`Snapshot` to delete.
|
||||
"""
|
||||
self._delete("/snapshots/%s" % base.getid(snapshot))
|
||||
|
||||
def update(self, snapshot, **kwargs):
|
||||
"""
|
||||
Update the display_name or display_description for a snapshot.
|
||||
|
||||
:param snapshot: The :class:`Snapshot` to delete.
|
||||
"""
|
||||
if not kwargs:
|
||||
return
|
||||
|
||||
body = {"snapshot": kwargs}
|
||||
|
||||
self._update("/snapshots/%s" % base.getid(snapshot), body)
|
@ -1,122 +0,0 @@
|
||||
# Copyright (c) 2011 Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
"""
|
||||
Volume Type interface.
|
||||
"""
|
||||
|
||||
from manilaclient import base
|
||||
|
||||
|
||||
class VolumeType(base.Resource):
|
||||
"""
|
||||
A Volume Type is the type of volume to be created
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "<VolumeType: %s>" % self.name
|
||||
|
||||
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 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 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
|
||||
resp = None
|
||||
for k in keys:
|
||||
resp = self.manager._delete(
|
||||
"/types/%s/extra_specs/%s" % (
|
||||
base.getid(self), k))
|
||||
if resp is not None:
|
||||
return resp
|
||||
|
||||
|
||||
class VolumeTypeManager(base.ManagerWithFind):
|
||||
"""
|
||||
Manage :class:`VolumeType` resources.
|
||||
"""
|
||||
resource_class = VolumeType
|
||||
|
||||
def list(self):
|
||||
"""
|
||||
Get a list of all volume types.
|
||||
|
||||
:rtype: list of :class:`VolumeType`.
|
||||
"""
|
||||
return self._list("/types", "volume_types")
|
||||
|
||||
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 create(self, name):
|
||||
"""
|
||||
Create a volume type.
|
||||
|
||||
:param name: Descriptive name of the volume type
|
||||
:rtype: :class:`VolumeType`
|
||||
"""
|
||||
|
||||
body = {
|
||||
"volume_type": {
|
||||
"name": name,
|
||||
}
|
||||
}
|
||||
|
||||
return self._create("/types", body, "volume_type")
|
@ -1,328 +0,0 @@
|
||||
# Copyright 2011 Denali Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Volume interface (1.1 extension).
|
||||
"""
|
||||
|
||||
import urllib
|
||||
from manilaclient import base
|
||||
|
||||
|
||||
class Volume(base.Resource):
|
||||
"""A volume is an extra block level storage to the OpenStack instances."""
|
||||
def __repr__(self):
|
||||
return "<Volume: %s>" % self.id
|
||||
|
||||
def delete(self):
|
||||
"""Delete this volume."""
|
||||
self.manager.delete(self)
|
||||
|
||||
def update(self, **kwargs):
|
||||
"""Update the display_name or display_description for this volume."""
|
||||
self.manager.update(self, **kwargs)
|
||||
|
||||
def attach(self, instance_uuid, mountpoint):
|
||||
"""Set attachment metadata.
|
||||
|
||||
:param instance_uuid: uuid of the attaching instance.
|
||||
:param mountpoint: mountpoint on the attaching instance.
|
||||
"""
|
||||
return self.manager.attach(self, instance_uuid, mountpoint)
|
||||
|
||||
def detach(self):
|
||||
"""Clear attachment metadata."""
|
||||
return self.manager.detach(self)
|
||||
|
||||
def reserve(self, volume):
|
||||
"""Reserve this volume."""
|
||||
return self.manager.reserve(self)
|
||||
|
||||
def unreserve(self, volume):
|
||||
"""Unreserve this volume."""
|
||||
return self.manager.unreserve(self)
|
||||
|
||||
def begin_detaching(self, volume):
|
||||
"""Begin detaching volume."""
|
||||
return self.manager.begin_detaching(self)
|
||||
|
||||
def roll_detaching(self, volume):
|
||||
"""Roll detaching volume."""
|
||||
return self.manager.roll_detaching(self)
|
||||
|
||||
def initialize_connection(self, volume, connector):
|
||||
"""Initialize a volume connection.
|
||||
|
||||
:param connector: connector dict from nova.
|
||||
"""
|
||||
return self.manager.initialize_connection(self, connector)
|
||||
|
||||
def terminate_connection(self, volume, connector):
|
||||
"""Terminate a volume connection.
|
||||
|
||||
:param connector: connector dict from nova.
|
||||
"""
|
||||
return self.manager.terminate_connection(self, connector)
|
||||
|
||||
def set_metadata(self, volume, metadata):
|
||||
"""Set or Append metadata to a volume.
|
||||
|
||||
:param type : The :class: `Volume` to set metadata on
|
||||
:param metadata: A dict of key/value pairs to set
|
||||
"""
|
||||
return self.manager.set_metadata(self, metadata)
|
||||
|
||||
def upload_to_image(self, force, image_name, container_format,
|
||||
disk_format):
|
||||
"""Upload a volume to image service as an image."""
|
||||
self.manager.upload_to_image(self, force, image_name, container_format,
|
||||
disk_format)
|
||||
|
||||
def force_delete(self):
|
||||
"""Delete the specified volume ignoring its current state.
|
||||
|
||||
:param volume: The UUID of the volume to force-delete.
|
||||
"""
|
||||
self.manager.force_delete(self)
|
||||
|
||||
|
||||
class VolumeManager(base.ManagerWithFind):
|
||||
"""
|
||||
Manage :class:`Volume` resources.
|
||||
"""
|
||||
resource_class = Volume
|
||||
|
||||
def create(self, size, snapshot_id=None, source_volid=None,
|
||||
display_name=None, display_description=None,
|
||||
volume_type=None, user_id=None,
|
||||
project_id=None, availability_zone=None,
|
||||
metadata=None, imageRef=None):
|
||||
"""
|
||||
Create a volume.
|
||||
|
||||
:param size: Size of volume in GB
|
||||
:param snapshot_id: ID of the snapshot
|
||||
:param display_name: Name of the volume
|
||||
:param display_description: Description of the volume
|
||||
:param volume_type: Type of volume
|
||||
:rtype: :class:`Volume`
|
||||
:param user_id: User id derived from context
|
||||
:param project_id: Project id derived from context
|
||||
:param availability_zone: Availability Zone to use
|
||||
:param metadata: Optional metadata to set on volume creation
|
||||
:param imageRef: reference to an image stored in glance
|
||||
:param source_volid: ID of source volume to clone from
|
||||
"""
|
||||
|
||||
if metadata is None:
|
||||
volume_metadata = {}
|
||||
else:
|
||||
volume_metadata = metadata
|
||||
|
||||
body = {'volume': {'size': size,
|
||||
'snapshot_id': snapshot_id,
|
||||
'display_name': display_name,
|
||||
'display_description': display_description,
|
||||
'volume_type': volume_type,
|
||||
'user_id': user_id,
|
||||
'project_id': project_id,
|
||||
'availability_zone': availability_zone,
|
||||
'status': "creating",
|
||||
'attach_status': "detached",
|
||||
'metadata': volume_metadata,
|
||||
'imageRef': imageRef,
|
||||
'source_volid': source_volid,
|
||||
}}
|
||||
return self._create('/volumes', body, 'volume')
|
||||
|
||||
def get(self, volume_id):
|
||||
"""
|
||||
Get a volume.
|
||||
|
||||
:param volume_id: The ID of the volume to delete.
|
||||
:rtype: :class:`Volume`
|
||||
"""
|
||||
return self._get("/volumes/%s" % volume_id, "volume")
|
||||
|
||||
def list(self, detailed=True, search_opts=None):
|
||||
"""
|
||||
Get a list of all volumes.
|
||||
|
||||
:rtype: list of :class:`Volume`
|
||||
"""
|
||||
if search_opts is None:
|
||||
search_opts = {}
|
||||
|
||||
qparams = {}
|
||||
|
||||
for opt, val in search_opts.iteritems():
|
||||
if val:
|
||||
qparams[opt] = val
|
||||
|
||||
query_string = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
||||
|
||||
detail = ""
|
||||
if detailed:
|
||||
detail = "/detail"
|
||||
|
||||
return self._list("/volumes%s%s" % (detail, query_string),
|
||||
"volumes")
|
||||
|
||||
def delete(self, volume):
|
||||
"""
|
||||
Delete a volume.
|
||||
|
||||
:param volume: The :class:`Volume` to delete.
|
||||
"""
|
||||
self._delete("/volumes/%s" % base.getid(volume))
|
||||
|
||||
def update(self, volume, **kwargs):
|
||||
"""
|
||||
Update the display_name or display_description for a volume.
|
||||
|
||||
:param volume: The :class:`Volume` to delete.
|
||||
"""
|
||||
if not kwargs:
|
||||
return
|
||||
|
||||
body = {"volume": kwargs}
|
||||
|
||||
self._update("/volumes/%s" % base.getid(volume), 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 attach(self, volume, instance_uuid, mountpoint):
|
||||
"""
|
||||
Set attachment metadata.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID)
|
||||
you would like to attach.
|
||||
:param instance_uuid: uuid of the attaching instance.
|
||||
:param mountpoint: mountpoint on the attaching instance.
|
||||
"""
|
||||
return self._action('os-attach',
|
||||
volume,
|
||||
{'instance_uuid': instance_uuid,
|
||||
'mountpoint': mountpoint})
|
||||
|
||||
def detach(self, volume):
|
||||
"""
|
||||
Clear attachment metadata.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID)
|
||||
you would like to detach.
|
||||
"""
|
||||
return self._action('os-detach', volume)
|
||||
|
||||
def reserve(self, volume):
|
||||
"""
|
||||
Reserve this volume.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID)
|
||||
you would like to reserve.
|
||||
"""
|
||||
return self._action('os-reserve', volume)
|
||||
|
||||
def unreserve(self, volume):
|
||||
"""
|
||||
Unreserve this volume.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID)
|
||||
you would like to unreserve.
|
||||
"""
|
||||
return self._action('os-unreserve', volume)
|
||||
|
||||
def begin_detaching(self, volume):
|
||||
"""
|
||||
Begin detaching this volume.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID)
|
||||
you would like to detach.
|
||||
"""
|
||||
return self._action('os-begin_detaching', volume)
|
||||
|
||||
def roll_detaching(self, volume):
|
||||
"""
|
||||
Roll detaching this volume.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID)
|
||||
you would like to roll detaching.
|
||||
"""
|
||||
return self._action('os-roll_detaching', volume)
|
||||
|
||||
def initialize_connection(self, volume, connector):
|
||||
"""
|
||||
Initialize a volume connection.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID).
|
||||
:param connector: connector dict from nova.
|
||||
"""
|
||||
return self._action('os-initialize_connection', volume,
|
||||
{'connector': connector})[1]['connection_info']
|
||||
|
||||
def terminate_connection(self, volume, connector):
|
||||
"""
|
||||
Terminate a volume connection.
|
||||
|
||||
:param volume: The :class:`Volume` (or its ID).
|
||||
:param connector: connector dict from nova.
|
||||
"""
|
||||
self._action('os-terminate_connection', volume,
|
||||
{'connector': connector})
|
||||
|
||||
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")
|
||||
|
||||
def delete_metadata(self, volume, keys):
|
||||
"""
|
||||
Delete specified keys from volumes metadata.
|
||||
|
||||
:param volume: The :class:`Volume`.
|
||||
:param metadata: A list of keys to be removed.
|
||||
"""
|
||||
for k in keys:
|
||||
self._delete("/volumes/%s/metadata/%s" % (base.getid(volume), k))
|
||||
|
||||
def upload_to_image(self, volume, force, image_name, container_format,
|
||||
disk_format):
|
||||
"""
|
||||
Upload volume to image service as image.
|
||||
|
||||
:param volume: The :class:`Volume` to upload.
|
||||
"""
|
||||
return self._action('os-volume_upload_image',
|
||||
volume,
|
||||
{'force': force,
|
||||
'image_name': image_name,
|
||||
'container_format': container_format,
|
||||
'disk_format': disk_format})
|
||||
|
||||
def force_delete(self, volume):
|
||||
return self._action('os-force_delete', base.getid(volume))
|
Loading…
Reference in New Issue
Block a user