Merge "Adding retype_volume to BlockStorageCloudMixin"
This commit is contained in:
@@ -119,5 +119,15 @@ class Volume(resource.Resource):
|
||||
body = {'os-update_readonly_flag': {'readonly': readonly}}
|
||||
self._action(session, body)
|
||||
|
||||
def retype(self, session, new_type, migration_policy):
|
||||
"""Retype volume considering the migration policy"""
|
||||
body = {
|
||||
'os-retype': {
|
||||
'new_type': new_type,
|
||||
'migration_policy': migration_policy
|
||||
}
|
||||
}
|
||||
self._action(session, body)
|
||||
|
||||
|
||||
VolumeDetail = Volume
|
||||
|
||||
@@ -173,6 +173,18 @@ class TestVolumeProxy(test_proxy_base.TestProxyBase):
|
||||
method_args=["value", False],
|
||||
expected_args=[False])
|
||||
|
||||
def test_volume_retype_without_migration_policy(self):
|
||||
self._verify("openstack.block_storage.v3.volume.Volume.retype",
|
||||
self.proxy.retype_volume,
|
||||
method_args=["value", "rbd"],
|
||||
expected_args=["rbd", "never"])
|
||||
|
||||
def test_volume_retype_with_migration_policy(self):
|
||||
self._verify("openstack.block_storage.v3.volume.Volume.retype",
|
||||
self.proxy.retype_volume,
|
||||
method_args=["value", "rbd", "on-demand"],
|
||||
expected_args=["rbd", "on-demand"])
|
||||
|
||||
def test_backend_pools(self):
|
||||
self.verify_list(self.proxy.backend_pools, stats.Pools)
|
||||
|
||||
|
||||
@@ -147,3 +147,18 @@ class TestVolume(base.TestCase):
|
||||
body = {'os-update_readonly_flag': {'readonly': False}}
|
||||
headers = {'Accept': ''}
|
||||
self.sess.post.assert_called_with(url, json=body, headers=headers)
|
||||
|
||||
def test_retype(self):
|
||||
sot = volume.Volume(**VOLUME)
|
||||
|
||||
self.assertIsNone(sot.retype(self.sess, 'rbd', 'on-demand'))
|
||||
|
||||
url = 'volumes/%s/action' % FAKE_ID
|
||||
body = {
|
||||
'os-retype': {
|
||||
'new_type': 'rbd',
|
||||
'migration_policy': 'on-demand'
|
||||
}
|
||||
}
|
||||
headers = {'Accept': ''}
|
||||
self.sess.post.assert_called_with(url, json=body, headers=headers)
|
||||
|
||||
Reference in New Issue
Block a user