diff --git a/examples/showoci/showoci.py b/examples/showoci/showoci.py index 01aee9b0aa..6d8d19d99d 100755 --- a/examples/showoci/showoci.py +++ b/examples/showoci/showoci.py @@ -104,6 +104,8 @@ import sys import argparse import datetime +import contextlib +import os version = "22.03.29" @@ -280,7 +282,7 @@ def return_error_message(service_error, service_warning, data_error, output_erro ########################################################################## # set parser ########################################################################## -def set_parser_arguments(): +def set_parser_arguments(argsList=[]): parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=80, width=130)) parser.add_argument('-a', action='store_true', default=False, dest='all', help='Print All Resources') parser.add_argument('-ani', action='store_true', default=False, dest='allnoiam', help='Print All Resources but identity') @@ -332,7 +334,17 @@ def set_parser_arguments(): parser.add_argument('-caches', action='store_true', default=False, dest='servicescr', help="Output Cache to screen (JSON format)") parser.add_argument('--version', action='version', version='%(prog)s ' + version) - result = parser.parse_args() + + if not argsList: + result = parser.parse_args() + else: + with contextlib.redirect_stdout(os.devnull): + try: + result = parser.parse_args(args=argsList) + return result + except: + return False + if len(sys.argv) < 2: parser.print_help() diff --git a/examples/showoci/showoci_data.py b/examples/showoci/showoci_data.py index c8eb87e5f7..2b603d17cf 100755 --- a/examples/showoci/showoci_data.py +++ b/examples/showoci/showoci_data.py @@ -41,6 +41,9 @@ def __init__(self, flags): # initiate service object self.service = ShowOCIService(flags) + # Initate data list everytime class is instantiated + self.data = [] + ############################################ # get service data ############################################ diff --git a/examples/showoci/showoci_output.py b/examples/showoci/showoci_output.py index bf5b3e5da9..161ad1d498 100755 --- a/examples/showoci/showoci_output.py +++ b/examples/showoci/showoci_output.py @@ -2647,7 +2647,13 @@ class ShowOCISummary(object): # Init ############################################ def __init__(self): - pass + + # Initate summary objects everytime class is instantiated + self.summary_global_list = [] + self.summary_global_data = [] + self.summary_global_region_total = [] + self.summary_global_region_json = {} + self.summary_global_total = [] ########################################################################## # get summary total