本文整理汇总了Python中bkr.server.model.OSMajor.by_name方法的典型用法代码示例。如果您正苦于以下问题:Python OSMajor.by_name方法的具体用法?Python OSMajor.by_name怎么用?Python OSMajor.by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.OSMajor
的用法示例。
在下文中一共展示了OSMajor.by_name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filters_out_excluded_families
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def test_filters_out_excluded_families(self):
with session.begin():
rhel3_i386 = data_setup.create_distro_tree(
osmajor=u"RedHatEnterpriseLinux3", arch=u"i386", distro_tags=[u"STABLE"]
)
rhel3_x86_64 = data_setup.create_distro_tree(
osmajor=u"RedHatEnterpriseLinux3", arch=u"x86_64", distro_tags=[u"STABLE"]
)
rhel4_i386 = data_setup.create_distro_tree(
osmajor=u"RedHatEnterpriseLinux4", arch=u"i386", distro_tags=[u"STABLE"]
)
rhel4_x86_64 = data_setup.create_distro_tree(
osmajor=u"RedHatEnterpriseLinux4", arch=u"x86_64", distro_tags=[u"STABLE"]
)
# system with RHEL4 i386 and RHEL3 x86_64 excluded
system = data_setup.create_system(arch=u"i386")
system.arch.append(Arch.by_name(u"x86_64"))
system.excluded_osmajor.extend(
[
ExcludeOSMajor(arch=Arch.by_name(u"i386"), osmajor=OSMajor.by_name(u"RedHatEnterpriseLinux4")),
ExcludeOSMajor(arch=Arch.by_name(u"x86_64"), osmajor=OSMajor.by_name(u"RedHatEnterpriseLinux3")),
]
)
out = run_client(["bkr", "machine-test", "--machine", system.fqdn])
self.assert_(out.startswith("Submitted:"), out)
with session.begin():
new_job = Job.query.order_by(Job.id.desc()).first()
distro_trees = [recipe.distro_tree for recipe in new_job.all_recipes]
self.assert_(rhel3_i386 in distro_trees, distro_trees)
self.assert_(rhel3_x86_64 not in distro_trees, distro_trees)
self.assert_(rhel4_i386 not in distro_trees, distro_trees)
self.assert_(rhel4_x86_64 in distro_trees, distro_trees)
示例2: _from_csv
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def _from_csv(cls,system,data,csv_type,log):
"""
Import data from CSV file into System Objects
"""
try:
arch = Arch.by_name(data['arch'])
except ValueError:
log.append("%s: Invalid Arch %s" % (system.fqdn, data['arch']))
return False
if data['update'] and data['family']:
try:
osversion = OSVersion.by_name(OSMajor.by_name(unicode(data['family'])),
unicode(data['update']))
except InvalidRequestError:
log.append("%s: Invalid Family %s Update %s" % (system.fqdn,
data['family'],
data['update']))
return False
if osversion not in [oldosversion.osversion for oldosversion in system.excluded_osversion_byarch(arch)]:
if data['excluded'] == 'True':
exclude_osversion = ExcludeOSVersion(osversion=osversion,
arch=arch)
system.excluded_osversion.append(exclude_osversion)
system.record_activity(user=identity.current.user, service=u'CSV',
action=u'Added', field=u'Excluded_families',
old=u'', new=u'%s/%s' % (osversion, arch))
else:
if data['excluded'] == 'False':
for old_osversion in system.excluded_osversion_byarch(arch):
if old_osversion.osversion == osversion:
system.record_activity(user=identity.current.user,
service=u'CSV', action=u'Removed',
field=u'Excluded_families',
old=u'%s/%s' % (old_osversion.osversion, arch),
new=u'')
session.delete(old_osversion)
if not data['update'] and data['family']:
try:
osmajor = OSMajor.by_name(data['family'])
except InvalidRequestError:
log.append("%s: Invalid family %s " % (system.fqdn,
data['family']))
return False
if osmajor not in [oldosmajor.osmajor for oldosmajor in system.excluded_osmajor_byarch(arch)]:
if data['excluded'].lower() == 'true':
exclude_osmajor = ExcludeOSMajor(osmajor=osmajor, arch=arch)
system.excluded_osmajor.append(exclude_osmajor)
system.record_activity(user=identity.current.user, service=u'CSV',
action=u'Added', field=u'Excluded_families',
old=u'', new=u'%s/%s' % (osmajor, arch))
else:
if data['excluded'].lower() == 'false':
for old_osmajor in system.excluded_osmajor_byarch(arch):
if old_osmajor.osmajor == osmajor:
system.record_activity(user=identity.current.user, service=u'CSV',
action=u'Removed', field=u'Excluded_families',
old=u'%s/%s' % (old_osmajor.osmajor, arch), new=u'')
session.delete(old_osmajor)
return True
示例3: test_adding_task_with_releases_list
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor 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)
示例4: test_clearing_alias_stores_null
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def test_clearing_alias_stores_null(self):
with session.begin():
data_setup.create_distro_tree(osmajor=u'YellowSpaceshipLinux2')
osmajor = OSMajor.by_name(u'YellowSpaceshipLinux2')
osmajor.alias = u'YSL2'
b = self.browser
go_to_edit_osmajor(b, 'YellowSpaceshipLinux2')
b.find_element_by_xpath('//input[@id="form_alias"]').clear()
b.find_element_by_xpath('//button[text()="Edit OSMajor"]').submit()
self.assertEquals(b.find_element_by_class_name('flash').text,
'Changes saved for YellowSpaceshipLinux2')
with session.begin():
session.refresh(osmajor)
self.assertEquals(osmajor.alias, None) # not ''
示例5: get_arch
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def get_arch(self, filter):
""" pass in a dict() with either distro or osmajor to get possible arches
"""
if 'distro' in filter:
# look up distro
try:
arches = [arch.arch for arch in Distro.by_name(filter['distro']).osversion.arches]
except DatabaseLookupError:
raise BX(_('Invalid Distro: %s' % filter['distro']))
elif 'osmajor' in filter:
# look up osmajor
try:
arches = [arch.arch for arch in OSMajor.by_name(filter['osmajor']).osversions[0].arches]
except InvalidRequestError:
raise BX(_('Invalid OSMajor: %s' % filter['osmajor']))
return arches
示例6: test_install_options_non_existent_system
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def test_install_options_non_existent_system(self):
login(self.browser)
fqdn = data_setup.unique_name('system%s.idonot.exist')
with session.begin():
distro_tree = data_setup.create_distro_tree(osmajor='MyEnterpriseLinux',
arch=u'x86_64')
self.import_csv((u'csv_type,fqdn,arch,family,update,ks_meta,kernel_options,kernel_options_post\n'
u'install,%s,x86_64,MyEnterpriseLinux,,mode=cmdline,,console=ttyS0' %
fqdn)
.encode('utf8'))
with session.begin():
system = System.query.filter(System.fqdn == fqdn).one()
arch = Arch.by_name(u'x86_64')
osmajor = OSMajor.by_name(u'MyEnterpriseLinux')
p = system.provisions[arch].provision_families[osmajor]
self.assertEquals(p.ks_meta, u'mode=cmdline')
self.assertEquals(p.kernel_options_post, u'console=ttyS0')
示例7: test_doubled_quotes
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def test_doubled_quotes(self):
with session.begin():
system = data_setup.create_system(fqdn=u'mymainframe.funtimes.invalid', arch=u's390x')
OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinux7')
b = self.browser
login(b)
b.get(get_server_base() + 'csv/csv_import')
b.find_element_by_name('csv_file').send_keys(
pkg_resources.resource_filename(self.__module__, 'bz802842.csv'))
b.find_element_by_name('csv_file').submit()
self.failUnless(is_text_present(self.browser, "No Errors"))
with session.begin():
session.refresh(system)
self.assertEquals(system.provisions[Arch.by_name(u's390x')]\
.provision_families[OSMajor.by_name(u'RedHatEnterpriseLinux7')]\
.kernel_options,
'rd.znet="qeth,0.0.8000,0.0.8001,0.0.8002,layer2=1,portname=lol,portno=0" '
'ip=1.2.3.4::1.2.3.4:255.255.248.0::eth0:none MTU=1500 nameserver=1.2.3.4 '
'DASD=20A1,21A1,22A1,23A1 MACADDR=02:DE:AD:BE:EF:16 '
'!LAYER2 !DNS !PORTNO !IPADDR !GATEWAY !HOSTNAME !NETMASK ')
示例8: test_edit_osmajor_install_options
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def test_edit_osmajor_install_options(self):
with session.begin():
data_setup.create_distro_tree(osmajor=u'LinuxLinux2.1', arch=u'ia64')
data_setup.create_distro_tree(osmajor=u'LinuxLinux2.1', arch=u'ppc64')
b = self.browser
# set them from scratch
go_to_edit_osmajor(b, 'LinuxLinux2.1')
b.find_element_by_xpath('//*[@id="install_options_all"]'
'//div[normalize-space(label/text())="Kickstart Metadata"]'
'//input').send_keys('one')
b.find_element_by_xpath('//*[@id="install_options_all"]'
'//div[normalize-space(label/text())="Kernel Options"]'
'//input').send_keys('two')
b.find_element_by_xpath('//*[@id="install_options_all"]'
'//div[normalize-space(label/text())="Kernel Options Post"]'
'//input').send_keys('three')
b.find_element_by_xpath('//*[@id="install_options_ppc64"]'
'//div[normalize-space(label/text())="Kickstart Metadata"]'
'//input').send_keys('four')
b.find_element_by_xpath('//*[@id="install_options_ppc64"]'
'//div[normalize-space(label/text())="Kernel Options"]'
'//input').send_keys('five')
b.find_element_by_xpath('//*[@id="install_options_ppc64"]'
'//div[normalize-space(label/text())="Kernel Options Post"]'
'//input').send_keys('six')
b.find_element_by_xpath('//button[text()="Save Changes"]').click()
self.assertEquals(
b.find_element_by_class_name('flash').text,
'Install options saved for LinuxLinux2.1')
# check everything is saved
with session.begin():
o = OSMajor.by_name(u'LinuxLinux2.1')
ia64 = Arch.by_name(u'ia64')
ppc64 = Arch.by_name(u'ppc64')
self.assertEquals(set(o.install_options_by_arch.keys()),
set([None, ia64, ppc64]),
o.install_options_by_arch)
self.assertEquals(o.install_options_by_arch[None].ks_meta, 'one')
self.assertEquals(o.install_options_by_arch[None].kernel_options, 'two')
self.assertEquals(o.install_options_by_arch[None].kernel_options_post, 'three')
self.assertEquals(o.install_options_by_arch[ia64].ks_meta, '')
self.assertEquals(o.install_options_by_arch[ia64].kernel_options, '')
self.assertEquals(o.install_options_by_arch[ia64].kernel_options_post, '')
self.assertEquals(o.install_options_by_arch[ppc64].ks_meta, 'four')
self.assertEquals(o.install_options_by_arch[ppc64].kernel_options, 'five')
self.assertEquals(o.install_options_by_arch[ppc64].kernel_options_post, 'six')
# now edit the existing options
go_to_edit_osmajor(b, 'LinuxLinux2.1')
input = b.find_element_by_xpath('//*[@id="install_options_ppc64"]'
'//div[normalize-space(label/text())="Kickstart Metadata"]'
'//input')
self.assertEquals(input.get_attribute('value'), 'four')
input.clear()
input.send_keys('something else')
input = b.find_element_by_xpath('//*[@id="install_options_ppc64"]'
'//div[normalize-space(label/text())="Kernel Options"]'
'//input')
self.assertEquals(input.get_attribute('value'), 'five')
input.clear()
input.send_keys('something else')
input = b.find_element_by_xpath('//*[@id="install_options_ppc64"]'
'//div[normalize-space(label/text())="Kernel Options Post"]'
'//input')
self.assertEquals(input.get_attribute('value'), 'six')
input.clear()
input.send_keys('something else')
b.find_element_by_xpath('//button[text()="Save Changes"]').click()
self.assertEquals(
b.find_element_by_class_name('flash').text,
'Install options saved for LinuxLinux2.1')
# check they are updated
with session.begin():
session.expunge_all()
o = OSMajor.by_name(u'LinuxLinux2.1')
ppc64 = Arch.by_name(u'ppc64')
self.assertEquals(o.install_options_by_arch[ppc64].ks_meta,
'something else')
self.assertEquals(o.install_options_by_arch[ppc64].kernel_options,
'something else')
self.assertEquals(o.install_options_by_arch[ppc64].kernel_options_post,
'something else')
示例9: filter
# 需要导入模块: from bkr.server.model import OSMajor [as 别名]
# 或者: from bkr.server.model.OSMajor import by_name [as 别名]
def filter(self, filter):
"""
Returns a list of tasks filtered by the given criteria.
The *filter* argument must be an XML-RPC structure (dict), with any of the following keys:
'distro_name'
Distro name. Include only tasks which are compatible
with this distro.
'osmajor'
OSVersion OSMajor, like RedHatEnterpriseLinux6. Include only
tasks which are compatible with this OSMajor.
'names'
Task name. Include only tasks that are named. Useful when
combined with 'osmajor' or 'distro_name'.
'packages'
List of package names. Include only tasks which have a Run-For
entry matching any of these packages.
'types'
List of task types. Include only tasks which have one or more
of these types.
'valid'
bool 0 or 1. Include only tasks which are valid or not.
'destructive'
bool 0 or 1. Set to 0 for only non-destructive tasks. Set to
1 for only destructive tasks.
The return value is an array of dicts, which are name and arches.
name is the name of the matching tasks.
arches is an array of arches which this task does not apply for.
Call :meth:`tasks.to_dict` to fetch metadata for a particular task.
.. versionchanged:: 0.9
Changed 'install_name' to 'distro_name' in the *filter* argument.
"""
if filter.get('distro_name'):
distro = Distro.by_name(filter['distro_name'])
tasks = distro.tasks()
elif 'osmajor' in filter and filter['osmajor']:
try:
osmajor = OSMajor.by_name(filter['osmajor'])
except InvalidRequestError:
raise BX(_('Invalid OSMajor: %s' % filter['osmajor']))
tasks = osmajor.tasks()
else:
tasks = Task.query
# Filter by valid task if requested
if 'valid' in filter:
tasks = tasks.filter(Task.valid==bool(filter['valid']))
# Filter by destructive if requested
if 'destructive' in filter:
tasks = tasks.filter(Task.destructive==bool(filter['destructive']))
# Filter by name if specified
# /distribution/install, /distribution/reservesys
if 'names' in filter and filter['names']:
# if not a list, make it into a list.
if isinstance(filter['names'], str):
filter['names'] = [filter['names']]
or_names = []
for tname in filter['names']:
or_names.append(Task.name==tname)
tasks = tasks.filter(or_(*or_names))
# Filter by packages if specified
# apache, kernel, mysql, etc..
if 'packages' in filter and filter['packages']:
# if not a list, make it into a list.
if isinstance(filter['packages'], str):
filter['packages'] = [filter['packages']]
tasks = tasks.filter(Task.runfor.any(or_(
*[TaskPackage.package == package for package in filter['packages']])))
# Filter by type if specified
# Tier1, Regression, KernelTier1, etc..
if 'types' in filter and filter['types']:
# if not a list, make it into a list.
if isinstance(filter['types'], str):
filter['types'] = [filter['types']]
tasks = tasks.join('types')
or_types = []
for type in filter['types']:
try:
tasktype = TaskType.by_name(type)
except InvalidRequestError, err:
raise BX(_('Invalid Task Type: %s' % type))
or_types.append(TaskType.id==tasktype.id)
tasks = tasks.filter(or_(*or_types))