Implement reset-state (os-reset_status) action
This change implements a reset-state method in the cinderclient which exposes the extension: os-reset_status from the Cinder API. Fix bug 1190731 Change-Id: I8f631f0f19ca16e0fdd1e3adcf923cc684292887
This commit is contained in:
parent
046ea37f93
commit
7571232c02
@ -234,8 +234,10 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
assert body[action] is None
|
assert body[action] is None
|
||||||
elif action == 'os-roll_detaching':
|
elif action == 'os-roll_detaching':
|
||||||
assert body[action] is None
|
assert body[action] is None
|
||||||
|
elif action == 'os-reset_status':
|
||||||
|
assert 'status' in body[action]
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected server action: %s" % action)
|
raise AssertionError("Unexpected action: %s" % action)
|
||||||
return (resp, {}, _body)
|
return (resp, {}, _body)
|
||||||
|
|
||||||
def post_volumes(self, **kw):
|
def post_volumes(self, **kw):
|
||||||
|
@ -179,3 +179,13 @@ class ShellTest(utils.TestCase):
|
|||||||
self.run_command('metadata 1234 unset key1 key2')
|
self.run_command('metadata 1234 unset key1 key2')
|
||||||
self.assert_called('DELETE', '/volumes/1234/metadata/key1')
|
self.assert_called('DELETE', '/volumes/1234/metadata/key1')
|
||||||
self.assert_called('DELETE', '/volumes/1234/metadata/key2', pos=-2)
|
self.assert_called('DELETE', '/volumes/1234/metadata/key2', pos=-2)
|
||||||
|
|
||||||
|
def test_reset_state(self):
|
||||||
|
self.run_command('reset-state 1234')
|
||||||
|
expected = {'os-reset_status': {'status': 'available'}}
|
||||||
|
self.assert_called('POST', '/volumes/1234/action', body=expected)
|
||||||
|
|
||||||
|
def test_reset_state_with_flag(self):
|
||||||
|
self.run_command('reset-state --state error 1234')
|
||||||
|
expected = {'os-reset_status': {'status': 'error'}}
|
||||||
|
self.assert_called('POST', '/volumes/1234/action', body=expected)
|
||||||
|
@ -241,8 +241,10 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
assert body[action] is None
|
assert body[action] is None
|
||||||
elif action == 'os-roll_detaching':
|
elif action == 'os-roll_detaching':
|
||||||
assert body[action] is None
|
assert body[action] is None
|
||||||
|
elif action == 'os-reset_status':
|
||||||
|
assert 'status' in body[action]
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected server action: %s" % action)
|
raise AssertionError("Unexpected action: %s" % action)
|
||||||
return (resp, {}, _body)
|
return (resp, {}, _body)
|
||||||
|
|
||||||
def post_volumes(self, **kw):
|
def post_volumes(self, **kw):
|
||||||
|
@ -157,3 +157,13 @@ class ShellTest(utils.TestCase):
|
|||||||
self.run_command('metadata 1234 unset key1 key2')
|
self.run_command('metadata 1234 unset key1 key2')
|
||||||
self.assert_called('DELETE', '/volumes/1234/metadata/key1')
|
self.assert_called('DELETE', '/volumes/1234/metadata/key1')
|
||||||
self.assert_called('DELETE', '/volumes/1234/metadata/key2', pos=-2)
|
self.assert_called('DELETE', '/volumes/1234/metadata/key2', pos=-2)
|
||||||
|
|
||||||
|
def test_reset_state(self):
|
||||||
|
self.run_command('reset-state 1234')
|
||||||
|
expected = {'os-reset_status': {'status': 'available'}}
|
||||||
|
self.assert_called('POST', '/volumes/1234/action', body=expected)
|
||||||
|
|
||||||
|
def test_reset_state_with_flag(self):
|
||||||
|
self.run_command('reset-state --state error 1234')
|
||||||
|
expected = {'os-reset_status': {'status': 'error'}}
|
||||||
|
self.assert_called('POST', '/volumes/1234/action', body=expected)
|
||||||
|
@ -268,6 +268,18 @@ def do_force_delete(cs, args):
|
|||||||
volume.force_delete()
|
volume.force_delete()
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to modify.')
|
||||||
|
@utils.arg('--state', metavar='<state>', default='available',
|
||||||
|
help=('Indicate which state to assign the volume. Options include '
|
||||||
|
'available, error, creating, deleting, error_deleting. If no '
|
||||||
|
'state is provided, available will be used.'))
|
||||||
|
@utils.service_type('volume')
|
||||||
|
def do_reset_state(cs, args):
|
||||||
|
"""Explicitly update the state of a volume."""
|
||||||
|
volume = _find_volume(cs, args.volume)
|
||||||
|
volume.reset_state(args.state)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume', metavar='<volume>', help='ID of the volume to rename.')
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to rename.')
|
||||||
@utils.arg('display_name', nargs='?', metavar='<display-name>',
|
@utils.arg('display_name', nargs='?', metavar='<display-name>',
|
||||||
help='New display-name for the volume.')
|
help='New display-name for the volume.')
|
||||||
|
@ -98,6 +98,10 @@ class Volume(base.Resource):
|
|||||||
"""
|
"""
|
||||||
self.manager.force_delete(self)
|
self.manager.force_delete(self)
|
||||||
|
|
||||||
|
def reset_state(self, state):
|
||||||
|
"""Update the volume with the provided state."""
|
||||||
|
self.manager.reset_state(self, state)
|
||||||
|
|
||||||
|
|
||||||
class VolumeManager(base.ManagerWithFind):
|
class VolumeManager(base.ManagerWithFind):
|
||||||
"""
|
"""
|
||||||
@ -327,3 +331,7 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
def force_delete(self, volume):
|
def force_delete(self, volume):
|
||||||
return self._action('os-force_delete', base.getid(volume))
|
return self._action('os-force_delete', base.getid(volume))
|
||||||
|
|
||||||
|
def reset_state(self, volume, state):
|
||||||
|
"""Update the provided volume with the provided state."""
|
||||||
|
return self._action('os-reset_status', volume, {'status': state})
|
||||||
|
@ -278,6 +278,18 @@ def do_force_delete(cs, args):
|
|||||||
volume.force_delete()
|
volume.force_delete()
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to modify.')
|
||||||
|
@utils.arg('--state', metavar='<state>', default='available',
|
||||||
|
help=('Indicate which state to assign the volume. Options include '
|
||||||
|
'available, error, creating, deleting, error_deleting. If no '
|
||||||
|
'state is provided, available will be used.'))
|
||||||
|
@utils.service_type('volume')
|
||||||
|
def do_reset_state(cs, args):
|
||||||
|
"""Explicitly update the state of a volume."""
|
||||||
|
volume = _find_volume(cs, args.volume)
|
||||||
|
volume.reset_state(args.state)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('volume',
|
@utils.arg('volume',
|
||||||
metavar='<volume>',
|
metavar='<volume>',
|
||||||
help='ID of the volume to rename.')
|
help='ID of the volume to rename.')
|
||||||
|
@ -97,6 +97,10 @@ class Volume(base.Resource):
|
|||||||
"""
|
"""
|
||||||
self.manager.force_delete(self)
|
self.manager.force_delete(self)
|
||||||
|
|
||||||
|
def reset_state(self, state):
|
||||||
|
"""Update the volume with the provided state."""
|
||||||
|
self.manager.reset_state(self, state)
|
||||||
|
|
||||||
|
|
||||||
class VolumeManager(base.ManagerWithFind):
|
class VolumeManager(base.ManagerWithFind):
|
||||||
"""Manage :class:`Volume` resources."""
|
"""Manage :class:`Volume` resources."""
|
||||||
@ -307,3 +311,7 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
def force_delete(self, volume):
|
def force_delete(self, volume):
|
||||||
return self._action('os-force_delete', base.getid(volume))
|
return self._action('os-force_delete', base.getid(volume))
|
||||||
|
|
||||||
|
def reset_state(self, volume, state):
|
||||||
|
"""Update the provided volume with the provided state."""
|
||||||
|
return self._action('os-reset_status', volume, {'status': state})
|
||||||
|
Loading…
Reference in New Issue
Block a user