Add share type change to Share Migration CLI

This patch adds '--new_share_type' to 'migration-start' CLI
command, allowing a user to change the share type during migration.

Depends-On: I3200eaaa5b66d9b8ce1cbd16c1658db8516c70fb
Partially implements: blueprint newton-migration-improvements
Change-Id: Ib0a43369bad5a72eef619cb73c417a8dde153b56
This commit is contained in:
Rodrigo Barbieri 2016-08-10 22:43:42 -03:00
parent 800b8003b1
commit b5b1ebed62
5 changed files with 30 additions and 7 deletions

View File

@ -539,6 +539,7 @@ class SharesTest(utils.TestCase):
"writable": True,
"nondisruptive": False,
"new_share_network_id": None,
"new_share_type_id": None,
})
self.assertEqual("fake", result)

View File

@ -329,7 +329,7 @@ class ShellTest(test_utils.TestCase):
cliutils.print_list.assert_called_once_with(
mock.ANY,
['ID', 'Share ID', 'Host', 'Status', 'Availability Zone',
'Share Network ID', 'Share Server ID'])
'Share Network ID', 'Share Server ID', 'Share Type ID'])
@mock.patch.object(cliutils, 'print_list', mock.Mock())
def test_share_instance_list_select_column(self):
@ -1876,7 +1876,7 @@ class ShellTest(test_utils.TestCase):
command = ("migration-start --preserve-metadata False --writable False"
" --force-host-assisted-migration True "
"--non-disruptive True --new-share-network 1111 "
"1234 host@backend#pool")
"--new-share-type 1 1234 host@backend#pool")
self.run_command(command)
expected = {'migration_start': {
'host': 'host@backend#pool',
@ -1885,6 +1885,7 @@ class ShellTest(test_utils.TestCase):
'writable': 'False',
'nondisruptive': 'True',
'new_share_network_id': '1111',
'new_share_type_id': '1'
}}
self.assert_called('POST', '/shares/1234/action', body=expected)

View File

@ -45,11 +45,13 @@ class Share(common_base.Resource):
def migration_start(self, host, force_host_assisted_migration,
preserve_metadata=True, writable=True,
nondisruptive=False, new_share_network_id=None):
nondisruptive=False, new_share_network_id=None,
new_share_type_id=None):
"""Migrate the share to a new host."""
self.manager.migration_start(self, host, force_host_assisted_migration,
preserve_metadata, writable,
nondisruptive, new_share_network_id)
nondisruptive, new_share_network_id,
new_share_type_id)
def migration_complete(self):
"""Complete migration of a share."""
@ -152,7 +154,8 @@ class ShareManager(base.ManagerWithFind):
@api_versions.experimental_api
def migration_start(self, share, host, force_host_assisted_migration,
preserve_metadata=True, writable=True,
nondisruptive=False, new_share_network_id=None):
nondisruptive=False, new_share_network_id=None,
new_share_type_id=None):
return self._action(
"migration_start", share, {
"host": host,
@ -161,6 +164,7 @@ class ShareManager(base.ManagerWithFind):
"writable": writable,
"nondisruptive": nondisruptive,
"new_share_network_id": new_share_network_id,
"new_share_type_id": new_share_type_id,
})
@api_versions.wraps("2.22")

View File

@ -680,6 +680,15 @@ def do_create(cs, args):
help='Specifies a new share network if desired to change. Default=None. '
'Introduced in version 2.22.',
default=None)
@cliutils.arg(
'--new_share_type',
'--new-share-type',
metavar='<new_share_type>',
required=False,
action='single_alias',
help='Specifies a new share type if desired to change. Default=None. '
'Introduced in version 2.22.',
default=None)
def do_migration_start(cs, args):
"""Migrates share to a new host (Admin only, Experimental)."""
share = _find_share(cs, args.share)
@ -687,9 +696,14 @@ def do_migration_start(cs, args):
if args.new_share_network:
share_net = _find_share_network(cs, args.new_share_network)
new_share_net_id = share_net.id if share_net else None
new_share_type_id = None
if args.new_share_type:
share_type = _find_share_type(cs, args.new_share_type)
new_share_type_id = share_type.id if share_type else None
share.migration_start(args.host, args.force_host_assisted_migration,
args.preserve_metadata, args.writable,
args.non_disruptive, new_share_net_id)
args.non_disruptive, new_share_net_id,
new_share_type_id)
@cliutils.arg(
@ -1412,7 +1426,7 @@ def do_share_instance_list(cs, args):
list_of_keys = [
'ID', 'Share ID', 'Host', 'Status', 'Availability Zone',
'Share Network ID', 'Share Server ID'
'Share Network ID', 'Share Server ID', 'Share Type ID',
]
if args.columns is not None:

View File

@ -0,0 +1,3 @@
---
features:
- Added parameter to change share type when performing migration.