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


Python model.System类代码示例

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


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

示例1: query

 def query(cls):        
     for key_int in System.permissable_systems(Key_Value_Int.query.outerjoin('system','user')):
         if key_int.system:
             yield CSV_KeyValue(key_int)
     for key_string in System.permissable_systems(Key_Value_String.query.outerjoin('system','user')):
         if key_string.system:
             yield CSV_KeyValue(key_string)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:7,代码来源:CSV_import_export.py

示例2: add_system

def add_system():
    # We accept JSON or form-encoded for convenience
    if request.json:
        if 'fqdn' not in request.json:
            raise BadRequest400('Missing fqdn key')
        new_fqdn = request.json['fqdn']
    elif request.form:
        if 'fqdn' not in request.form:
            raise BadRequest400('Missing fqdn parameter')
        new_fqdn = request.form['fqdn']
    else:
        raise UnsupportedMediaType415
    with convert_internal_errors():
        if System.query.filter(System.fqdn == new_fqdn).count() != 0:
            raise Conflict409('System with fqdn %r already exists' % new_fqdn)
        system = System(fqdn=new_fqdn, owner=identity.current.user)
        session.add(system)
        # new systems are visible to everybody by default
        system.custom_access_policy = SystemAccessPolicy()
        system.custom_access_policy.add_rule(SystemPermission.view,
                everybody=True)
    # XXX this should be 201 with Location: /systems/FQDN/ but 302 is more 
    # convenient because it lets us use a traditional browser form without AJAX 
    # handling, and for now we're redirecting to /view/FQDN until that is moved 
    # to /systems/FQDN/
    return flask_redirect(url(u'/view/%s#essentials' % system.fqdn))
开发者ID:sujithshankar,项目名称:beaker,代码行数:26,代码来源:systems.py

示例3: remove

    def remove(self, id, *args, **kw):
        labcontroller = LabController.by_id(id)
        labcontroller.removed = datetime.utcnow()
        # de-associate systems
        systems = System.query.filter(System.lab_controller == labcontroller)
        System.record_bulk_activity(systems, user=identity.current.user,
                service=u'WEBUI', action=u'Changed', field=u'lab_controller',
                old=labcontroller.fqdn, new=None)
        systems.update({'lab_controller_id': None}, synchronize_session=False)
        # cancel running recipes
        watchdogs = Watchdog.by_status(labcontroller=labcontroller, 
            status='active')
        for w in watchdogs:
            w.recipe.recipeset.job.cancel(msg='LabController %s has been deleted' % labcontroller.fqdn)
        # remove distro trees
        distro_tree_assocs = LabControllerDistroTree.query\
            .filter(LabControllerDistroTree.lab_controller == labcontroller)\
            .join(LabControllerDistroTree.distro_tree)
        DistroTree.record_bulk_activity(distro_tree_assocs, user=identity.current.user,
                service=u'WEBUI', action=u'Removed', field=u'lab_controller_assocs',
                old=labcontroller.fqdn, new=None)
        distro_tree_assocs.delete(synchronize_session=False)
        labcontroller.disabled = True
        labcontroller.record_activity(user=identity.current.user, service=u'WEBUI',
                field=u'Disabled', action=u'Changed', old=unicode(False), new=unicode(True))
        labcontroller.record_activity(user=identity.current.user, service=u'WEBUI',
                field=u'Removed', action=u'Changed', old=unicode(False), new=unicode(True))

        flash( _(u"%s removed") % labcontroller.fqdn )
        raise redirect(".")
开发者ID:ShaolongHu,项目名称:beaker,代码行数:30,代码来源:labcontroller.py

示例4: 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

示例5: test_creating_a_system_with_power_settings

 def test_creating_a_system_with_power_settings(self):
     s = requests.Session()
     s.post(get_server_base() + 'login', data={'user_name': self.user.user_name,
                                               'password': u'password'}).raise_for_status()
     fqdn = data_setup.unique_name(u'newsystem%s')
     data = {
         'fqdn': fqdn,
         'lab_controller_id': self.lc.id,
         'power_type': u'apc_snmp_then_etherwake',
         'power_address': u'dummyaddress',
         'power_user': u'dummyuser',
         'power_password': u'dummypassword',
         'power_id': u'dummyvm',
         'power_quiescent_period': 5,
         'release_action': u'LeaveOn',
         'reprovision_distro_tree': {'id': self.distro_tree.id},
     }
     response = post_json(get_server_base() + 'systems/', session=s, data=data)
     with session.begin():
         system = System.by_fqdn(fqdn, self.user)
         self.assertEquals(system.power.power_type, PowerType.by_name(u'apc_snmp_then_etherwake'))
         self.assertEquals(system.power.power_address, u'dummyaddress')
         self.assertEquals(system.power.power_user, u'dummyuser')
         self.assertEquals(system.power.power_passwd, u'dummypassword')
         self.assertEquals(system.power.power_id, u'dummyvm')
         self.assertEquals(system.power.power_quiescent_period, 5)
         self.assertEquals(system.release_action, ReleaseAction.leave_on)
         self.assertEquals(system.reprovision_distro_tree, self.distro_tree)
