Use REST API for volume delete and detach calls
Change-Id: I0267899b4fb1dbb277ef969663ff82eadf465879 Signed-off-by: Rosario Di Somma <rosario.disomma@dreamhost.com>
This commit is contained in:
parent
be92751781
commit
bcc7ea694a
|
@ -212,16 +212,6 @@ class NovaImageList(task_manager.Task):
|
|||
return client.nova_client.images.list()
|
||||
|
||||
|
||||
class VolumeDelete(task_manager.Task):
|
||||
def main(self, client):
|
||||
client.cinder_client.volumes.delete(**self.args)
|
||||
|
||||
|
||||
class VolumeDetach(task_manager.Task):
|
||||
def main(self, client):
|
||||
client.nova_client.volumes.delete_server_volume(**self.args)
|
||||
|
||||
|
||||
class VolumeAttach(task_manager.Task):
|
||||
def main(self, client):
|
||||
return client.nova_client.volumes.create_server_volume(**self.args)
|
||||
|
|
|
@ -3923,9 +3923,9 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||
|
||||
with _utils.shade_exceptions("Error in deleting volume"):
|
||||
try:
|
||||
self.manager.submit_task(
|
||||
_tasks.VolumeDelete(volume=volume['id']))
|
||||
except cinder_exceptions.NotFound:
|
||||
self._volume_client.delete(
|
||||
'volumes/{id}'.format(id=volume['id']))
|
||||
except OpenStackCloudURINotFound:
|
||||
self.log.debug(
|
||||
"Volume {id} not found when deleting. Ignoring.".format(
|
||||
id=volume['id']))
|
||||
|
@ -3987,12 +3987,13 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||
:raises: OpenStackCloudException on operation error.
|
||||
"""
|
||||
|
||||
with _utils.shade_exceptions(
|
||||
"Error detaching volume {volume} from server {server}".format(
|
||||
volume=volume['id'], server=server['id'])):
|
||||
self.manager.submit_task(
|
||||
_tasks.VolumeDetach(attachment_id=volume['id'],
|
||||
server_id=server['id']))
|
||||
with _utils.shade_exceptions():
|
||||
self._compute_client.delete(
|
||||
'servers/{server_id}/os-volume_attachments/{volume_id}'.format(
|
||||
server_id=server['id'], volume_id=volume['id']),
|
||||
error_message="Error detaching volume {volume} "
|
||||
"from server {server}".format(
|
||||
volume=volume['id'], server=server['id']))
|
||||
|
||||
if wait:
|
||||
for count in _utils._iterate_timeout(
|
||||
|
|
|
@ -189,7 +189,7 @@ class TestVolume(base.RequestsMockTestCase):
|
|||
'os-volume_attachments', volume['id']]),
|
||||
status_code=404)])
|
||||
with testtools.ExpectedException(
|
||||
shade.OpenStackCloudException,
|
||||
shade.OpenStackCloudURINotFound,
|
||||
"Error detaching volume %s from server %s" % (
|
||||
volume['id'], server['id'])
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue