def run(self, *args, **kwargs): self.set_hub(**kwargs) debug = kwargs.pop('debug', False) dryrun = kwargs.pop('dryrun', False) wait = kwargs.pop('wait', False) taskParams = kwargs.pop('taskparam', []) families = kwargs.pop('family', []) kwargs.pop('variant', None) kwargs.pop('arch', None) if not kwargs.get('whiteboard'): kwargs['whiteboard'] = 'Test harness installation' if not families: families = self.get_os_majors(**kwargs) # filter out any junky old distros with no family families = [f for f in families if f] fva = set() # all family-variant-arch combinations for family in families: dts = self.hub.distrotrees.filter({'family': family}) for dt in dts: fva.add((family, dt['variant'] or '', dt['arch'])) # if this family has any variants, discard combinations which have blank variant if any(f == family and v for f, v, a in fva): fva.difference_update([(f, v, a) for f, v, a in fva if f == family and not v]) job = BeakerJob(**kwargs) for family, variant, arch in sorted(fva): requestedTasks = self.get_tasks(family=family, **kwargs) recipe = BeakerRecipe() recipe.add_base_requires(family=family, variant=variant, arch=arch, **kwargs) arch_node = self.doc.createElement('distro_arch') arch_node.setAttribute('op', '=') arch_node.setAttribute('value', arch) recipe = self.process_template(recipe, requestedTasks, taskParams=taskParams, distroRequires=arch_node, arch=arch, family=family, allow_empty_recipe=True, **kwargs) recipe.whiteboard = ' '.join([family, variant, arch]) recipeset = BeakerRecipeSet(**kwargs) recipeset.add_recipe(recipe) job.add_recipe_set(recipeset) jobxml = job.toxml(**kwargs) if debug: print(jobxml) submitted_jobs = [] failed = False if not dryrun: try: submitted_jobs.append(self.hub.jobs.upload(jobxml)) print("Submitted: %s" % submitted_jobs) except (KeyboardInterrupt, SystemError): raise except Exception as ex: failed = True sys.stderr.write('Exception: %s\n' % ex) if wait: failed |= watch_tasks(self.hub, submitted_jobs) sys.exit(failed)
def run(self, *args, **kwargs): self.set_hub(**kwargs) debug = kwargs.get("debug", False) dryrun = kwargs.get("dryrun", False) wait = kwargs.get("wait", False) machine = kwargs.get("machine", None) family = kwargs.get("family", []) taskParams = kwargs.get("taskparam", []) # Add in Inventory if requested if kwargs.get("inventory"): kwargs['task'].append('/distribution/inventory') if not machine: self.parser.error('Use --machine to specify machine to be tested') if not kwargs.get("whiteboard"): kwargs["whiteboard"] = "Test %s" % machine # If family is specified on command line just do it. if family: if not kwargs['arches']: self.parser.error( "If family is specified you must specify arches as well") families = dict((family, [arch for arch in kwargs['arches']]) for family in family) else: families = self.get_system_os_major_arches(*args, **kwargs) # Exit early if not families: sys.stderr.write( 'Could not find an appropriate distro to provision system with.' ) sys.exit(1) # Create Job job = BeakerJob(*args, **kwargs) for family, arches in families.items(): kwargs['family'] = family # get all tasks requested requestedTasks = self.get_tasks(*args, **kwargs) # If arch is specified on command line limit to just those. (if they match) if kwargs['arches']: arches = set(kwargs['arches']).intersection(set(arches)) for arch in arches: recipeTemplate = BeakerRecipe() # Add Distro Requirements temp = dict(kwargs) temp['family'] = family recipeTemplate.add_base_requires(*args, **temp) arch_node = self.doc.createElement('distro_arch') arch_node.setAttribute('op', '=') arch_node.setAttribute('value', arch) recipe_set = BeakerRecipeSet(**kwargs) recipe_set.add_recipe( self.process_template(recipeTemplate, requestedTasks, taskParams=taskParams, allow_empty_recipe=True, distroRequires=arch_node, **temp)) job.add_recipe_set(recipe_set) # jobxml jobxml = job.toxml(**kwargs) if debug: print(jobxml) submitted_jobs = [] failed = False if not dryrun: try: submitted_jobs.append(self.hub.jobs.upload(jobxml)) except Exception as ex: failed = True sys.stderr.write(ex) if not dryrun: print("Submitted: %s" % submitted_jobs) if wait: watch_tasks(self.hub, submitted_jobs) if failed: sys.exit(1)
def run(self, *args, **kwargs): if not kwargs.get("package", []) and not kwargs.get("task", []) \ and not kwargs.get("taskfile", []) and not kwargs.get("type", []): self.parser.error( 'No tasks specified to be run\nHint: ' 'Use --task, --package, --taskfile or --task-type to select tasks\n' ) self.set_hub(**kwargs) debug = kwargs.get("debug", False) dryrun = kwargs.get("dryrun", False) wait = kwargs.get("wait", False) family = kwargs.get("family", None) distro = kwargs.get("distro", None) arches = kwargs.get("arches", []) taskParams = kwargs.get("taskparam", []) if not family and not distro: sys.stderr.write("No Family or Distro specified\n") sys.exit(1) if not arches: # Get default arches that apply for this distro/family arches = self.get_arches(*args, **kwargs) # get all tasks requested try: requested_tasks = self.get_tasks(*args, **kwargs) except Fault: requested_tasks = None if not requested_tasks: sys.stderr.write("No tasks match the specified option(s)\n") sys.exit(1) # Create Job job = BeakerJob(*args, **kwargs) # Create Base Recipe recipe_template = BeakerRecipe() # Add Distro Requirements recipe_template.add_base_requires(*args, **kwargs) # Add Host Requirements for arch in arches: arch_node = self.doc.createElement('distro_arch') arch_node.setAttribute('op', '=') arch_node.setAttribute('value', arch) recipe_set = BeakerRecipeSet(**kwargs) if self.multi_host: for i in range(self.n_servers): recipe_set.add_recipe( self.process_template(recipe_template, requested_tasks, taskParams=taskParams, distroRequires=arch_node, role='SERVERS', arch=arch, **kwargs)) for i in range(self.n_clients): recipe_set.add_recipe( self.process_template(recipe_template, requested_tasks, taskParams=taskParams, distroRequires=arch_node, role='CLIENTS', arch=arch, **kwargs)) else: recipe_set.add_recipe( self.process_template(recipe_template, requested_tasks, taskParams=taskParams, distroRequires=arch_node, arch=arch, **kwargs)) job.add_recipe_set(recipe_set) # jobxml jobxml = job.toxml(**kwargs) if debug: print(jobxml) submitted_jobs = [] is_failed = False if not dryrun: try: submitted_jobs.append(self.hub.jobs.upload(jobxml)) print("Submitted: %s" % submitted_jobs) except (KeyboardInterrupt, SystemExit): raise except Exception as ex: is_failed = True sys.stderr.write('Exception: %s\n' % ex) if wait: is_failed |= watch_tasks(self.hub, submitted_jobs) sys.exit(is_failed)