Merge "Add REIMAGE_VOLUME message action"
This commit is contained in:
commit
eb98b2874b
@ -235,5 +235,5 @@ class API(base.Base):
|
|||||||
context,
|
context,
|
||||||
message_field.Action.REIMAGE_VOLUME,
|
message_field.Action.REIMAGE_VOLUME,
|
||||||
resource_uuid=volume_id,
|
resource_uuid=volume_id,
|
||||||
detail=message_field.Detail.NOTIFY_COMPUTE_SERVICE_FAILED)
|
detail=message_field.Detail.REIMAGE_VOLUME_FAILED)
|
||||||
return result
|
return result
|
||||||
|
@ -49,6 +49,7 @@ class Action(object):
|
|||||||
BACKUP_CREATE = ('013', _('create backup'))
|
BACKUP_CREATE = ('013', _('create backup'))
|
||||||
BACKUP_DELETE = ('014', _('delete backup'))
|
BACKUP_DELETE = ('014', _('delete backup'))
|
||||||
BACKUP_RESTORE = ('015', _('restore backup'))
|
BACKUP_RESTORE = ('015', _('restore backup'))
|
||||||
|
REIMAGE_VOLUME = ('016', _('reimage volume'))
|
||||||
|
|
||||||
ALL = (SCHEDULE_ALLOCATE_VOLUME,
|
ALL = (SCHEDULE_ALLOCATE_VOLUME,
|
||||||
ATTACH_VOLUME,
|
ATTACH_VOLUME,
|
||||||
@ -65,6 +66,7 @@ class Action(object):
|
|||||||
BACKUP_CREATE,
|
BACKUP_CREATE,
|
||||||
BACKUP_DELETE,
|
BACKUP_DELETE,
|
||||||
BACKUP_RESTORE,
|
BACKUP_RESTORE,
|
||||||
|
REIMAGE_VOLUME,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -125,6 +127,9 @@ class Detail(object):
|
|||||||
BACKUP_RESTORE_ERROR = (
|
BACKUP_RESTORE_ERROR = (
|
||||||
'026', _("Backup driver failed to restore backup."))
|
'026', _("Backup driver failed to restore backup."))
|
||||||
VOLUME_INVALID_STATE = ('027', _("Volume status is invalid."))
|
VOLUME_INVALID_STATE = ('027', _("Volume status is invalid."))
|
||||||
|
REIMAGE_VOLUME_FAILED = (
|
||||||
|
'028',
|
||||||
|
_("Compute service failed to reimage volume."))
|
||||||
|
|
||||||
ALL = (UNKNOWN_ERROR,
|
ALL = (UNKNOWN_ERROR,
|
||||||
DRIVER_NOT_INITIALIZED,
|
DRIVER_NOT_INITIALIZED,
|
||||||
@ -153,6 +158,7 @@ class Detail(object):
|
|||||||
BACKUP_DELETE_DRIVER_ERROR,
|
BACKUP_DELETE_DRIVER_ERROR,
|
||||||
BACKUP_RESTORE_ERROR,
|
BACKUP_RESTORE_ERROR,
|
||||||
VOLUME_INVALID_STATE,
|
VOLUME_INVALID_STATE,
|
||||||
|
REIMAGE_VOLUME_FAILED,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Exception and detail mappings
|
# Exception and detail mappings
|
||||||
|
@ -281,3 +281,59 @@ class NovaApiTestCase(test.TestCase):
|
|||||||
'server_uuid': 'server-id-2',
|
'server_uuid': 'server-id-2',
|
||||||
'tag': 'volume_id'},
|
'tag': 'volume_id'},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_reimage_volume(self):
|
||||||
|
server_ids = ['server-id-1', 'server-id-2']
|
||||||
|
with mock.patch.object(nova, 'novaclient') as mock_novaclient, \
|
||||||
|
mock.patch.object(self.novaclient.server_external_events,
|
||||||
|
'create') as mock_create_event:
|
||||||
|
mock_novaclient.return_value = self.novaclient
|
||||||
|
mock_create_event.return_value = []
|
||||||
|
|
||||||
|
result = self.api.reimage_volume(self.ctx, server_ids, 'volume_id')
|
||||||
|
self.assertTrue(result)
|
||||||
|
|
||||||
|
mock_novaclient.assert_called_once_with(self.ctx,
|
||||||
|
privileged_user=True,
|
||||||
|
api_version='2.91')
|
||||||
|
mock_create_event.assert_called_once_with([
|
||||||
|
{'name': 'volume-reimaged',
|
||||||
|
'server_uuid': 'server-id-1',
|
||||||
|
'tag': 'volume_id'},
|
||||||
|
{'name': 'volume-reimaged',
|
||||||
|
'server_uuid': 'server-id-2',
|
||||||
|
'tag': 'volume_id'},
|
||||||
|
])
|
||||||
|
|
||||||
|
@ddt.data(nova_exceptions.NotFound,
|
||||||
|
Exception,
|
||||||
|
'illegal_list',
|
||||||
|
[{'code': None}])
|
||||||
|
@mock.patch('cinder.message.api.API.create')
|
||||||
|
def test_reimage_volume_failed(self, nova_result, mock_create):
|
||||||
|
server_ids = ['server-id-1', 'server-id-2']
|
||||||
|
with mock.patch.object(nova, 'novaclient') as mock_novaclient, \
|
||||||
|
mock.patch.object(self.novaclient.server_external_events,
|
||||||
|
'create') as mock_create_event:
|
||||||
|
mock_novaclient.return_value = self.novaclient
|
||||||
|
mock_create_event.side_effect = [nova_result]
|
||||||
|
|
||||||
|
result = self.api.reimage_volume(self.ctx, server_ids, 'volume_id')
|
||||||
|
self.assertFalse(result)
|
||||||
|
|
||||||
|
mock_novaclient.assert_called_once_with(self.ctx,
|
||||||
|
privileged_user=True,
|
||||||
|
api_version='2.91')
|
||||||
|
mock_create.assert_called_once_with(
|
||||||
|
self.ctx,
|
||||||
|
message_field.Action.REIMAGE_VOLUME,
|
||||||
|
resource_uuid='volume_id',
|
||||||
|
detail=message_field.Detail.REIMAGE_VOLUME_FAILED)
|
||||||
|
mock_create_event.assert_called_once_with([
|
||||||
|
{'name': 'volume-reimaged',
|
||||||
|
'server_uuid': 'server-id-1',
|
||||||
|
'tag': 'volume_id'},
|
||||||
|
{'name': 'volume-reimaged',
|
||||||
|
'server_uuid': 'server-id-2',
|
||||||
|
'tag': 'volume_id'},
|
||||||
|
])
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
`Bug #1968170 <https://bugs.launchpad.net/cinder/+bug/1968170>`_: Fixed
|
||||||
|
the message created when nova fails to reimage the volume.
|
Loading…
Reference in New Issue
Block a user