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


Python Key.by_name方法代码示例

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


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

示例1: test_by_multiple_key_values

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_by_multiple_key_values(self):
     with session.begin():
         self.system = data_setup.create_system()
         self.system.key_values_string.append(Key_Value_String(
             Key.by_name(u'CPUMODEL'), 'foocodename'))
         self.system.key_values_string.append(Key_Value_String(
             Key.by_name(u'HVM'), '1'))
         self.system.key_values_int.append(Key_Value_Int(
             Key.by_name(u'DISKSPACE'), '1024'))
     b = self.browser
     perform_search(b, [('Key/Value', 'HVM', 'is', '1'),
         ('Key/Value', 'CPUMODEL', 'is', 'foocodename'),
         ('Key/Value', 'DISKSPACE', 'greater than', '1000')])
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
开发者ID:beaker-project,项目名称:beaker,代码行数:17,代码来源:test_system_search.py

示例2: test_by_key_value_is_not

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_by_key_value_is_not(self):
     with session.begin():
         self.another_system.key_values_string.append(Key_Value_String(
                 Key.by_name(u'CPUMODEL'), 'foocodename'))
     b = self.browser
     perform_search(b, [('Key/Value', 'CPUMODEL', 'is not', 'foocodename')],
             search_url=u'mine')
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
开发者ID:beaker-project,项目名称:beaker,代码行数:11,代码来源:test_system_search.py

示例3: _from_csv

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
    def _from_csv(cls,system,data,csv_type,log):
        """
        Import data from CSV file into System Objects
        """
        if 'key' in data and data['key']:
            try:
                key = Key.by_name(data['key'])
            except InvalidRequestError:
                log.append('%s: Invalid Key %s ' % (system.fqdn, data['key']))
                return False
        else:
            log.append('%s: Key must not be blank!' % system.fqdn)
            return False
        if 'key_value' in data and data['key_value']:
            if key.numeric:
                system_key_values = system.key_values_int
                try:
                    key_value = Key_Value_Int.by_key_value(system,
                                                           key,
                                                           data['key_value'])
                except InvalidRequestError:
                    key_value = Key_Value_Int(key=key,
                                              key_value=data['key_value'])
            else:
                system_key_values = system.key_values_string
                try:
                    key_value = Key_Value_String.by_key_value(system,
                                                           key,
                                                           data['key_value'])
                except InvalidRequestError:
                    key_value = Key_Value_String(key=key,
                                                 key_value=data['key_value'])
        else:
            log.append('%s: Key Value must not be blank!' % system.fqdn)
            return False
        deleted = False
        if 'deleted' in data:
            deleted = smart_bool(data['deleted'])
        if deleted:
            if key_value in system_key_values:
                system.record_activity(user=identity.current.user, service=u'CSV',
                        action=u'Removed', field=u'Key/Value',
                        old=u'%s/%s' % (data['key'],data['key_value']), new=u'')
                system_key_values.remove(key_value)
                if not key_value.id:
                    session.expunge(key_value)
        else:
            if key_value not in system_key_values:
                system.record_activity(user=identity.current.user, service=u'CSV',
                        action=u'Added', field=u'Key/Value', old=u'',
                        new=u'%s/%s' % (data['key'],data['key_value']))
                system_key_values.append(key_value)

        session.add(key_value)
        return True
开发者ID:ShaolongHu,项目名称:beaker,代码行数:57,代码来源:CSV_import_export.py

示例4: test_xml_filter

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_xml_filter(self):
     with session.begin():
         module_key = Key.by_name(u"MODULE")
         with_module = data_setup.create_system()
         with_module.key_values_string.extend(
             [Key_Value_String(module_key, u"cciss"), Key_Value_String(module_key, u"kvm")]
         )
         without_module = data_setup.create_system()
     out = run_client(["bkr", "list-systems", "--xml-filter", '<key_value key="MODULE" />'])
     returned_systems = out.splitlines()
     self.assert_(with_module.fqdn in returned_systems, returned_systems)
     self.assert_(without_module.fqdn not in returned_systems, returned_systems)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:14,代码来源:test_list_systems.py

示例5: test_by_key_value_is_on_removed_systems_page

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_by_key_value_is_on_removed_systems_page(self):
     with session.begin():
         system = data_setup.create_system()
         removed_system = data_setup.create_system(status=SystemStatus.removed)
         removed_system.key_values_string.append(Key_Value_String(
                 Key.by_name(u'CPUMODEL'), 'foocodename'))
     # Key Value search from "Removed Systems"
     b = self.browser
     perform_search(b, [('Key/Value', 'CPUMODEL', 'is', 'foocodename')],
             search_url='removed')
     check_system_search_results(b, present=[removed_system],
             absent=[system])
开发者ID:beaker-project,项目名称:beaker,代码行数:14,代码来源:test_system_search.py

