Merge "Implement ability to extend volume."
This commit is contained in:
commit
a7a48b8fee
cinderclient
@ -159,6 +159,10 @@ def _stub_transfer(id, base_uri, tenant_id):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _stub_extend(id, new_size):
|
||||||
|
return {'volume_id': '712f4980-5ac1-41e5-9383-390aa7c9f58b'}
|
||||||
|
|
||||||
|
|
||||||
class FakeClient(fakes.FakeClient, client.Client):
|
class FakeClient(fakes.FakeClient, client.Client):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -290,6 +294,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
assert body[action] is None
|
assert body[action] is None
|
||||||
elif action == 'os-reset_status':
|
elif action == 'os-reset_status':
|
||||||
assert 'status' in body[action]
|
assert 'status' in body[action]
|
||||||
|
elif action == 'os-extend':
|
||||||
|
assert body[action].keys() == ['new_size']
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Unexpected action: %s" % action)
|
raise AssertionError("Unexpected action: %s" % action)
|
||||||
return (resp, {}, _body)
|
return (resp, {}, _body)
|
||||||
|
@ -85,3 +85,8 @@ class VolumesTest(utils.TestCase):
|
|||||||
keys = ['key1']
|
keys = ['key1']
|
||||||
cs.volumes.delete_metadata(1234, keys)
|
cs.volumes.delete_metadata(1234, keys)
|
||||||
cs.assert_called('DELETE', '/volumes/1234/metadata/key1')
|
cs.assert_called('DELETE', '/volumes/1234/metadata/key1')
|
||||||
|
|
||||||
|
def test_extend(self):
|
||||||
|
v = cs.volumes.get('1234')
|
||||||
|
cs.volumes.extend(v, 2)
|
||||||
|
cs.assert_called('POST', '/volumes/1234/action')
|
||||||
|
@ -889,3 +889,15 @@ def do_transfer_show(cs, args):
|
|||||||
|
|
||||||
info.pop('links', None)
|
info.pop('links', None)
|
||||||
utils.print_dict(info)
|
utils.print_dict(info)
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('volume', metavar='<volume>', help='ID of the volume to extend.')
|
||||||
|
@utils.arg('new-size',
|
||||||
|
metavar='<new_size>',
|
||||||
|
type=int,
|
||||||
|
help='New size of volume in GB')
|
||||||
|
@utils.service_type('volume')
|
||||||
|
def do_extend(cs, args):
|
||||||
|
"""Attempt to extend the size of an existing volume."""
|
||||||
|
volume = _find_volume(cs, args.volume)
|
||||||
|
cs.volumes.extend_volume(volume, args.new_size)
|
||||||
|
@ -104,6 +104,14 @@ class Volume(base.Resource):
|
|||||||
"""Update the volume with the provided state."""
|
"""Update the volume with the provided state."""
|
||||||
self.manager.reset_state(self, state)
|
self.manager.reset_state(self, state)
|
||||||
|
|
||||||
|
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 desired size to extend volume to.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.manager.extend(self, volume, new_size)
|
||||||
|
|
||||||
|
|
||||||
class VolumeManager(base.ManagerWithFind):
|
class VolumeManager(base.ManagerWithFind):
|
||||||
"""Manage :class:`Volume` resources."""
|
"""Manage :class:`Volume` resources."""
|
||||||
@ -321,3 +329,8 @@ class VolumeManager(base.ManagerWithFind):
|
|||||||
def reset_state(self, volume, state):
|
def reset_state(self, volume, state):
|
||||||
"""Update the provided volume with the provided state."""
|
"""Update the provided volume with the provided state."""
|
||||||
return self._action('os-reset_status', volume, {'status': state})
|
return self._action('os-reset_status', volume, {'status': state})
|
||||||
|
|
||||||
|
def extend(self, volume, new_size):
|
||||||
|
return self._action('os-extend',
|
||||||
|
base.getid(volume),
|
||||||
|
{'new_size': new_size})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user