From cec788b21911273353ce486856dab23c033a1ba3 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sun, 6 Dec 2015 22:50:52 +0100 Subject: [PATCH] openstack: split argparse arguments So that it can be re-used by scripts that need to include part of the parser. Signed-off-by: Loic Dachary --- scripts/openstack.py | 164 ++++++++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 72 deletions(-) diff --git a/scripts/openstack.py b/scripts/openstack.py index b467de4f50..c758dc6b34 100644 --- a/scripts/openstack.py +++ b/scripts/openstack.py @@ -6,91 +6,31 @@ import teuthology.openstack def main(argv=sys.argv[1:]): sys.exit(teuthology.openstack.main(parse_args(argv), argv)) -def parse_args(argv): - parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, - description=""" -Run a suite of ceph integration tests. A suite is a directory containing -facets. A facet is a directory containing config snippets. Running a suite -means running teuthology for every configuration combination generated by -taking one config snippet from each facet. Any config files passed on the -command line will be used for every combination, and will override anything in -the suite. By specifying a subdirectory in the suite argument, it is possible -to limit the run to a specific facet. For instance -s upgrade/dumpling-x only -runs the dumpling-x facet of the upgrade suite. - -Display the http and ssh access to follow the progress of the suite -and analyze results. - - firefox http://183.84.234.3:8081/ - ssh -i teuthology-admin.pem ubuntu@183.84.234.3 - -""") - parser.add_argument( - '-v', '--verbose', - action='store_true', default=None, - help='be more verbose', - ) - parser.add_argument( - '--wait', - action='store_true', default=None, - help='block until the suite is finished', - ) - parser.add_argument( - '--name', - help='OpenStack primary instance name', - default='teuthology', - ) +def get_key_parser(): + parser = argparse.ArgumentParser() parser.add_argument( '--key-name', help='OpenStack keypair name', - required=True, ) parser.add_argument( '--key-filename', help='path to the ssh private key', ) - parser.add_argument( - '--simultaneous-jobs', - help='maximum number of jobs running in parallel', - type=int, - default=1, - ) - parser.add_argument( - '--teardown', - action='store_true', default=None, - help='destroy the cluster, if it exists', - ) - parser.add_argument( - '--teuthology-git-url', - help=("git clone url for teuthology"), - ) - parser.add_argument( - '--teuthology-branch', - help="use this teuthology branch instead of master", - default='master', - ) - parser.add_argument( - '--upload', - action='store_true', default=False, - help='upload archives to an rsync server', - ) - parser.add_argument( - '--archive-upload', - help='rsync destination to upload archives', - default='ubuntu@teuthology-logs.public.ceph.com:./', - ) - parser.add_argument( - '--archive-upload-url', - help='Public facing URL where archives are uploaded', - default='http://teuthology-logs.public.ceph.com', - ) + return parser + +def get_suite_parser(): + parser = argparse.ArgumentParser() # copy/pasted from scripts/suite.py parser.add_argument( 'config_yaml', nargs='*', help='Optional extra job yaml to include', ) + parser.add_argument( + '-v', '--verbose', + action='store_true', default=None, + help='be more verbose', + ) parser.add_argument( '--dry-run', action='store_true', default=None, @@ -191,5 +131,85 @@ and analyze results. '--ceph-qa-suite-git-url', help=("git clone url for ceph-qa-suite"), ) + return parser + +def get_openstack_parser(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--wait', + action='store_true', default=None, + help='block until the suite is finished', + ) + parser.add_argument( + '--name', + help='OpenStack primary instance name', + default='teuthology', + ) + parser.add_argument( + '--simultaneous-jobs', + help='maximum number of jobs running in parallel', + type=int, + default=1, + ) + parser.add_argument( + '--teardown', + action='store_true', default=None, + help='destroy the cluster, if it exists', + ) + parser.add_argument( + '--teuthology-git-url', + help="git clone url for teuthology", + ) + parser.add_argument( + '--teuthology-branch', + help="use this teuthology branch instead of master", + default='master', + ) + parser.add_argument( + '--upload', + action='store_true', default=False, + help='upload archives to an rsync server', + ) + parser.add_argument( + '--archive-upload', + help='rsync destination to upload archives', + default='ubuntu@teuthology-logs.public.ceph.com:./', + ) + parser.add_argument( + '--archive-upload-url', + help='Public facing URL where archives are uploaded', + default='http://teuthology-logs.public.ceph.com', + ) + return parser - return parser.parse_args(argv) +def get_parser(): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + parents=[ + get_suite_parser(), + get_key_parser(), + get_openstack_parser(), + ], + conflict_handler='resolve', + add_help=False, + description=""" +Run a suite of ceph integration tests. A suite is a directory containing +facets. A facet is a directory containing config snippets. Running a suite +means running teuthology for every configuration combination generated by +taking one config snippet from each facet. Any config files passed on the +command line will be used for every combination, and will override anything in +the suite. By specifying a subdirectory in the suite argument, it is possible +to limit the run to a specific facet. For instance -s upgrade/dumpling-x only +runs the dumpling-x facet of the upgrade suite. + +Display the http and ssh access to follow the progress of the suite +and analyze results. + + firefox http://183.84.234.3:8081/ + ssh -i teuthology-admin.pem ubuntu@183.84.234.3 + +""") + return parser + +def parse_args(argv): + return get_parser().parse_args(argv) -- 2.39.5