From 5cd75e8727afe44b4d905019b625dd5d12d307df Mon Sep 17 00:00:00 2001 From: Naoya Harada Date: Thu, 29 Sep 2016 14:22:57 +0900 Subject: [PATCH] Improve help text for events-list command options events-list command's help text for some options does not follow common format. Also, *-events-list commands have similar issues. This patch fixes help texts for these commands to make them clearer for users. Change-Id: Icd85d13fee437bf0f83979eb6625377b38ce39ad Closes-bug: #1628769 --- tackerclient/tacker/v1_0/events/events.py | 72 ++++++++++++++++------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/tackerclient/tacker/v1_0/events/events.py b/tackerclient/tacker/v1_0/events/events.py index e325e60f..068f4054 100644 --- a/tackerclient/tacker/v1_0/events/events.py +++ b/tackerclient/tacker/v1_0/events/events.py @@ -19,42 +19,72 @@ from tackerclient.tacker import v1_0 as tackerV10 _EVENT = "event" -class ListResourceEvents(tackerV10.ListCommand): - """List events that belong to a given resource. +class ListEventsBase(tackerV10.ListCommand): + """Base class for list command.""" - The supported args are --id, --resource_id, --resource_state, - --resource_type, --event_type - """ - - resource = _EVENT list_columns = ['id', 'resource_type', 'resource_id', 'resource_state', 'event_type', 'timestamp', 'event_details'] + def get_parser(self, prog_name): + parser = super(ListEventsBase, self).get_parser(prog_name) + parser.add_argument('--id', + help='id of the event to look up.') + parser.add_argument('--resource-id', + help='resource id of the events to look up.') + parser.add_argument('--resource-state', + help='resource state of the events to look up.') + parser.add_argument('--event-type', + help='event type of the events to look up.') + return parser -class ListVNFEvents(ListResourceEvents): - """List events that belong to a given VNF. + def args2search_opts(self, parsed_args): + search_opts = super(ListEventsBase, self).args2search_opts( + parsed_args) + if parsed_args.id: + search_opts.update({'id': parsed_args.id}) + if parsed_args.resource_id: + search_opts.update({'resource_id': parsed_args.resource_id}) + if parsed_args.resource_state: + search_opts.update({'resource_state': parsed_args.resource_state}) + if parsed_args.event_type: + search_opts.update({'event_type': parsed_args.event_type}) + return search_opts - The supported args are --id, --resource_id, --resource_state, --event_type - """ + +class ListResourceEvents(ListEventsBase): + """List events of resources.""" + + resource = _EVENT + + def get_parser(self, prog_name): + parser = super(ListResourceEvents, self).get_parser(prog_name) + parser.add_argument('--resource-type', + help='resource type of the events to look up.') + return parser + + def args2search_opts(self, parsed_args): + search_opts = super(ListResourceEvents, self).args2search_opts( + parsed_args) + if parsed_args.resource_type: + search_opts.update({'resource_type': parsed_args.resource_type}) + return search_opts + + +class ListVNFEvents(ListEventsBase): + """List events of VNFs.""" resource = "vnf_event" -class ListVNFDEvents(ListResourceEvents): - """List events that belong to a given VNFD. - - The supported args are --id, --resource_id, --resource_state, --event_type - """ +class ListVNFDEvents(ListEventsBase): + """List events of VNFDs.""" resource = "vnfd_event" -class ListVIMEvents(ListResourceEvents): - """List events that belong to a given VIM. - - The supported args are --id, --resource_id, --resource_state, --event_type - """ +class ListVIMEvents(ListEventsBase): + """List events of VIMs.""" resource = "vim_event"