def create_recipe(distro_tree=None, task_list=None, task_name=u'/distribution/reservesys', num_tasks=None, whiteboard=None, role=None, cls=MachineRecipe, **kwargs): if not distro_tree: distro_tree = create_distro_tree() recipe = cls(ttasks=1) recipe.whiteboard = whiteboard recipe.distro_tree = distro_tree recipe.role = role or u'STANDALONE' recipe.distro_requires = recipe.distro_tree.to_xml().toxml() if kwargs.get('reservesys', False): duration = kwargs.get('reservesys_duration', 86400) recipe.reservation_request = RecipeReservationRequest(duration) if num_tasks: task_list = [create_task() for i in range(0, num_tasks)] if task_list: #don't specify a task_list and a task_name... for t in task_list: rt = RecipeTask.from_task(t) rt.role = u'STANDALONE' recipe.tasks.append(rt) recipe.ttasks = len(task_list) else: rt = RecipeTask.from_task(create_task(name=task_name)) rt.role = u'STANDALONE' recipe.tasks.append(rt) return recipe
def create_recipe(distro_tree=None, task_list=None, task_name=u'/distribution/reservesys', whiteboard=None, role=None, cls=MachineRecipe, **kwargs): if not distro_tree: distro_tree = create_distro_tree() recipe = cls(ttasks=1) recipe.whiteboard = whiteboard recipe.distro_tree = distro_tree recipe.role = role recipe.distro_requires = recipe.distro_tree.to_xml().toxml() if kwargs.get('reservesys', False): duration=kwargs.get('reservesys_duration', 86400) recipe.reservation_request = RecipeReservationRequest(duration) if task_list: #don't specify a task_list and a task_name... for t in task_list: rt = RecipeTask.from_task(t) rt.role = u'STANDALONE' recipe.tasks.append(rt) recipe.ttasks = len(task_list) else: rt = RecipeTask.from_task(create_task(name=task_name)) rt.role = u'STANDALONE' recipe.tasks.append(rt) return recipe
def setUp(self): with session.begin(): self.recipe = data_setup.create_recipe(task_name=u'/distribution/install') self.recipe.tasks.extend([ RecipeTask.from_task(data_setup.create_task()), RecipeTask.from_fetch_url(u'http://example.com/tasks/example.tar.bz2'), ]) data_setup.create_job_for_recipes([self.recipe]) data_setup.mark_recipe_running(self.recipe)
def setUp(self): with session.begin(): self.recipe = data_setup.create_recipe( task_name=u'/distribution/install') self.recipe.tasks.extend([ RecipeTask.from_task(data_setup.create_task()), RecipeTask.from_fetch_url( u'http://example.com/tasks/example.tar.bz2'), ]) data_setup.create_job_for_recipes([self.recipe]) data_setup.mark_recipe_running(self.recipe)
def create_recipe(distro_tree=None, task_list=None, task_name=u'/distribution/reservesys', num_tasks=None, whiteboard=None, role=None, ks_meta=None, cls=MachineRecipe, **kwargs): recipe = cls(ttasks=1) recipe.ks_meta = ks_meta recipe.whiteboard = whiteboard recipe.distro_tree = distro_tree recipe.role = role or u'STANDALONE' custom_distro = kwargs.get('custom_distro', False) if not custom_distro: if not distro_tree: distro_tree = create_distro_tree(**kwargs) recipe.distro_tree = distro_tree recipe.installation = recipe.distro_tree.create_installation_from_tree() recipe.distro_requires = lxml.etree.tostring(recipe.distro_tree.to_xml(), encoding=unicode) else: name = kwargs.get('distro_name', u'MyAwesomeLinux1.0') tree_url = kwargs.get('tree_url', u'ftp://dummylab.example.com/distros/MyAwesomeLinux1/') initrd_path = kwargs.get('initrd_path', u'pxeboot/initrd') kernel_path = kwargs.get('kernel_path', u'pxeboot/vmlinuz') arch = kwargs.get('arch', u'i386') variant = kwargs.get('variant', u'Server') osmajor = kwargs.get('osmajor', u'DansAwesomeLinux6') osminor = kwargs.get('osminor', u'0') arch = Arch.by_name(arch) recipe.installation = Installation(tree_url=tree_url, initrd_path=initrd_path, kernel_path=kernel_path, arch=arch, distro_name=name, osmajor=osmajor, osminor=osminor, variant=variant) if kwargs.get('reservesys', False): recipe.reservation_request = RecipeReservationRequest() if kwargs.get('reservesys_duration'): recipe.reservation_request.duration = kwargs['reservesys_duration'] if num_tasks: task_list = [create_task() for i in range(0, num_tasks)] if not task_list: #don't specify a task_list and a task_name... try: task = Task.by_name(task_name) except LookupError: task = create_task(name=task_name) task_list = [task] for t in task_list: rt = RecipeTask.from_task(t) rt.role = u'STANDALONE' recipe.tasks.append(rt) recipe.ttasks = len(task_list) return recipe
def create_recipe(distro_tree=None, task_list=None, task_name=u'/distribution/reservesys', num_tasks=None, whiteboard=None, role=None, ks_meta=None, cls=MachineRecipe, **kwargs): recipe = cls(ttasks=1) recipe.ks_meta = ks_meta recipe.whiteboard = whiteboard recipe.distro_tree = distro_tree recipe.role = role or u'STANDALONE' custom_distro = kwargs.get('custom_distro', False) if not custom_distro: if not distro_tree: distro_tree = create_distro_tree(**kwargs) recipe.distro_tree = distro_tree recipe.installation = recipe.distro_tree.create_installation_from_tree() recipe.distro_requires = lxml.etree.tostring(recipe.distro_tree.to_xml(), encoding=unicode) else: name = kwargs.get('distro_name', u'MyAwesomeLinux1.0') tree_url = kwargs.get('tree_url', u'ftp://dummylab.example.com/distros/MyAwesomeLinux1/') initrd_path = kwargs.get('initrd_path', u'pxeboot/initrd') kernel_path = kwargs.get('kernel_path', u'pxeboot/vmlinuz') arch = kwargs.get('arch', u'i386') variant = kwargs.get('variant', u'Server') osmajor = kwargs.get('osmajor', u'DansAwesomeLinux6') osminor = kwargs.get('osminor', u'0') arch = Arch.by_name(arch) recipe.installation = Installation(tree_url=tree_url, initrd_path=initrd_path, kernel_path=kernel_path, arch=arch, distro_name=name, osmajor=osmajor, osminor=osminor, variant=variant) if kwargs.get('reservesys', False): recipe.reservation_request = RecipeReservationRequest() if kwargs.get('reservesys_duration'): recipe.reservation_request.duration = kwargs['reservesys_duration'] if num_tasks: task_list = [create_task() for i in range(0, num_tasks)] if not task_list: #don't specify a task_list and a task_name... try: task = Task.by_name(task_name) except LookupError: task = create_task(name=task_name) task_list = [task] for t in task_list: rt = RecipeTask.from_task(t) rt.role = u'STANDALONE' recipe.tasks.append(rt) recipe.ttasks = len(task_list) return recipe
# If fetch URL is given, the task doesn't need to exist. xmltasks.append(xmltask) elif Task.exists_by_name(xmltask.name, valid=True): xmltasks.append(xmltask) else: invalid_tasks.append(xmltask.name) if invalid_tasks and not ignore_missing_tasks: raise BX(_('Invalid task(s): %s') % ', '.join(invalid_tasks)) for xmltask in xmltasks: if hasattr(xmltask, 'fetch'): recipetask = RecipeTask.from_fetch_url( xmltask.fetch.url, subdir=xmltask.fetch.subdir, name=xmltask.name) else: recipetask = RecipeTask.from_task(Task.by_name(xmltask.name)) recipetask.role = xmltask.role for xmlparam in xmltask.iter_params(): param = RecipeTaskParam(name=xmlparam.name, value=xmlparam.value) recipetask.params.append(param) recipe.tasks.append(recipetask) if not recipe.tasks: raise BX(_('No Tasks! You can not have a recipe with no tasks!')) return recipe @expose('json') def update_recipe_set_response(self, recipe_set_id, response_id): rs = RecipeSet.by_id(recipe_set_id) old_response = None if rs.nacked is None:
for xmltask in xmlrecipe.iter_tasks(): if hasattr(xmltask, 'fetch'): # If fetch URL is given, the task doesn't need to exist. xmltasks.append(xmltask) elif Task.exists_by_name(xmltask.name, valid=True): xmltasks.append(xmltask) else: invalid_tasks.append(xmltask.name) if invalid_tasks and not ignore_missing_tasks: raise BX(_('Invalid task(s): %s') % ', '.join(invalid_tasks)) for xmltask in xmltasks: if hasattr(xmltask, 'fetch'): recipetask = RecipeTask.from_fetch_url(xmltask.fetch.url, subdir=xmltask.fetch.subdir, name=xmltask.name) else: recipetask = RecipeTask.from_task(Task.by_name(xmltask.name)) recipetask.role = xmltask.role for xmlparam in xmltask.iter_params(): param = RecipeTaskParam( name=xmlparam.name, value=xmlparam.value) recipetask.params.append(param) recipe.tasks.append(recipetask) if not recipe.tasks: raise BX(_('No Tasks! You can not have a recipe with no tasks!')) return recipe @expose('json') def update_recipe_set_response(self,recipe_set_id,response_id): rs = RecipeSet.by_id(recipe_set_id) if rs.nacked is None: rs.nacked = RecipeSetResponse(response_id=response_id)