开发者ID:beaker-project,项目名称:beaker,代码行数:28,代码来源:test_add_system.py

示例6: test_power_quiescent_period_statefulness_not_elapsed

 def test_power_quiescent_period_statefulness_not_elapsed(self):
     if daemons_running_externally():
         raise SkipTest('cannot examine logs of remote beaker-provision')
     provision_process, = [p for p in processes if p.name == \
         'beaker-provision']
     # Initial lookup of this system will reveal no state, so will delay
     # for the whole quiescent period
     try:
         provision_process.start_output_capture()
         with session.begin():
             system = data_setup.create_system(lab_controller=self.get_lc())
             system.power.power_type = PowerType.lazy_create(name=u'dummy')
             system.power.power_quiescent_period = 1
             system.power.power_id = u'' # make power script not sleep
             system.power.delay_until = None
             system.action_power(action=u'off', service=u'testdata')
         wait_for_commands_to_finish(system, timeout=10)
     finally:
         provision_output = provision_process.finish_output_capture()
     self.assertIn('Entering quiescent period, delaying 1 seconds for '
         'command %s'  % system.command_queue[0].id, provision_output)
     # Increase the quiescent period, to ensure we enter it
     try:
         provision_process.start_output_capture()
         with session.begin():
             system = System.by_id(system.id, User.by_user_name('admin'))
             system.power.power_quiescent_period = 10
             system.action_power(action=u'on', service=u'testdata')
         wait_for_commands_to_finish(system, timeout=15)
     finally:
         provision_output = provision_process.finish_output_capture()
     self.assertIn('Entering quiescent period', provision_output)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:32,代码来源:test_provision.py

示例7: test_lookup_secret_fqdn

 def test_lookup_secret_fqdn(self):
     with session.begin():
         system = data_setup.create_system()
         system.private = True
     lab_controller_user = LabController.by_name(self.lc_fqdn).user
     system2 = System.by_fqdn(str(system.fqdn), user=lab_controller_user)
     self.assertEquals(system, system2)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:7,代码来源:test_lab_controller.py

示例8: test_creating_a_system_with_hardware_details

 def test_creating_a_system_with_hardware_details(self):
     s = requests.Session()
     s.post(get_server_base() + 'login', data={'user_name': self.user.user_name,
                                               'password': u'password'}).raise_for_status()
     fqdn = data_setup.unique_name(u'newsystem%s')
     data = {
         'fqdn': fqdn,
         'hypervisor': u'KVM',
         'vendor': u'dummyvendor',
         'location': u'dummylocation',
         'model': u'dummymodel',
         'serial_number': u'dummynumber',
         'mac_address': u'dummymacaddress',
         'memory': 111111,
         'numa_nodes': 5,
     }
     response = post_json(get_server_base() + 'systems/', session=s, data=data)
     with session.begin():
         system = System.by_fqdn(fqdn, self.user)
         self.assertEquals(system.fqdn, fqdn)
         self.assertEquals(system.hypervisor, Hypervisor.by_name(u'KVM'))
         self.assertEquals(system.location, u'dummylocation')
         self.assertEquals(system.serial, u'dummynumber')
         self.assertEquals(system.mac_address, u'dummymacaddress')
         self.assertEquals(system.memory, 111111)
         self.assertEquals(system.numa.nodes, 5)
开发者ID:beaker-project,项目名称:beaker,代码行数:26,代码来源:test_add_system.py

示例9: test_create_system_set_host_hypervisor

 def test_create_system_set_host_hypervisor(self):
     fqdn = data_setup.unique_name(u'mysystem%s')
     run_client(['bkr', 'system-create', fqdn,
                 '--host-hypervisor=KVM'])
     with session.begin():
         system = System.by_fqdn(fqdn, User.by_user_name(u'admin'))
         self.assertEquals(str(system.hypervisor), u'KVM')
         self.assertEquals(system.activity[0].new_value, u'KVM')
