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


Python model.Job类代码示例

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


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

示例1: test_recipe_running_then_cancelled

 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,代码行数:27,代码来源:test_update_status.py

示例2: create_job_for_recipes

def create_job_for_recipes(recipes, owner=None, whiteboard=None, cc=None,product=None,
        retention_tag=None, group=None, submitter=None, priority=None, **kwargs):
    if retention_tag is None:
        retention_tag = RetentionTag.by_tag(u'scratch') # Don't use default, unpredictable
    else:
        retention_tag = RetentionTag.by_tag(retention_tag)

    if owner is None:
        owner = create_user()
    if whiteboard is None:
        whiteboard = unique_name(u'job %s')
    job = Job(whiteboard=whiteboard, ttasks=sum(r.ttasks for r in recipes),
        owner=owner, retention_tag=retention_tag, group=group, product=product,
        submitter=submitter)
    if cc is not None:
        job.cc = cc
    if priority is None:
        priority = TaskPriority.default_priority()
    recipe_set = RecipeSet(ttasks=sum(r.ttasks for r in recipes),
            priority=priority)
    recipe_set.recipes.extend(recipes)
    job.recipesets.append(recipe_set)
    session.add(job)
    session.flush()
    log.debug('Created %s', job.t_id)
    return job
开发者ID:sujithshankar,项目名称:beaker,代码行数:26,代码来源:data_setup.py

示例3: _remove

    def _remove(self, user, method, **kw):

        if user == identity.current.user:
            raise BX(_('You cannot remove yourself'))

        # cancel all running and queued jobs
        Job.cancel_jobs_by_user(user, 'User %s removed' % user.user_name)

        # Return all systems in use by this user
        for system in System.query.filter(System.user==user):
            reservation = system.open_reservation
            system.unreserve(reservation=reservation, service=method, user=user)
        # Return all loaned systems in use by this user
        for system in System.query.filter(System.loaned==user):
            system.record_activity(user=identity.current.user, service=method,
                    action=u'Changed', field=u'Loaned To',
                    old=u'%s' % system.loaned, new=u'None')
            system.loaned = None
        # Change the owner to the caller
        for system in System.query.filter(System.owner==user):
            system.owner = identity.current.user
            system.record_activity(user=identity.current.user, service=method,
                    action=u'Changed', field=u'Owner',
                    old=u'%s' % user, new=u'%s' % identity.current.user)
        # Finally remove the user
        user.removed=datetime.utcnow()
开发者ID:omps,项目名称:beaker,代码行数:26,代码来源:user.py

示例4: test_recipe_running_then_watchdog_expired

 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,代码行数:25,代码来源:test_update_status.py

示例5: test_task_aborted_return_reservation

 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,代码行数:25,代码来源:test_update_status.py

示例6: test_02_abort_dead_recipes

 def test_02_abort_dead_recipes(self):
     beakerd.process_new_recipes()
     beakerd.update_dirty_jobs()
     beakerd.queue_processed_recipesets()
     beakerd.update_dirty_jobs()
     with session.begin():
         self.assertEqual(Job.by_id(self.job2.id).status, TaskStatus.queued)
         # Remove distro_tree2 from lab1, should cause remaining recipe to abort.
         for lca in self.distro_tree2.lab_controller_assocs[:]:
             session.delete(lca)
     beakerd.abort_dead_recipes()
     beakerd.update_dirty_jobs()
     with session.begin():
         self.assertEqual(Job.by_id(self.job2.id).status, TaskStatus.aborted)
开发者ID:sujithshankar,项目名称:beaker,代码行数:14,代码来源:test_deadrecipes.py

示例7: test_get_system_with_running_hardware_scan_recipe

 def test_get_system_with_running_hardware_scan_recipe(self):
     # The bug was a circular reference from system -> recipe -> system
     # which caused JSON serialization to fail.
     with session.begin():
         Job.inventory_system_job(data_setup.create_distro_tree(), owner=self.owner, system=self.system)
         recipe = self.system.find_current_hardware_scan_recipe()
         data_setup.mark_recipe_running(recipe, system=self.system)
     response = requests.get(
         get_server_base() + "/systems/%s/" % self.system.fqdn, headers={"Accept": "application/json"}
     )
     response.raise_for_status()
     in_progress_scan = response.json()["in_progress_scan"]
     self.assertEquals(in_progress_scan["recipe_id"], recipe.id)
     self.assertEquals(in_progress_scan["status"], u"Running")
     self.assertEquals(in_progress_scan["job_id"], recipe.recipeset.job.t_id)
开发者ID:beaker-project,项目名称:beaker,代码行数:15,代码来源:test_systems.py

