当前位置: 首页>>代码示例>>Python>>正文


Python Task.by_name方法代码示例

本文整理汇总了Python中bkr.server.model.Task.by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Task.by_name方法的具体用法?Python Task.by_name怎么用?Python Task.by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bkr.server.model.Task的用法示例。


在下文中一共展示了Task.by_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_recipe

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def _create_recipe(self, system=None):
     with session.begin():
         install_task = Task.by_name(u'/distribution/install')
         reserve_task = Task.by_name(u'/distribution/reservesys')
         lc = create_lab_controller()
         rhel62_server_x86_64 = create_rhel62_server_x86_64(lab_controller=lc)
         if not system:
             system = create_x86_64_automated(lc)
         recipe = data_setup.create_recipe(distro_tree=rhel62_server_x86_64, task_list=[install_task, reserve_task])
         data_setup.create_job_for_recipes([recipe], owner=create_user(), whiteboard=u'')
         data_setup.mark_recipe_complete(recipe, system=system)
     self.recipe_id = recipe.id
     return recipe
开发者ID:beaker-project,项目名称:beaker,代码行数:15,代码来源:test_create_kickstart.py

示例2: _create_recipe_with_user_defined_distro

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def _create_recipe_with_user_defined_distro(self, **kwargs):
     with session.begin():
         install_task = Task.by_name(u'/distribution/check-install')
         reserve_task = Task.by_name(u'/distribution/reservesys')
         lc = create_lab_controller()
         system = create_x86_64_automated(lc)
         recipe = data_setup.create_recipe(custom_distro=True, osmajor=kwargs['osmajor'],
                                           task_list=[install_task, reserve_task]) if \
             'osmajor' in kwargs else data_setup.create_recipe(custom_distro=True, task_list=[install_task, reserve_task])
         data_setup.create_job_for_recipes([recipe], owner=create_user(), whiteboard=u'')
         data_setup.mark_recipe_complete(recipe, system=system)
     self.recipe_id = recipe.id
     return recipe
开发者ID:beaker-project,项目名称:beaker,代码行数:15,代码来源:test_create_kickstart.py

示例3: default

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def default(self, *args, **kw):
     try:
         using_task_id = False
         if len(args) == 1:
             try:
                 task_id = int(args[0])
                 using_task_id = True
             except ValueError:
                 pass
         if using_task_id:
             task = Task.by_id(task_id)
         else:
             task = Task.by_name("/%s" % "/".join(args))
             #Would rather not redirect but do_search expects task_id in URL
             #This is the simplest way of dealing with it
             redirect("/tasks/%s" % task.id)
     except InvalidRequestError:
         if using_task_id:
             err_msg = u'Invalid task_id %s' % args[0]
         else:
             err_msg =  u'Invalid task /%s' % '/'.join(args)
         flash(_(err_msg))
         redirect("/tasks")
     return dict(task=task,
                 form = self.task_form,
                 value = dict(task_id = task.id),
                 options = dict(hidden=dict(task = 1)),
                 action = './do_search')
开发者ID:ustbgaofan,项目名称:beaker,代码行数:30,代码来源:tasks.py

示例4: default

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
    def default(self, *args, **kw):
        try:
            using_task_id = False
            if len(args) == 1:
                try:
                    task_id = int(args[0])
                    using_task_id = True
                except ValueError:
                    pass
            if using_task_id:
                task = Task.by_id(task_id)
            else:
                task = Task.by_name("/%s" % "/".join(args))
                #Would rather not redirect but do_search expects task_id in URL
                #This is the simplest way of dealing with it
                redirect("/tasks/%s" % task.id)
        except DatabaseLookupError as e:
            flash(unicode(e))
            redirect("/tasks")

        return dict(task=task,
                    form = self.task_form,
                    value = dict(task_id = task.id),
                    options = dict(hidden=dict(task = 1)),
                    action = './do_search')
开发者ID:omps,项目名称:beaker,代码行数:27,代码来源:tasks.py

