Exemplo n.º 1
0
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
Exemplo n.º 2
0
 def test_timeout_is_enforced_for_fetching_images(self):
     with session.begin():
         lc = self.get_lc()
         system = data_setup.create_system(arch=u'x86_64', lab_controller=lc)
         distro_tree = data_setup.create_distro_tree(arch=u'x86_64',
                 lab_controllers=[lc],
                 # /slow/600 means the response will be delayed 10 minutes
                 urls=['http://localhost:19998/slow/600/'])
         installation = Installation(distro_tree=distro_tree, system=system,
                 kernel_options=u'')
         system.configure_netboot(installation=installation, service=u'testdata')
     wait_for_commands_to_finish(system, timeout=(2 * get_conf().get('SLEEP_TIME')
             + get_conf().get('IMAGE_FETCH_TIMEOUT')))
     self.assertEquals(system.command_queue[0].action, u'configure_netboot')
     self.assertEquals(system.command_queue[0].status, CommandStatus.failed)
     self.assertIn(u'timed out', system.command_queue[0].new_value)
Exemplo n.º 3
0
 def test_system_not_marked_broken_for_missing_distro_tree_images(self):
     with session.begin():
         lc = self.get_lc()
         system = data_setup.create_system(arch=u'x86_64',
                                           lab_controller=lc,
                                           status=SystemStatus.automated)
         self.addCleanup(self.cleanup_system, system)
         distro_tree = data_setup.create_distro_tree(
             arch=u'x86_64',
             lab_controllers=[lc],
             urls=['http://localhost:19998/error/404/'])
         installation = Installation(distro_tree=distro_tree,
                                     system=system,
                                     kernel_options=u'')
         system.configure_netboot(installation=installation,
                                  service=u'testdata')
     wait_for_commands_to_finish(system,
                                 timeout=(2 * get_conf().get('SLEEP_TIME')))
     self.assertEquals(system.command_queue[0].action, u'configure_netboot')
     self.assertEquals(system.command_queue[0].status, CommandStatus.failed)
     self.assertEquals(system.status, SystemStatus.automated)