Skip to content

Commit

Permalink
EDSF-374 Verify that required=True in ArgumentParser works
Browse files Browse the repository at this point in the history
  • Loading branch information
linda.nasredin committed Nov 1, 2023
1 parent d9d3c31 commit 5cc352f
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions modules/aws/sonar-upgrader/python_upgrader/upgrade/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ def init_upgrade_status(extended_nodes, target_version):

def parse_args():
parser = argparse.ArgumentParser(description="Upgrade script for DSF Hub and Agentless Gateway")
parser.add_argument("--agentless_gws", help="JSON-encoded Agentless Gateway list")
parser.add_argument("--dsf_hubs", help="JSON-encoded DSF Hub list")
parser.add_argument("--agentless_gws", required=True, help="JSON-encoded Agentless Gateway list")
parser.add_argument("--dsf_hubs", required=True, help="JSON-encoded DSF Hub list")
parser.add_argument("--target_version", required=True, help="Target version to upgrade")
parser.add_argument("--connection_timeout",
help="Client connection timeout in seconds used for the SSH connections between the "
Expand All @@ -282,12 +282,12 @@ def parse_args():
parser.add_argument("--test_connection", type=str_to_bool,
help="Whether to test the SSH connection to all DSF nodes being upgraded "
"before starting the upgrade")
parser.add_argument("--run_preflight_validations", required=True, type=str_to_bool,
parser.add_argument("--run_preflight_validations", type=str_to_bool,
help="Whether to run preflight validations")
parser.add_argument("--run_upgrade", required=True, type=str_to_bool, help="Whether to run the upgrade")
parser.add_argument("--run_postflight_validations", required=True, type=str_to_bool,
parser.add_argument("--run_upgrade", type=str_to_bool, help="Whether to run the upgrade")
parser.add_argument("--run_postflight_validations", type=str_to_bool,
help="Whether to run postflight validations")
parser.add_argument("--clean_old_deployments", type=str_to_bool, help="Whether to clean old deployments")
# parser.add_argument("--clean_old_deployments", type=str_to_bool, help="Whether to clean old deployments")
parser.add_argument("--stop_on_failure", type=str_to_bool,
help="Whether to stop or continue to upgrade the next DSF nodes in case of failure "
"on a DSF node")
Expand All @@ -297,6 +297,25 @@ def parse_args():
return args


def fill_args_defaults():
if args.connection_timeout is None:
args.connection_timeout = 90
if args.test_connection is None:
args.test_connection = True
if args.run_preflight_validations is None:
args.run_preflight_validations = True
if args.run_upgrade is None:
args.run_upgrade = True
if args.run_postflight_validations is None:
args.run_postflight_validations = True
if args.stop_on_failure is None:
args.stop_on_failure = True
if args.tarball_location is None:
args.tarball_location = '{"s3_bucket": "1ef8de27-ed95-40ff-8c08-7969fc1b7901", "s3_region": "us-east-1"}'

args.clean_old_deployments = False


def print_inputs(agentless_gws, hubs, tarball_location, args):
print("List of Agentless Gateways:")
print_hadr_sets(agentless_gws)
Expand Down Expand Up @@ -907,6 +926,8 @@ def verify_successful_run_by_configuration_options(args, upgrade_status_service)
run_dummy_upgrade = False
args = parse_args()

fill_args_defaults()

CONNECTION_TIMEOUT = int(args.connection_timeout)

main(args)

0 comments on commit 5cc352f

Please sign in to comment.