Adds the --all flag to tuskar plan-add-role

As part of [1] adds the ability to associate all current roles
to the specified plan uuid. The aim is to make it easier to
refresh the tuskar roles on a live deployment.

tuskar plan-add-role --all-roles plan_uuid

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1229493

Change-Id: If3fff0a372cf60355421ef8182458448e05b6841
This commit is contained in:
marios 2015-06-23 17:53:45 +03:00
parent 9e051c620a
commit 133db59ecf
1 changed files with 18 additions and 7 deletions

View File

@ -137,14 +137,25 @@ def do_plan_create(tuskar, args, outfile=sys.stdout):
@utils.arg('plan_uuid', help="UUID of the Plan to assign role to.")
@utils.arg('-r', '--role-uuid', metavar="<ROLE UUID>",
required=True, help='UUID of the Role to be assigned.')
required=False, help='UUID of the Role to be assigned.')
@utils.arg('--all-roles', default=False, action="store_true",
help='Add all Roles to the given plan')
def do_plan_add_role(tuskar, args, outfile=sys.stdout):
"""Associate role to a plan."""
plan = tuskar.plans.add_role(
vars(args).get('plan_uuid'),
vars(args).get('role_uuid')
)
print_plan_summary(plan, outfile=outfile)
plan = ''
if vars(args).get('all_roles'):
roles = tuskar.roles.list()
if not roles:
print(u'WARNING --all specified but no roles found', file=outfile)
for role in roles:
plan = tuskar.plans.add_role(vars(args).get('plan_uuid'),
role.uuid)
else:
plan = tuskar.plans.add_role(
vars(args).get('plan_uuid'),
vars(args).get('role_uuid')
)
if plan:
print_plan_summary(plan, outfile=outfile)
@utils.arg('plan_uuid', help="UUID of the Plan to remove role from.")