+ def list_steps(self):
+ if not self.options.verbose:
+ print(self.steps_message)
+ else:
+ # steps mentioned on the command line
+ if self.options.steps:
+ scopes = [("Argument steps",self.options.steps)]
+ else:
+ scopes = [("Default steps", TestPlc.default_steps)]
+ if self.options.all_steps:
+ scopes.append ( ("Other steps", TestPlc.other_steps) )
+ # try to list macro steps as well
+ scopes.append ( ("Macro steps", Step.list_macros()) )
+ for (scope, steps) in scopes:
+ print('--------------------', scope)
+ for step in [step for step in steps if TestPlc.valid_step(step)]:
+ try:
+ (step, qualifier) = step.split('@')
+ except:
+ pass
+ stepname = step
+ for special in ['force', 'ignore']:
+ stepname = stepname.replace('_'+special, "")
+ Step(stepname).print_doc()
+
+ def run (self):
+ usage = """usage: %%prog [options] steps
+arch-rpms-url defaults to the last value used, as stored in arg-arch-rpms-url,
+ no default
+config defaults to the last value used, as stored in arg-config,
+ or {}
+ips_vnode, ips_vplc and ips_qemu defaults to the last value used,
+ as stored in arg-ips-{{bplc,vplc,bnode,vnode}},
+ default is to use IP scanning
+steps refer to a method in TestPlc or to a step_* module
+
+run with -l to see a list of available steps
+===
+""".format(TestMain.default_config)
+
+ parser = ArgumentParser(usage = usage)
+ parser.add_argument("-u", "--url", action="store", dest="arch_rpms_url",
+ help="URL of the arch-dependent RPMS area - for locating what to test")
+ parser.add_argument("-b", "--build", action="store", dest="build_url",
+ help="ignored, for legacy only")
+ parser.add_argument("-c", "--config", action="append", dest="config", default=[],
+ help="Config module - can be set multiple times, or use quotes")
+ parser.add_argument("-p", "--personality", action="store", dest="personality",
+ help="personality - as in vbuild-nightly")
+ parser.add_argument("-d", "--pldistro", action="store", dest="pldistro",
+ help="pldistro - as in vbuild-nightly")
+ parser.add_argument("-f", "--fcdistro", action="store", dest="fcdistro",
+ help="fcdistro - as in vbuild-nightly")
+ parser.add_argument("-e", "--exclude", action="append", dest="exclude", default=[],
+ help="steps to exclude - can be set multiple times, or use quotes")
+ parser.add_argument("-i", "--ignore", action="append", dest="ignore", default=[],
+ help="steps to run but ignore - can be set multiple times, or use quotes")
+ parser.add_argument("-a", "--all", action="store_true", dest="all_steps", default=False,
+ help="Run all default steps")
+ parser.add_argument("-l", "--list", action="store_true", dest="list_steps", default=False,
+ help="List known steps")
+ parser.add_argument("-V", "--vserver", action="append", dest="ips_bplc", default=[],
+ help="Specify the set of hostnames for the boxes that host the plcs")
+ parser.add_argument("-P", "--plcs", action="append", dest="ips_vplc", default=[],
+ help="Specify the set of hostname/IP's to use for vplcs")
+ parser.add_argument("-Q", "--qemus", action="append", dest="ips_bnode", default=[],
+ help="Specify the set of hostnames for the boxes that host the nodes")
+ parser.add_argument("-N", "--nodes", action="append", dest="ips_vnode", default=[],
+ help="Specify the set of hostname/IP's to use for vnodes")
+ parser.add_argument("-s", "--size", action="store", dest="size", default=1,
+ type=int,
+ help="set test size in # of plcs - default is 1")
+ parser.add_argument("-q", "--qualifier", action="store", dest="qualifier", default=None,
+ type=int,
+ help="run steps only on plc numbered <qualifier>, starting at 1")
+ parser.add_argument("-y", "--rspec-style", action="append", dest="rspec_styles", default=[],
+ help="pl is for planetlab rspecs, pg is for protogeni")
+ parser.add_argument("-k", "--keep-going", action="store", dest="keep_going", default=False,
+ help="proceeds even if some steps are failing")
+ parser.add_argument("-D", "--dbname", action="store", dest="dbname", default=None,
+ help="Used by plc_db_dump and plc_db_restore")
+ parser.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False,
+ help="Run in verbose mode")
+ parser.add_argument("-I", "--interactive", action="store_true", dest="interactive", default=False,
+ help="prompts before each step")
+ parser.add_argument("-n", "--dry-run", action="store_true", dest="dry_run", default=False,
+ help="Show environment and exits")
+ parser.add_argument("-t", "--trace", action="store", dest="trace_file", default=None,
+ help="Trace file location")
+ parser.add_argument("-g", "--bonding", action='store', dest='bonding', default=None,
+ help="specify build to bond with")
+ parser.add_argument("steps", nargs='*')
+ self.options = parser.parse_args()
+
+ # allow things like "run -c 'c1 c2' -c c3"
+ def flatten (x):
+ result = []
+ for el in x:
+ if hasattr(el, "__iter__") and not isinstance(el, str):
+ result.extend(flatten(el))
+ else:
+ result.append(el)
+ return result
+ # flatten relevant options
+ for optname in ['config', 'exclude', 'ignore', 'ips_bplc', 'ips_vplc', 'ips_bnode', 'ips_vnode']:
+ setattr(self.options, optname,
+ flatten([arg.split() for arg in getattr(self.options, optname)]))
+
+ if not self.options.rspec_styles:
+ self.options.rspec_styles = TestMain.default_rspec_styles