示例6: test_key_present

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_key_present(self):
     module_key = Key.by_name(u'MODULE')
     with_module = data_setup.create_system()
     with_module.key_values_string.extend([
             Key_Value_String(module_key, u'cciss'),
             Key_Value_String(module_key, u'kvm')])
     without_module = data_setup.create_system()
     self.check_filter("""
         <hostRequires>
             <key_value key="MODULE" op="==" />
         </hostRequires>
         """,
         present=[with_module], absent=[without_module])
开发者ID:omps,项目名称:beaker,代码行数:15,代码来源:test_needpropertyxml.py

示例7: setUpClass

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
    def setUpClass(cls):
        cls.browser = cls.get_browser()
        login(cls.browser)
        cls.system_one_details = { 'fqdn' : u'a1',
                                    'type' : u'Machine',
                                    'arch' : u'i386',
                                    'status' : u'Automated',
                                    'owner' : data_setup.create_user(),}
        cls.system_one = data_setup.create_system(**cls.system_one_details)
        cls.system_one.loaned = data_setup.create_user()
        cls.system_one.numa = Numa(nodes=2)
        cls.system_one.key_values_string.append(Key_Value_String(
            Key.by_name(u'CPUMODEL'), 'foocodename'))
        cls.system_one.key_values_string.append(Key_Value_String(
            Key.by_name(u'HVM'), '1'))
        cls.system_one.cpu = Cpu(flags=['flag1', 'flag2'])

        cls.system_one.key_values_int.append(Key_Value_Int(
            Key.by_name(u'DISKSPACE'), '1024'))
        cls.system_one.key_values_int.append(Key_Value_Int(
            Key.by_name(u'MEMORY'), '4096'))

        cls.system_two_details = { 'fqdn' : u'a2',
                                    'type' : u'Prototype',
                                    'arch' : u'x86_64',
                                    'status' : u'Manual',
                                    'owner' : data_setup.create_user(),}
        cls.system_two = data_setup.create_system(**cls.system_two_details)
        cls.system_two.key_values_int.append(Key_Value_Int(
            Key.by_name(u'DISKSPACE'), '900'))
        cls.system_two.key_values_string.append(Key_Value_String(
            Key.by_name(u'HVM'), '1'))

        device_class = DeviceClass.lazy_create(device_class='class_type')
        device1 = Device.lazy_create(vendor_id = '0000',
                                      device_id = '0000',
                                      subsys_vendor_id = '2223',
                                      subsys_device_id = '2224',
                                      bus = '0000',
                                      driver = '0000',
                                      device_class_id = device_class.id,
                                      description = 'blah')
        cls.system_two.devices.append(device1)
        cls.system_three_details = { 'fqdn' : u'a3',
                                    'type' : u'Laptop',
                                    'arch' : u'ia64',
                                    'status' : u'Removed',
                                    'owner' : data_setup.create_user(),}
        cls.system_three = data_setup.create_system(**cls.system_three_details)
        cls.system_three.numa = Numa(nodes=1)
        device2 = Device.lazy_create(vendor_id = '0000',
                                      device_id = '0000',
                                      subsys_vendor_id = '1111',
                                      subsys_device_id = '1112',
                                      bus = '0000',
                                      driver = '0000',
                                      device_class_id = device_class.id,
                                      description = 'blah')
        cls.system_three.devices.append(device2)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:61,代码来源:test_system_search.py

示例8: test_xml_filter

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_xml_filter(self):
     with session.begin():
         module_key = Key.by_name(u'MODULE')
         with_module = data_setup.create_system()
         with_module.key_values_string.extend([
                 Key_Value_String(module_key, u'cciss'),
                 Key_Value_String(module_key, u'kvm')])
         without_module = data_setup.create_system()
     out = run_client(['bkr', 'system-list',
             '--xml-filter', '<key_value key="MODULE" />'])
     returned_systems = out.splitlines()
     self.assert_(with_module.fqdn in returned_systems, returned_systems)
     self.assert_(without_module.fqdn not in returned_systems,
             returned_systems)
开发者ID:beaker-project,项目名称:beaker,代码行数:16,代码来源:test_system_list.py

示例9: test_xml_filter

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_xml_filter(self):
     with session.begin():
         module_key = Key.by_name(u'MODULE')
         with_module = data_setup.create_system()
         with_module.key_values_string.extend([
                 Key_Value_String(module_key, u'cciss'),
                 Key_Value_String(module_key, u'kvm')])
         without_module = data_setup.create_system()
     feed_url = urljoin(get_server_base(), '?' + urlencode({
             'tg_format': 'atom', 'list_tgp_order': '-date_modified',
             'xmlsearch': '<key_value key="MODULE" />'}))
     feed = lxml.etree.parse(urlopen(feed_url)).getroot()
     self.assert_(self.feed_contains_system(feed, with_module.fqdn))
     self.assert_(not self.feed_contains_system(feed, without_module.fqdn))
开发者ID:ShaolongHu,项目名称:beaker,代码行数:16,代码来源:test_systems.py