示例8: test_remove_user_job_cancel

    def test_remove_user_job_cancel(self):
        with session.begin():
            user = data_setup.create_user(user_name =
                                          data_setup.unique_name('aaaaa%s'))
            job = data_setup.create_job(owner=user)
            data_setup.mark_job_running(job)

        b = self.browser
        login(b)
        b.get(get_server_base() + 'users')
        b.find_element_by_xpath('//a[@href="remove?id=%d"]' %user.user_id).click()
        # XXX: not necessary, but doing it here to buy time, since sometimes the
        # job cancellation seems to take a while
        logout(b)

        # reflect the change in recipe task status when
        # update_dirty_jobs() is called
        session.expunge_all()
        beakerd.update_dirty_jobs()

        with session.begin():
            job = Job.by_id(job.id)
            self.assertEquals(job.status, TaskStatus.cancelled)
            self.assertIn('User %s removed' % user.user_name,
                          job.recipesets[0].recipes[0].tasks[0].results[0].log)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:25,代码来源:test_remove_user.py

示例9: test_job_group

    def test_job_group(self):
        with session.begin():
            user_in_group = data_setup.create_user(password='password')
            group = data_setup.create_group()
            user_in_group.groups.append(group)
            user_not_in_group = data_setup.create_user(password='password')

        # Test submitting on behalf of user's group
        config1 = create_client_config(username=user_in_group.user_name,
            password='password')
        out = run_client(['bkr', 'workflow-simple', '--random',
                '--arch', self.distro_tree.arch.arch,
                '--family', self.distro.osversion.osmajor.osmajor,
                '--job-group', group.group_name,
                '--task', self.task.name], config=config1)
        self.assertTrue(out.startswith('Submitted:'), out)
        m = re.search('J:(\d+)', out)
        job_id = m.group(1)
        with session.begin():
            job = Job.by_id(job_id)
        self.assertEqual(group, job.group)

        # Test submitting on behalf of group user does not belong to
        config2 = create_client_config(username=user_not_in_group.user_name,
            password='password')
        try:
            out2 = run_client(['bkr', 'workflow-simple', '--random',
                    '--arch', self.distro_tree.arch.arch,
                    '--family', self.distro.osversion.osmajor.osmajor,
                    '--job-group', group.group_name,
                    '--task', self.task.name], config=config2)
            fail('should raise')
        except ClientError, e:
            self.assertTrue('You are not a member of the %s group' % \
                group.group_name in e.stderr_output, e)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:35,代码来源:test_workflow_simple.py

示例10: test_export_xml

 def test_export_xml(self):
     b = self.browser
     # Make sure the Export button is present in the jobs grid. We can't 
     # actually click it because it triggers a download, which WebDriver 
     # can't handle.
     b.get(get_server_base() + 'jobs/')
     b.find_element_by_name('simplesearch').send_keys(unicode(self.job_to_export.id))
     b.find_element_by_name('jobsearch_simple').submit()
     b.find_element_by_xpath(
             '//tr[normalize-space(string(./td[1]))="%s"]'
             '//a[text()="Export"]'
             % self.job_to_export.t_id)
     # Make sure the Export button is present on the job page.
     b.get(get_server_base() + 'jobs/%s' % self.job_to_export.id)
     b.find_element_by_link_text('Export')
     # Fetch the exported XML directly.
     response = requests.get(get_server_base() +
             'to_xml?taskid=%s&pretty=False' % self.job_to_export.t_id)
     xml_export = response.content
     with session.begin():
         job = Job.by_id(self.job_to_export.id)
         xml_export = job.to_xml().toxml()
         xml_export_tree = lxml.etree.parse(StringIO(xml_export))
         pretty_xml = lxml.etree.tostring(xml_export_tree, pretty_print=False)
         self.assert_(pretty_xml == xml_export)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:25,代码来源:test_job_export_xml.py

示例11: test_ignore_missing_tasks

 def test_ignore_missing_tasks(self):
     job_tid = self.server.jobs.upload('''
         <job>
             <whiteboard>job with nonexistent task</whiteboard>
             <recipeSet>
                 <recipe>
                     <distroRequires>
                         <distro_name op="=" value="BlueShoeLinux5-5" />
                     </distroRequires>
                     <hostRequires/>
                     <task name="/distribution/install" />
                     <task name="/asdf/notexist" />
                     <task name="/distribution/reservesys" />
                 </recipe>
             </recipeSet>
         </job>
         ''',
         True # ignore_missing_tasks
     )
     self.assert_(job_tid.startswith('J:'))
     with session.begin():
         job = Job.by_id(int(job_tid[2:]))
         self.assertEqual(job.ttasks, 2) # not 3
         recipe = job.recipesets[0].recipes[0]
         self.assertEqual(len(recipe.tasks), 2)
         self.assertEqual(recipe.tasks[0].task.name, u'/distribution/install')
         # /asdf/notexist is silently dropped
         self.assertEqual(recipe.tasks[1].task.name, u'/distribution/reservesys')
