Merge "Revert "Cleanup for Replication v2: remove 'replication-reenable'.""

This commit is contained in:
Jenkins
2016-03-16 21:44:56 +00:00
committed by Gerrit Code Review
5 changed files with 32 additions and 0 deletions

View File

@@ -455,6 +455,8 @@ class FakeHTTPClient(base_client.HTTPClient):
assert list(body[action]) == ['bootable'] assert list(body[action]) == ['bootable']
elif action == 'os-unmanage': elif action == 'os-unmanage':
assert body[action] is None assert body[action] is None
elif action == 'os-reenable-replica':
assert body[action] is None
elif action == 'os-set_image_metadata': elif action == 'os-set_image_metadata':
assert list(body[action]) == ['metadata'] assert list(body[action]) == ['metadata']
elif action == 'os-unset_image_metadata': elif action == 'os-unset_image_metadata':
@@ -1083,6 +1085,9 @@ class FakeHTTPClient(base_client.HTTPClient):
snapshot.update(kw['body']['snapshot']) snapshot.update(kw['body']['snapshot'])
return (202, {}, {'snapshot': snapshot}) return (202, {}, {'snapshot': snapshot})
def post_os_reenable_replica_1234(self, **kw):
return (202, {}, {})
def get_scheduler_stats_get_pools(self, **kw): def get_scheduler_stats_get_pools(self, **kw):
stats = [ stats = [
{ {

View File

@@ -1029,6 +1029,11 @@ class ShellTest(utils.TestCase):
self.assert_called('POST', '/volumes/1234/action', self.assert_called('POST', '/volumes/1234/action',
body={'os-unmanage': None}) body={'os-unmanage': None})
def test_replication_reenable(self):
self.run_command('replication-reenable 1234')
self.assert_called('POST', '/volumes/1234/action',
body={'os-reenable-replica': None})
def test_create_snapshot_from_volume_with_metadata(self): def test_create_snapshot_from_volume_with_metadata(self):
""" """
Tests create snapshot with --metadata parameter. Tests create snapshot with --metadata parameter.

View File

@@ -281,6 +281,14 @@ class VolumesTest(utils.TestCase):
cs.assert_called('POST', '/os-snapshot-manage', {'snapshot': expected}) cs.assert_called('POST', '/os-snapshot-manage', {'snapshot': expected})
self._assert_request_id(vol) self._assert_request_id(vol)
def test_replication_reenable(self):
v = cs.volumes.get('1234')
self._assert_request_id(v)
vol = cs.volumes.reenable(v)
cs.assert_called('POST', '/volumes/1234/action',
{'os-reenable-replica': None})
self._assert_request_id(vol)
def test_get_pools(self): def test_get_pools(self):
vol = cs.volumes.get_pools('') vol = cs.volumes.get_pools('')
cs.assert_called('GET', '/scheduler-stats/get_pools') cs.assert_called('GET', '/scheduler-stats/get_pools')

View File

@@ -2236,6 +2236,16 @@ def do_unmanage(cs, args):
cs.volumes.unmanage(volume.id) cs.volumes.unmanage(volume.id)
@utils.arg('volume', metavar='<volume>',
help='Name or ID of the volume to reenable replication. '
'The replication-status of the volume should be inactive.')
@utils.service_type('volumev2')
def do_replication_reenable(cs, args):
"""Sync the secondary volume with primary for a relationship."""
volume = utils.find_volume(cs, args.volume)
cs.volumes.reenable(volume.id)
@utils.arg('--all-tenants', @utils.arg('--all-tenants',
dest='all_tenants', dest='all_tenants',
metavar='<0|1>', metavar='<0|1>',

View File

@@ -587,6 +587,10 @@ class VolumeManager(base.ManagerWithFind):
"""Unmanage a volume.""" """Unmanage a volume."""
return self._action('os-unmanage', volume, None) return self._action('os-unmanage', volume, None)
def reenable(self, volume):
"""Sync the secondary volume with primary for a relationship."""
return self._action('os-reenable-replica', volume, None)
def get_pools(self, detail): def get_pools(self, detail):
"""Show pool information for backends.""" """Show pool information for backends."""
query_string = "" query_string = ""