开发者ID:beaker-project,项目名称:beaker,代码行数:8,代码来源:test_system_create.py

示例10: test_create_system_set_labcontroller

 def test_create_system_set_labcontroller(self):
     fqdn = data_setup.unique_name(u'mysystem%s')
     lc = data_setup.create_labcontroller()
     run_client(['bkr', 'system-create',
                 '--lab-controller', str(lc.fqdn),
                 fqdn])
     with session.begin():
         system = System.by_fqdn(fqdn, User.by_user_name(u'admin'))
         self.assertTrue(system.lab_controller, lc)
开发者ID:beaker-project,项目名称:beaker,代码行数:9,代码来源:test_system_create.py

示例11: reserve

    def reserve(self, distro_tree_id, system_id=None, lab_controller_id=None):
        """ Either queue or provision the system now """
        if system_id == 'search':
            redirect('/reserve_system', distro_tree_id=distro_tree_id)
        elif system_id:
            try:
                system = System.by_id(system_id, identity.current.user)
            except InvalidRequestError:
                flash(_(u'Invalid System ID %s' % system_id))
            system_name = system.fqdn
        else:
            system_name = 'Any System'
        distro_names = [] 

        return_value = dict(
                            system_id = system_id, 
                            system = system_name,
                            distro = '',
                            distro_tree_ids = [],
                            )
        warn = None
        if not isinstance(distro_tree_id, list):
            distro_tree_id = [distro_tree_id]
        for id in distro_tree_id:
            try:
                distro_tree = DistroTree.by_id(id)
                if System.by_type(type=SystemType.machine,
                        systems=distro_tree.systems(user=identity.current.user))\
                        .count() < 1:
                    warn = _(u'No systems compatible with %s') % distro_tree
                distro_names.append(unicode(distro_tree))
                return_value['distro_tree_ids'].append(id)
            except NoResultFound:
                flash(_(u'Invalid distro tree ID %s') % id)
        distro = ", ".join(distro_names)
        return_value['distro'] = distro
        
        return dict(form=self.reserveform,
                    action='./doit',
                    value = return_value,
                    warn=warn,
                    options = None,
                    title='Reserve %s' % system_name)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:43,代码来源:reserve_workflow.py

示例12: test_create_system_set_arches

 def test_create_system_set_arches(self):
     fqdn = data_setup.unique_name(u'mysystem%s')
     run_client(['bkr', 'system-create',
                 '--arch', u'i386',
                 '--arch', u'x86_64',
                 fqdn])
     with session.begin():
         system = System.by_fqdn(fqdn, User.by_user_name(u'admin'))
         self.assertIn(Arch.by_name(u'i386'), system.arch)
         self.assertIn(Arch.by_name(u'x86_64'), system.arch)
开发者ID:beaker-project,项目名称:beaker,代码行数:10,代码来源:test_system_create.py

示例13: clear_netboot_form

    def clear_netboot_form(self, fqdn):
        """Queues the clear netboot commands

        Enqueues the command to clear any netboot configuration for this
        system, and on success redirects to the system page.
        """
        system = System.by_fqdn(fqdn, identity.current.user)
        system.clear_netboot(service=u'WEBUI')
        flash(_(u'Clear netboot command enqueued'))
        redirect(u'../view/%s' % fqdn)
开发者ID:sibiaoluo,项目名称:beaker,代码行数:10,代码来源:systems.py

示例14: clear_netboot

    def clear_netboot(self, fqdn):
        """
        Clears any netboot configuration in effect for the system with the
        given fully-qualified domain name.

        .. verisonadded:: 0.9
        """
        system = System.by_fqdn(fqdn, identity.current.user)
        system.clear_netboot(service=u'XMLRPC')
        return system.fqdn # because turbogears makes us return something
开发者ID:sibiaoluo,项目名称:beaker,代码行数:10,代码来源:systems.py

示例15: update_loan

    def update_loan(self, fqdn=None, loaned=None, loan_comment=None, **kw):
        """Update system loan and loan comment.

        Returns the loanee
        """
        # The formal param 'loaned' is dictated to us by widgets.SystemForm...
        loaning_to = loaned
        system = System.by_fqdn(fqdn, identity.current.user)
        system.change_loan(loaning_to, loan_comment)
        return loaning_to if loaning_to else ''
开发者ID:sibiaoluo,项目名称:beaker,代码行数:10,代码来源:systems.py


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