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


Python model.RecipeTask类代码示例

本文整理汇总了Python中bkr.server.model.RecipeTask的典型用法代码示例。如果您正苦于以下问题:Python RecipeTask类的具体用法?Python RecipeTask怎么用?Python RecipeTask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create_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
开发者ID:sujithshankar,项目名称:beaker,代码行数:26,代码来源:data_setup.py

示例2: setUp

 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)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:9,代码来源:test_proxy.py

示例3: _get_recipe_task_by_id

def _get_recipe_task_by_id(recipeid, taskid):
    try:
        task = RecipeTask.by_id(taskid)
    except NoResultFound:
        raise NotFound404('Recipe task not found')
    if recipeid != '_' and str(task.recipe.id) != recipeid:
        raise NotFound404('Recipe task not found')
    return task
开发者ID:beaker-project,项目名称:beaker,代码行数:8,代码来源:recipetasks.py

示例4: watchdog

 def watchdog(self, task_id):
     """
     Returns number of seconds left on task_id watchdog, or False if it doesn't exist.
     """
     try:
         task = RecipeTask.by_id(task_id)
     except InvalidRequestError:
         raise BX(_('Invalid task ID: %s' % task_id))
     return task.status_watchdog()
开发者ID:ShaolongHu,项目名称:beaker,代码行数:9,代码来源:recipetasks.py

示例5: extend

 def extend(self, task_id, kill_time):
     """
     Extend tasks watchdog by kill_time seconds
     """
     try:
         task = RecipeTask.by_id(task_id)
     except InvalidRequestError:
         raise BX(_('Invalid task ID: %s' % task_id))
     return task.extend(kill_time)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:9,代码来源:recipetasks.py

示例6: start

 def start(self, task_id, watchdog_override=None):
     """
     Set task status to Running
     """
     try:
         task = RecipeTask.by_id(task_id)
     except InvalidRequestError:
         raise BX(_('Invalid task ID: %s' % task_id))
     return task.start(watchdog_override)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:9,代码来源:recipetasks.py

示例7: create_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 task_list: #don't specify a task_list and a task_name...
        for t in task_list:
            rt = RecipeTask(task=t)
            rt.role = u'STANDALONE'
            recipe.tasks.append(rt)
    else:
        rt = RecipeTask(task=create_task(name=task_name))
        rt.role = u'STANDALONE'
        recipe.tasks.append(rt)
    return recipe
开发者ID:sibiaoluo,项目名称:beaker,代码行数:21,代码来源:data_setup.py

示例8: result

 def result(self, task_id, result_type, path=None, score=None, summary=None):
     """
     Record a Result
     """
     try:
         task = RecipeTask.by_id(task_id)
     except InvalidRequestError:
         raise BX(_('Invalid task ID: %s' % task_id))
     if result_type not in task.result_types:
         raise BX(_('Invalid result_type: %s, must be one of %s' %
                          (result_type, task.result_types)))
     kwargs = dict(path=path, score=score, summary=summary)
     return getattr(task,result_type)(**kwargs)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:13,代码来源:recipetasks.py

示例9: stop

 def stop(self, task_id, stop_type, msg=None):
     """
     Set task status to Completed
     """
     try:
         task = RecipeTask.by_id(task_id)
     except InvalidRequestError:
         raise BX(_('Invalid task ID: %s' % task_id))
     if stop_type not in task.stop_types:
         raise BX(_('Invalid stop_type: %s, must be one of %s' %
                          (stop_type, task.stop_types)))
     kwargs = dict(msg = msg)
     return getattr(task,stop_type)(**kwargs)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:13,代码来源:recipetasks.py

示例10: update

 def update(self, task_id, data):
     """
     XML-RPC method used by the lab controller harness API to update 
     a recipe-task's attributes.
     """
     try:
         task = RecipeTask.by_id(task_id)
     except InvalidRequestError:
         raise BX(_('Invalid task ID: %s' % task_id))
     if 'name' in data:
         task.name = data['name']
     if 'version' in data:
         task.version = data['version']
     return task.__json__()
开发者ID:sujithshankar,项目名称:beaker,代码行数:14,代码来源:recipetasks.py

示例11: register_result_file

    def register_result_file(self, server, result_id, path, filename, basepath):
        """
        register file and return path to store
        """
        try:
            result = RecipeTaskResult.by_id(result_id, lockmode='update')
        except NoResultFound:
            raise BX(_('Invalid result ID: %s' % result_id))
        RecipeTask.by_id(result.recipe_task_id, lockmode='update')
        Recipe.by_id(result.recipetask.recipe_id, lockmode='update')
        if result.recipetask.is_finished():
            raise BX('Cannot register file for finished task %s'
                    % result.recipetask.t_id)
        self._check_log_limit(result.recipetask)

        log_recipe = LogRecipeTaskResult.lazy_create(recipe_task_result_id=result.id,
                                                     path=path, 
                                                     filename=filename,
                                                    )
        log_recipe.server = server
        log_recipe.basepath = basepath
        result.recipetask.recipe.log_server = urlparse.urlparse(server)[1]
        return '%s' % result.filepath
开发者ID:beaker-project,项目名称:beaker,代码行数:23,代码来源:recipetasks.py

示例12: create_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
开发者ID:beaker-project,项目名称:beaker,代码行数:48,代码来源:data_setup.py

示例13: register_file

    def register_file(self, server, task_id, path, filename, basepath):
        """
        register file and return path to store
        """
        try:
            recipetask = RecipeTask.by_id(task_id)
        except InvalidRequestError:
            raise BX(_('Invalid task ID: %s' % task_id))
        if recipetask.is_finished():
            raise BX('Cannot register file for finished task %s'
                    % recipetask.t_id)

        # Add the log to the DB if it hasn't been recorded yet.
        log_recipe = LogRecipeTask.lazy_create(recipe_task_id=recipetask.id,
                                               path=path, 
                                               filename=filename,
                                              )
        log_recipe.server = server
        log_recipe.basepath = basepath
        recipetask.recipe.log_server = urlparse.urlparse(server)[1]
        return '%s' % recipetask.filepath
开发者ID:ShaolongHu,项目名称:beaker,代码行数:21,代码来源:recipetasks.py

示例14: peer_roles

 def peer_roles(self, task_id):
     try:
         task = RecipeTask.by_id(task_id)
     except NoResultFound:
         raise BX(_('Invalid task ID: %s') % task_id)
     # don't use set, we want to preserve ordering
     roles = {}
     for role, recipes in task.recipe.peer_roles().iteritems():
         fqdns = roles.setdefault(unicode(role), [])
         for recipe in recipes:
             if not recipe.resource or not recipe.resource.fqdn:
                 continue
             fqdn = unicode(recipe.resource.fqdn)
             if fqdn not in fqdns:
                 fqdns.append(fqdn)
     for role, tasks in task.peer_roles().iteritems():
         fqdns = roles.setdefault(unicode(role), [])
         for task in tasks:
             if not task.recipe.resource or not task.recipe.resource.fqdn:
                 continue
             fqdn = unicode(task.recipe.resource.fqdn)
             if fqdn not in fqdns:
                 fqdns.append(fqdn)
     return roles
开发者ID:ShaolongHu,项目名称:beaker,代码行数:24,代码来源:recipetasks.py

示例15: hasattr

            recipe.ks_appends.append(RecipeKSAppend(ks_append=xmlksappend))
        xmltasks = []
        invalid_tasks = []
        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)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:32,代码来源:jobs.py


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