示例10: test_multiple_xml_filters

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_multiple_xml_filters(self):
     with session.begin():
         module_key = Key.by_name(u'MODULE')
         matching = data_setup.create_system()
         matching.cpu = Cpu(vendor=u'GenuineIntel', family=6, model=47, model_name=u'Intel')
         matching.key_values_string.append(
                 Key_Value_String(module_key, u'cciss'))
         nonmatching = data_setup.create_system()
     out = run_client(['bkr', 'system-list',
             '--xml-filter', '<not><lender value="shark"/></not>',
             '--xml-filter', '<key_value key="MODULE" value="cciss"/>',
             '--host-filter', 'INTEL__WESTMERE'])
     returned_systems = out.splitlines()
     self.assertIn(matching.fqdn, returned_systems)
     self.assertNotIn(nonmatching.fqdn, returned_systems)
开发者ID:beaker-project,项目名称:beaker,代码行数:17,代码来源:test_system_list.py

示例11: test_xml_filter

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_xml_filter(self):
     with session.begin():
         module_key = Key.by_name(u"MODULE")
         with_module = data_setup.create_system()
         with_module.key_values_string.extend(
             [Key_Value_String(module_key, u"cciss"), Key_Value_String(module_key, u"kvm")]
         )
         without_module = data_setup.create_system()
     feed_url = urljoin(
         get_server_base(),
         "?"
         + urlencode(
             {"tg_format": "atom", "list_tgp_order": "-date_modified", "xmlsearch": '<key_value key="MODULE" />'}
         ),
     )
     feed = lxml.etree.parse(urlopen(feed_url)).getroot()
     self.assert_(self.feed_contains_system(feed, with_module.fqdn))
     self.assert_(not self.feed_contains_system(feed, without_module.fqdn))
开发者ID:beaker-project,项目名称:beaker,代码行数:20,代码来源:test_systems.py

示例12: test_by_key_value_is

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_by_key_value_is(self):
     with session.begin():
         self.system.key_values_string.append(Key_Value_String(
                 Key.by_name(u'CPUMODEL'), 'foocodename'))
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
         .select_by_visible_text('CPUMODEL')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
开发者ID:beaker-project,项目名称:beaker,代码行数:20,代码来源:test_system_search.py

示例13: test_key_notequal

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_key_notequal(self):
     module_key = Key.by_name(u'MODULE')
     with_cciss = data_setup.create_system()
     with_cciss.key_values_string.extend([
             Key_Value_String(module_key, u'cciss'),
             Key_Value_String(module_key, u'kvm')])
     without_cciss = data_setup.create_system()
     without_cciss.key_values_string.extend([
             Key_Value_String(module_key, u'ida'),
             Key_Value_String(module_key, u'kvm')])
     self.check_filter("""
         <hostRequires>
             <and>
                 <key_value key="MODULE" op="!=" value="cciss"/>
             </and>
         </hostRequires>
         """,
         present=[without_cciss], absent=[with_cciss])
开发者ID:omps,项目名称:beaker,代码行数:20,代码来源:test_needpropertyxml.py

示例14: test_remove_key_value

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_remove_key_value(self):
     with session.begin():
         self.system.key_values_int.append(
                 Key_Value_Int(Key.by_name(u'NR_DISKS'), 100))
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Key/Values')
     b.find_element_by_xpath(
             '//td[normalize-space(preceding-sibling::td[1]/text())'
             '="NR_DISKS" and '
             'normalize-space(text())="100"]')
     delete_and_confirm(b, '//tr[normalize-space(td[1]/text())="NR_DISKS" and '
             'normalize-space(td[2]/text())="100"]')
     self.assertEquals(b.find_element_by_class_name('flash').text,
             'removed NR_DISKS/100')
     b.find_element_by_xpath('//div[@id="keys" and not(.//tr['
             'normalize-space(td[1]/text())="NR_DISKS" and '
             'normalize-space(td[2]/text())="100"])]')
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
开发者ID:sujithshankar,项目名称:beaker,代码行数:24,代码来源:test_system_view.py

示例15: test_keyvalue_does_not_cause_duplicate_rows

# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_name [as 别名]
 def test_keyvalue_does_not_cause_duplicate_rows(self):
     system = data_setup.create_system()
     disk_key = Key.by_name(u'DISK')
     system.key_values_int.extend([
             Key_Value_Int(disk_key, 30718),
             Key_Value_Int(disk_key, 140011),
             Key_Value_Int(disk_key, 1048570)])
     session.flush()
     filter = """
         <hostRequires>
             <and>
                 <system><name op="=" value="%s" /></system>
                 <key_value key="DISK" op="&gt;" value="9000" />
             </and>
         </hostRequires>
         """ % system.fqdn
     query = XmlHost.from_string(filter).apply_filter(System.query)
     self.assertEquals(len(query.all()), 1)
     # with the bug this count comes out as 3 instead of 1,
     # which doesn't sound so bad...
     # but when it's 926127 instead of 278, that's bad
     self.assertEquals(query.count(), 1)
开发者ID:omps,项目名称:beaker,代码行数:24,代码来源:test_needpropertyxml.py


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