Merge "Implement Plan add Role for the OpenStack client"
This commit is contained in:
commit
3413001b4b
|
@ -203,11 +203,31 @@ class AddManagementPlanRole(show.ShowOne):
|
|||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(AddManagementPlanRole, 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 added to the Plan."
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
|
||||
client = self.app.client_manager.management
|
||||
|
||||
plan = client.plans.add_role(
|
||||
parsed_args.plan_uuid,
|
||||
parsed_args.role_uuid
|
||||
)
|
||||
|
||||
return self.dict2columns(plan.to_dict())
|
||||
|
||||
|
||||
class RemoveManagementPlanRole(show.ShowOne):
|
||||
"""Remove a Role from a Management Plan."""
|
||||
|
|
|
@ -261,12 +261,22 @@ class TestAddManagementPlanRole(TestPlans):
|
|||
self.cmd = plan.AddManagementPlanRole(self.app, None)
|
||||
|
||||
def test_add_plan_role(self):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
arglist = ['UUID1', 'UUID2']
|
||||
verifylist = [
|
||||
('plan_uuid', 'UUID1'),
|
||||
('role_uuid', 'UUID2'),
|
||||
]
|
||||
|
||||
self.management_mock.plans.add_role.return_value = fakes.mock_plans[0]
|
||||
|
||||
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 TestRemoveManagementPlanRole(TestPlans):
|
||||
|
|
Loading…
Reference in New Issue