Filter and format parameters for plan role in OSC

Output of commands for add/remove role to plan inside OpenStack
client was too long. Filter and formatter for parameters and
roles added.

Change-Id: I1831aab96dad00f605feb6340e43ca5437fe0c04
This commit is contained in:
Marek Aufart 2015-05-29 13:58:06 +02:00
parent 47fdee09d0
commit 24087b31c0

View File

@ -21,6 +21,7 @@ from cliff import command
from cliff import lister
from cliff import show
from tuskarclient.common import formatting
from tuskarclient.common import utils
@ -228,7 +229,7 @@ class AddManagementPlanRole(show.ShowOne):
parsed_args.role_uuid
)
return self.dict2columns(plan.to_dict())
return self.dict2columns(filtered_plan_dict(plan.to_dict()))
class RemoveManagementPlanRole(show.ShowOne):
@ -261,7 +262,7 @@ class RemoveManagementPlanRole(show.ShowOne):
parsed_args.role_uuid
)
return self.dict2columns(plan.to_dict())
return self.dict2columns(filtered_plan_dict(plan.to_dict()))
class DownloadManagementPlan(command.Command):
@ -320,3 +321,18 @@ class DownloadManagementPlan(command.Command):
with open(filename, 'w+') as template_file:
template_file.write(template_content)
print(filename)
def filtered_plan_dict(plan_dict):
if 'parameters' in plan_dict and 'roles' in plan_dict:
plan_dict['parameters'] = [param for param in
plan_dict['parameters']
if param['name'].endswith('::count')]
plan_dict['parameters'] = formatting.parameters_v2_formatter(
plan_dict['parameters'])
plan_dict['roles'] = formatting.parameters_v2_formatter(
plan_dict['roles'])
return plan_dict