开发者ID:omps,项目名称:beaker,代码行数:28,代码来源:test_jobs_xmlrpc.py

示例12: clone

 def clone(self, job_id=None, recipe_id=None, recipeset_id=None,
         textxml=None, filexml=None, confirmed=False, **kw):
     """
     Review cloned xml before submitting it.
     """
     title = 'Clone Job'
     if job_id:
         # Clone from Job ID
         title = 'Clone Job %s' % job_id
         try:
             job = Job.by_id(job_id)
         except InvalidRequestError:
             flash(_(u"Invalid job id %s" % job_id))
             redirect(".")
         textxml = job.to_xml(clone=True).toprettyxml()
     elif recipeset_id:
         title = 'Clone Recipeset %s' % recipeset_id
         try:
             recipeset = RecipeSet.by_id(recipeset_id)
         except InvalidRequestError:
             flash(_(u"Invalid recipeset id %s" % recipeset_id))
             redirect(".")
         textxml = recipeset.to_xml(clone=True,from_job=False).toprettyxml()
     elif isinstance(filexml, cgi.FieldStorage):
         # Clone from file
         try:
             textxml = filexml.value.decode('utf8')
         except UnicodeDecodeError, e:
             flash(_(u'Invalid job XML: %s') % e)
             redirect('.')
开发者ID:ustbgaofan,项目名称:beaker,代码行数:30,代码来源:jobs.py

示例13: doit

def doit():
    distro_trees = []
    for id in request.form.getlist('distro_tree_id'):
        try:
            distro_trees.append(DistroTree.by_id(id))
        except NoResultFound:
            raise BadRequest400('Distro tree %r does not exist' % id)
    job_details = {}
    job_details['pick'] = request.form.get('pick') or 'auto'
    if job_details['pick'] == 'fqdn':
        try:
            job_details['system'] = System.by_fqdn(request.form.get('system'),
                    identity.current.user)
        except NoResultFound:
            raise BadRequest400('System %s not found' % request.form.get('system'))
    elif job_details['pick'] == 'lab':
        try:
            job_details['lab'] = LabController.by_name(request.form.get('lab'))
        except NoResultFound:
            raise BadRequest400('Lab controller %s not found' % request.form.get('lab'))
    days = int(request.form.get('reserve_days') or DEFAULT_RESERVE_DAYS)
    days = min(days, MAX_DAYS_PROVISION)
    job_details['reservetime'] = days * 24 * 60 * 60
    job_details['whiteboard'] = request.form.get('whiteboard')
    job_details['ks_meta'] = request.form.get('ks_meta')
    job_details['koptions'] = request.form.get('koptions')
    job_details['koptions_post'] = request.form.get('koptions_post')
    with convert_internal_errors():
        job = Job.provision_system_job(distro_trees, **job_details)
    return 'Created %s' % job.t_id, 201, [('Location', absolute_url('/jobs/%s' % job.id))]
开发者ID:ShaolongHu,项目名称:beaker,代码行数:30,代码来源:reserve_workflow.py

示例14: update

 def update(self, id, **kw):
     # XXX Thus function is awkward and needs to be cleaned up.
     try:
         job = Job.by_id(id)
     except InvalidRequestError:
         raise cherrypy.HTTPError(status=400, message='Invalid job id %s' % id)
     if not job.can_change_product(identity.current.user) or not \
         job.can_change_retention_tag(identity.current.user):
         raise cherrypy.HTTPError(status=403,
                 message="You don't have permission to update job id %s" % id)
     returns = {'success' : True, 'vars':{}}
     if 'retentiontag' in kw and 'product' in kw:
         retention_tag = RetentionTag.by_id(kw['retentiontag'])
         if int(kw['product']) == ProductWidget.product_deselected:
             product = None
         else:
             product = Product.by_id(kw['product'])
         returns.update(Utility.update_retention_tag_and_product(job,
                 retention_tag, product))
     elif 'retentiontag' in kw:
         retention_tag = RetentionTag.by_id(kw['retentiontag'])
         returns.update(Utility.update_retention_tag(job, retention_tag))
     elif 'product' in kw:
         if int(kw['product']) == ProductWidget.product_deselected:
             product = None
         else:
             product = Product.by_id(kw['product'])
         returns.update(Utility.update_product(job, product))
     if 'whiteboard' in kw:
         job.whiteboard = kw['whiteboard']
     return returns
开发者ID:ustbgaofan,项目名称:beaker,代码行数:31,代码来源:jobs.py

示例15: run

 def run(self):
     session.begin()
     recipe = Job.by_id(job.id).recipesets[0].recipes[0]
     assert not recipe.watchdog
     assert not recipe.resource
     recipe.recipeset.cancel()
     self.ready_evt.set()
     self.continue_evt.wait()
     session.commit()
开发者ID:ShaolongHu,项目名称:beaker,代码行数:9,代码来源:test_update_status.py


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