Implement Plan remove Role for the OpenStack client

Change-Id: I51741dac1e118c99d7878095269dc738726b03bc
This commit is contained in:
Dougal Matthews 2015-04-30 15:43:54 +01:00
parent 3413001b4b
commit 622802052e
2 changed files with 34 additions and 3 deletions

View File

@ -236,11 +236,31 @@ class RemoveManagementPlanRole(show.ShowOne):
def get_parser(self, prog_name): def get_parser(self, prog_name):
parser = super(RemoveManagementPlanRole, self).get_parser(prog_name) parser = super(RemoveManagementPlanRole, self).get_parser(prog_name)
parser.add_argument(
'plan_uuid',
help="The UUID of the plan."
)
parser.add_argument(
'role_uuid',
help="The UUID of the Role being removed from the Plan."
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args) self.log.debug("take_action(%s)" % parsed_args)
client = self.app.client_manager.management
plan = client.plans.remove_role(
parsed_args.plan_uuid,
parsed_args.role_uuid
)
return self.dict2columns(plan.to_dict())
class DownloadManagementPlan(command.Command): class DownloadManagementPlan(command.Command):
"""Download the a Management Plan.""" """Download the a Management Plan."""

View File

@ -286,12 +286,23 @@ class TestRemoveManagementPlanRole(TestPlans):
self.cmd = plan.RemoveManagementPlanRole(self.app, None) self.cmd = plan.RemoveManagementPlanRole(self.app, None)
def test_remove_plan_role(self): def test_remove_plan_role(self):
arglist = [] arglist = ['UUID1', 'UUID2']
verifylist = [] verifylist = [
('plan_uuid', 'UUID1'),
('role_uuid', 'UUID2'),
]
self.management_mock.plans.remove_role.return_value = (
fakes.mock_plans[0])
parsed_args = self.check_parser(self.cmd, arglist, verifylist) parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args) result = self.cmd.take_action(parsed_args)
self.assertEqual([
('description', 'name', 'roles', 'uuid'),
('Plan 1', 'Plan 1 Name', fakes.mock_roles, 'UUID1')
], list(result))
class TestDownloadManagementPlan(TestPlans): class TestDownloadManagementPlan(TestPlans):