[OSC] Implement Share Server Migration Show Command
This commit adds 'openstack share server migration show' command, that implement the same functionality as 'manila migration-get-progress ' command. Partially-implements: bp openstack-client-support Change-Id: I66843b91684645491e236464151d3733ef05cf3b
This commit is contained in:
parent
2bbc6b7b29
commit
35be44a30c
@ -468,3 +468,37 @@ class ShareServerMigrationComplete(command.Command):
|
|||||||
raise exceptions.CommandError(
|
raise exceptions.CommandError(
|
||||||
"Share Server Migration complete is only available "
|
"Share Server Migration complete is only available "
|
||||||
"with manila API version >= 2.57")
|
"with manila API version >= 2.57")
|
||||||
|
|
||||||
|
|
||||||
|
class ShareServerMigrationShow(command.ShowOne):
|
||||||
|
"""Obtains progress of share migration for a given share server.
|
||||||
|
|
||||||
|
(Admin only, Experimental).
|
||||||
|
|
||||||
|
:param share_server: either share_server object or text with its ID.
|
||||||
|
|
||||||
|
"""
|
||||||
|
_description = _(
|
||||||
|
"Gets migration progress of a given share server when copying")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ShareServerMigrationShow, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'share_server',
|
||||||
|
metavar='<share_server>',
|
||||||
|
help='ID of share server to show migration progress for.'
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
share_client = self.app.client_manager.share
|
||||||
|
if share_client.api_version >= api_versions.APIVersion("2.57"):
|
||||||
|
share_server = osc_utils.find_resource(
|
||||||
|
share_client.share_servers,
|
||||||
|
parsed_args.share_server)
|
||||||
|
result = share_server.migration_get_progress()
|
||||||
|
return self.dict2columns(result)
|
||||||
|
else:
|
||||||
|
raise exceptions.CommandError(
|
||||||
|
"Share Server Migration show is only available "
|
||||||
|
"with manila API version >= 2.57")
|
||||||
|
@ -570,3 +570,38 @@ class TestShareServerMigrationComplete(TestShareServer):
|
|||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.share_server.migration_complete.assert_called
|
self.share_server.migration_complete.assert_called
|
||||||
|
|
||||||
|
|
||||||
|
class TestShareServerMigrationShow(TestShareServer):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestShareServerMigrationShow, self).setUp()
|
||||||
|
|
||||||
|
self.new_share_network = manila_fakes.FakeShareNetwork \
|
||||||
|
.create_one_share_network()
|
||||||
|
self.share_networks_mock.get.return_value = self.new_share_network
|
||||||
|
|
||||||
|
self.share_server = (
|
||||||
|
manila_fakes.FakeShareServer.create_one_server(
|
||||||
|
attrs={
|
||||||
|
'status': 'migrating',
|
||||||
|
'task_state': 'migration_in_progress'
|
||||||
|
},
|
||||||
|
methods={'migration_get_progress': None}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.servers_mock.get.return_value = self.share_server
|
||||||
|
|
||||||
|
# Get the command objects to test
|
||||||
|
self.cmd = osc_share_servers.ShareServerMigrationShow(self.app, None)
|
||||||
|
|
||||||
|
def test_share_server_migration_show(self):
|
||||||
|
arglist = [
|
||||||
|
self.share_server.id
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('share_server', self.share_server.id)
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
self.cmd.take_action(parsed_args)
|
||||||
|
self.share_server.migration_get_progress.assert_called
|
||||||
|
@ -157,6 +157,7 @@ openstack.share.v2 =
|
|||||||
share_server_set = manilaclient.osc.v2.share_servers:SetShareServer
|
share_server_set = manilaclient.osc.v2.share_servers:SetShareServer
|
||||||
share_server_migration_cancel = manilaclient.osc.v2.share_servers:ShareServerMigrationCancel
|
share_server_migration_cancel = manilaclient.osc.v2.share_servers:ShareServerMigrationCancel
|
||||||
share_server_migration_complete = manilaclient.osc.v2.share_servers:ShareServerMigrationComplete
|
share_server_migration_complete = manilaclient.osc.v2.share_servers:ShareServerMigrationComplete
|
||||||
|
share_server_migration_show = manilaclient.osc.v2.share_servers:ShareServerMigrationShow
|
||||||
|
|
||||||
[coverage:run]
|
[coverage:run]
|
||||||
omit = manilaclient/tests/*
|
omit = manilaclient/tests/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user