示例5: test_recipe_running_then_cancelled

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_recipe_running_then_cancelled(self):
     """ This tests the case where the recipe is running, has a valid
     reservation request, but is cancelled before it's completed.
     """
     with session.begin():
         recipe = data_setup.create_recipe(
             task_list=[Task.by_name(u'/distribution/install')] * 2,
             reservesys=True)
         job = data_setup.create_job_for_recipes([recipe])
         job_id = job.id
         data_setup.mark_recipe_running(recipe)
         data_setup.mark_recipe_installation_finished(recipe)
         # we want at least one task to be Completed here
         # https://bugzilla.redhat.com/show_bug.cgi?id=1195558
         job.recipesets[0].recipes[0].tasks[0].stop()
         job.recipesets[0].recipes[0].tasks[1].start()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.running)
         job.recipesets[0].cancel()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.cancelled)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:29,代码来源:test_update_status.py

示例6: test_recipe_running_then_watchdog_expired

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_recipe_running_then_watchdog_expired(self):
     """ This tests the case where the recipe is running, has a valid
     reservation request, but the watchdog expires before it's
     completed.
     """
     with session.begin():
         recipe = data_setup.create_recipe(
             task_list=[Task.by_name(u'/distribution/install')],
             reservesys=True)
         job = data_setup.create_job_for_recipes([recipe])
         job_id = job.id
         data_setup.mark_recipe_tasks_finished(recipe,
                                               task_status=TaskStatus.aborted)
         job.recipesets[0].recipes[0].abort()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.reserved)
         job.recipesets[0].recipes[0].return_reservation()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                           TaskStatus.aborted)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:27,代码来源:test_update_status.py

示例7: test_task_aborted_return_reservation

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_task_aborted_return_reservation(self):
     """ This tests the case where the task was aborted, then
     the recipe goes to Reserved state and then finally the reservation
     is returned
     """
     with session.begin():
         recipe = data_setup.create_recipe(
             task_list=[Task.by_name(u'/distribution/install')],
             reservesys=True)
         job = data_setup.create_job_for_recipes([recipe])
         job_id = job.id
         data_setup.mark_recipe_tasks_finished(recipe, result=TaskResult.warn,
                                               task_status=TaskStatus.aborted)
         job._mark_dirty()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.reserved)
         job.recipesets[0].recipes[0].return_reservation()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.aborted)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:27,代码来源:test_update_status.py

示例8: test_reserved_then_job_cancelled

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_reserved_then_job_cancelled(self):
     """ This tests the case where the recipe is Reserved
     but the job is cancelled
     """
     recipe = data_setup.create_recipe(task_list=[Task.by_name(u"/distribution/install")], reservesys=True)
     job = data_setup.create_job_for_recipes([recipe])
     data_setup.mark_recipe_tasks_finished(recipe)
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.reserved)
     job.cancel()
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.completed)
开发者ID:beaker-project,项目名称:beaker,代码行数:14,代码来源:test_update_status.py

示例9: test_adding_task_with_releases_list

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_adding_task_with_releases_list(self):
     with session.begin():
         OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinux5')
         OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinux6')
     rpm_path = pkg_resources.resource_filename('bkr.inttest.server',
             'task-rpms/tmp-distribution-beaker-dummy_for_bz1422410-1.0-1.noarch.rpm')
     out = run_client(['bkr', 'task-add', rpm_path])
     self.assertIn(u'Success', out)
     with session.begin():
         task = Task.by_name(u'/distribution/beaker/dummy_for_bz1422410')
         self.assertItemsEqual([OSMajor.by_name(u'RedHatEnterpriseLinux5')],
                 task.exclusive_osmajors)
开发者ID:beaker-project,项目名称:beaker,代码行数:14,代码来源:test_task_add.py

示例10: test_reserved_then_watchdog_expired

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_reserved_then_watchdog_expired(self):
     """ This tests the case where the external
     watchdog expires when the recipe is in Reserved state
     """
     recipe = data_setup.create_recipe(task_list=[Task.by_name(u"/distribution/install")], reservesys=True)
     job = data_setup.create_job_for_recipes([recipe])
     data_setup.mark_recipe_tasks_finished(recipe)
     job._mark_dirty()
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.reserved)
     job.recipesets[0].recipes[0].abort()
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.completed)
开发者ID:beaker-project,项目名称:beaker,代码行数:15,代码来源:test_update_status.py

示例11: expiring_reservations

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def expiring_reservations(self):
     """
     Get expiring reservations
     """
     tasks = Task.by_name(u'/distribution/reservesys')
     query = Recipe.query\
         .join(Recipe.recipeset).join(RecipeSet.job).filter(Job.owner == self.user)\
         .join(Recipe.watchdog).join(Watchdog.recipetask)\
         .join(Recipe.resource)\
         .filter(or_(RecipeTask.task == tasks, Recipe.status == TaskStatus.reserved))\
         .filter(Watchdog.kill_time <= (datetime.utcnow() + timedelta(hours=self.reservation_expiry)))\
         .values(Watchdog.kill_time, RecipeResource.fqdn)
     return list(query)
开发者ID:omps,项目名称:beaker,代码行数:15,代码来源:usage_reminder.py

示例12: test_task_aborted_return_reservation

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_task_aborted_return_reservation(self):
     """ This tests the case where the task was aborted, then
     the recipe goes to Reserved state and then finally the reservation
     is returned
     """
     recipe = data_setup.create_recipe(task_list=[Task.by_name(u"/distribution/install")], reservesys=True)
     job = data_setup.create_job_for_recipes([recipe])
     data_setup.mark_recipe_tasks_finished(recipe, result=TaskResult.warn, task_status=TaskStatus.aborted)
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.reserved)
     job.recipesets[0].recipes[0].return_reservation()
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.aborted)
开发者ID:beaker-project,项目名称:beaker,代码行数:15,代码来源:test_update_status.py

示例13: test_recipe_running_then_watchdog_expired

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_recipe_running_then_watchdog_expired(self):
     """ This tests the case where the recipe is running, has a valid
     reservation request, but the watchdog expires before it's
     completed.
     """
     recipe = data_setup.create_recipe(task_list=[Task.by_name(u"/distribution/install")], reservesys=True)
     job = data_setup.create_job_for_recipes([recipe])
     data_setup.mark_recipe_tasks_finished(recipe, task_status=TaskStatus.aborted)
     job.recipesets[0].recipes[0].abort()
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.reserved)
     job.recipesets[0].recipes[0].return_reservation()
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.aborted)
开发者ID:beaker-project,项目名称:beaker,代码行数:16,代码来源:test_update_status.py

示例14: test_reserves_system_when_recipe_waiting

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
 def test_reserves_system_when_recipe_waiting(self):
     recipe = data_setup.create_recipe(task_list=[Task.by_name(u"/distribution/utils/dummy")], reservesys=True)
     job = data_setup.create_job_for_recipes([recipe])
     # Anaconda installs the OS (Status: Installing) and reboots
     # beakerd comes along and calls update_dirty_jobs which sets the recipe to: Waiting
     data_setup.mark_recipe_waiting(recipe)
     # In the meantime however our task has finished really quickly, which
     # means the min_status is TaskStatus.completed and therefore finished
     data_setup.mark_recipe_tasks_finished(recipe, only=True)
     # beakerd hasn't come along and updated our recipe yet, so it's still
     # in waiting
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.waiting)
     # Now beakerd updates it and should reserve our system
     job.update_status()
     self.assertEqual(job.recipesets[0].recipes[0].status, TaskStatus.reserved)
开发者ID:beaker-project,项目名称:beaker,代码行数:17,代码来源:test_update_status.py

示例15: create_recipe

# 需要导入模块: from bkr.server.model import Task [as 别名]
# 或者: from bkr.server.model.Task import by_name [as 别名]
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
开发者ID:beaker-project,项目名称:beaker,代码行数:50,代码来源:data_setup.py


注:本文中的bkr.server.model.Task.by_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。