本文整理汇总了Python中bkr.server.model.OSMajor类的典型用法代码示例。如果您正苦于以下问题:Python OSMajor类的具体用法?Python OSMajor怎么用?Python OSMajor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSMajor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
def index(self, **kwargs):
kwargs.setdefault('tag', 'STABLE')
value = dict((k, v) for k, v in kwargs.iteritems()
if k in ['osmajor', 'tag', 'distro'])
options = {}
tags = DistroTag.used()
options['tag'] = [('', 'None selected')] + \
[(tag.tag, tag.tag) for tag in tags]
options['osmajor'] = [('', 'None selected')] + \
[(osmajor.osmajor, osmajor.osmajor) for osmajor
in OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())]
options['distro'] = self._get_distro_options(**kwargs)
options['lab_controller_id'] = [(None, 'None selected')] + \
LabController.get_all(valid=True)
options['distro_tree_id'] = self._get_distro_tree_options(**kwargs)
attrs = {}
if not options['distro']:
attrs['distro'] = dict(disabled=True)
return dict(title=_(u'Reserve Workflow'),
widget=self.widget,
value=value,
widget_options=options,
widget_attrs=attrs)
示例2: index
def index(self, **kwargs):
# CherryPy will give us distro_tree_id as a scalar if it only has one
# value, but we want it to always be a list of int
if not kwargs.get('distro_tree_id'):
kwargs['distro_tree_id'] = []
elif not isinstance(kwargs['distro_tree_id'], list):
kwargs['distro_tree_id'] = [int(kwargs['distro_tree_id'])]
else:
kwargs['distro_tree_id'] = [int(x) for x in kwargs['distro_tree_id']]
# If we got a distro_tree_id but no osmajor or distro, fill those in
# with the right values so that the distro picker is populated properly
if kwargs['distro_tree_id']:
distro_tree = DistroTree.by_id(kwargs['distro_tree_id'][0])
if not kwargs.get('distro'):
kwargs['distro'] = distro_tree.distro.name
if not kwargs.get('osmajor'):
kwargs['osmajor'] = distro_tree.distro.osversion.osmajor.osmajor
options = {}
options['tag'] = [tag.tag for tag in DistroTag.used()]
options['osmajor'] = [osmajor.osmajor for osmajor in
OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())]
options['distro'] = self._get_distro_options(
osmajor=kwargs.get('osmajor'), tag=kwargs.get('tag'))
options['distro_tree_id'] = self._get_distro_tree_options(
distro=kwargs.get('distro'))
options['lab'] = [lc.fqdn for lc in
LabController.query.filter(LabController.removed == None)]
return dict(title=_(u'Reserve Workflow'),
selection=kwargs, options=options)
示例3: index
def index(self, **kwargs):
value = dict((k, v) for k, v in kwargs.iteritems()
if k in ['osmajor', 'tag', 'distro'])
options = {}
tags = DistroTag.used()
# It's important that 'None selected' is prepended
# rather then appended to the list of tags, as that will ensure
# it is the default option in the drop down.
options['tag'] = [('', 'None selected')] + \
[(tag.tag, tag.tag) for tag in tags]
options['osmajor'] = [('', 'None selected')] + \
[(osmajor.osmajor, osmajor.osmajor) for osmajor
in OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())]
options['distro'] = self._get_distro_options(**kwargs)
options['lab_controller_id'] = [(None, 'None selected')] + \
LabController.get_all(valid=True)
options['distro_tree_id'] = self._get_distro_tree_options(**kwargs)
attrs = {}
if not options['distro']:
attrs['distro'] = dict(disabled=True)
return dict(title=_(u'Reserve Workflow'),
widget=self.widget,
value=value,
widget_options=options,
widget_attrs=attrs)
示例4: test_update_harness_repos
def test_update_harness_repos(self):
"""Test that the update_repo() call runs as expected.
This checks that the harness repos that are supposed to be
synced are actually synced.
Does not check repo metadata.
"""
if 'sqlite' in get_engine().name:
raise unittest.SkipTest('SQL generated by lazy_create is not valid'
' in sqlite')
base_path = mkdtemp()
self.addCleanup(rmtree, base_path)
faux_remote_harness1 = self._create_remote_harness(base_path, 'foobangmajor')
faux_remote_harness2 = self._create_remote_harness(base_path, 'foobazmajor')
faux_local_harness = mkdtemp('local_harness')
self.addCleanup(rmtree, faux_local_harness)
with session.begin():
lab_controller = data_setup.create_labcontroller(fqdn=u'dummylab.example.invalid')
distro_tree = data_setup.create_distro_tree(
osmajor=OSMajor.lazy_create(osmajor=u'foobangmajor'),
harness_dir=False,
lab_controllers=[lab_controller])
distro_tree = data_setup.create_distro_tree(
osmajor=OSMajor.lazy_create(osmajor=u'foobazmajor'),
harness_dir=False,
lab_controllers=[lab_controller])
# I'm not testing the config here, so just use createrepo
update_repos('file://%s/' % base_path, faux_local_harness)
self.assertTrue(os.path.exists(os.path.join(faux_local_harness, 'foobangmajor')))
self.assertTrue(os.path.exists(os.path.join(faux_local_harness, 'foobazmajor')))
示例5: _from_csv
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
示例6: test_filters_out_excluded_families
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)
示例7: create_task
def create_task(name=None, exclude_arches=None, exclusive_arches=None,
exclude_osmajors=None, exclusive_osmajors=None, version=u'1.0-1',
uploader=None, owner=None, priority=u'Manual', valid=None, path=None,
description=None, requires=None, runfor=None, type=None, avg_time=1200):
if name is None:
name = unique_name(u'/distribution/test_task_%s')
if path is None:
path = u'/mnt/tests/%s' % name
if description is None:
description = unique_name(u'description%s')
if uploader is None:
uploader = create_user(user_name=u'task-uploader%s' % name.replace('/', '-'))
if owner is None:
owner = u'task-owner%[email protected]' % name.replace('/', '-')
if valid is None:
valid = True
rpm = u'example%s-%s.noarch.rpm' % (name.replace('/', '-'), version)
task = Task(name=name)
task.rpm = rpm
task.version = version
task.uploader = uploader
task.owner = owner
task.priority = priority
task.valid = valid
task.path = path
task.description = description
task.avg_time = avg_time
task.license = u'GPLv99+'
if type:
for t in type:
task.types.append(TaskType.lazy_create(type=t))
if exclude_arches:
for arch in exclude_arches:
task.excluded_arches.append(Arch.by_name(arch))
if exclusive_arches:
for arch in exclusive_arches:
task.exclusive_arches.append(Arch.by_name(arch))
if exclude_osmajors:
for osmajor in exclude_osmajors:
task.excluded_osmajors.append(OSMajor.lazy_create(osmajor=osmajor))
if exclusive_osmajors:
for osmajor in exclusive_osmajors:
task.exclusive_osmajors.append(OSMajor.lazy_create(osmajor=osmajor))
if requires:
for require in requires:
tp = TaskPackage.lazy_create(package=require)
task.required.append(tp)
if runfor:
for run in runfor:
task.runfor.append(TaskPackage.lazy_create(package=run))
session.add(task)
session.flush()
log.debug('Created task %s', task.name)
return task
示例8: test_adding_task_with_releases_list
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)
示例9: test_executed_tasks_family_sorting
def test_executed_tasks_family_sorting(self):
with session.begin():
task = data_setup.create_task()
data_setup.create_completed_job(task_name=task.name,
distro_tree=data_setup.create_distro_tree(osmajor=u'BlueShoe10'))
data_setup.create_completed_job(task_name=task.name,
distro_tree=data_setup.create_distro_tree(osmajor=u'BlueShoe9'))
# plus one that is never used
OSMajor.lazy_create(osmajor=u'neverused666')
b = self.browser
b.get(get_server_base() + 'tasks/%d' % task.id)
options = [element.text for element in
b.find_elements_by_xpath("//select[@name='osmajor_id']/option")]
self.assert_(options.index('BlueShoe9') < options.index('BlueShoe10'), options)
self.assert_('neverused666' not in options, options)
示例10: create_distro
def create_distro(name=None, osmajor=u'DansAwesomeLinux6', osminor=u'9',
arches=None, tags=None, harness_dir=True, osmajor_installopts=None):
osmajor = OSMajor.lazy_create(osmajor=osmajor)
osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=osminor)
if arches:
osversion.arches = arches
if not name:
name = unique_name(u'%s.%s-%%s' % (osmajor, osminor))
distro = Distro.lazy_create(name=name, osversion=osversion)
for tag in (tags or []):
distro.add_tag(tag)
# add distro wide install options, if any
if osmajor_installopts:
for arch in arches:
io = OSMajorInstallOptions.lazy_create(osmajor_id=osmajor.id,
arch_id=Arch.by_name(arch).id)
io.ks_meta = osmajor_installopts.get('ks_meta', '')
io.kernel_options = osmajor_installopts.get('kernel_options', '')
io.kernel_options_post = osmajor_installopts.get('kernel_options_post', '')
log.debug('Created distro %r', distro)
if harness_dir:
harness_dir = os.path.join(turbogears.config.get('basepath.harness'), distro.osversion.osmajor.osmajor)
if not os.path.exists(harness_dir):
os.makedirs(harness_dir)
return distro
示例11: test_concurrent_new_osversion
def test_concurrent_new_osversion(self):
distro_data = dict(self.distro_data)
# ensure osmajor already exists
with session.begin():
osmajor = OSMajor.lazy_create(osmajor=distro_data["osmajor"])
# ... but osversion is new
distro_data["osminor"] = "6969"
self.add_distro_trees_concurrently(distro_data, distro_data)
示例12: test_concurrent_same_tree
def test_concurrent_same_tree(self):
distro_data = dict(self.distro_data)
# ensure osmajor, osversion, and distro already exist
with session.begin():
osmajor = OSMajor.lazy_create(osmajor=distro_data["osmajor"])
osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=distro_data["osminor"])
osversion.arches = [Arch.lazy_create(arch=arch) for arch in distro_data["arches"]]
Distro.lazy_create(name=distro_data["name"], osversion=osversion)
self.add_distro_trees_concurrently(distro_data, distro_data)
示例13: setUp
def setUp(self):
with session.begin():
self.uploader = data_setup.create_user(password=u'upload')
# Make sure the Releases values we are using in the test cases
# below are already known to Beaker, otherwise they will be ignored.
OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinuxServer5')
OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinuxClient5')
OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinux7')
OSMajor.lazy_create(osmajor=u'RedHatEnterpriseLinux6')
self.browser = self.get_browser()
login(self.browser, user=self.uploader.user_name, password=u'upload')
示例14: test_concurrent_new_distro
def test_concurrent_new_distro(self):
distro_data = dict(self.distro_data)
# ensure osmajor and osversion already exist
with session.begin():
osmajor = OSMajor.lazy_create(osmajor=distro_data["osmajor"])
osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=distro_data["osminor"])
osversion.arches = [Arch.lazy_create(arch=arch) for arch in distro_data["arches"]]
# ... but distro is new
distro_data["name"] = "concurrent-new-distro"
self.add_distro_trees_concurrently(distro_data, distro_data)
示例15: test_exclude_nonexistent_osmajor
def test_exclude_nonexistent_osmajor(self):
if 'sqlite' in get_engine().name:
raise unittest.SkipTest('SQL generated by lazy_create is not valid'
' in sqlite')
with session.begin():
osmajor = OSMajor.lazy_create(osmajor="exist")
lab_controller = data_setup.create_labcontroller(fqdn=u'dummylab.example.invalid')
distro_tree = data_setup.create_distro_tree(osmajor=osmajor.osmajor,
harness_dir=False,
lab_controllers=[lab_controller])
nonexistent_osmajor = OSMajor.lazy_create(osmajor=u'notexist')
remote_harness_dir = mkdtemp(suffix='remote')
self.addCleanup(rmtree, remote_harness_dir)
local_harness_dir = mkdtemp(suffix='local')
self.addCleanup(rmtree, local_harness_dir)
self._create_remote_harness(remote_harness_dir, osmajor.osmajor)
update_repos('file://%s/' % remote_harness_dir, local_harness_dir)
self.assertTrue(os.path.exists(os.path.join(local_harness_dir, osmajor.osmajor)))
self.assertFalse(os.path.exists(os.path.join(local_harness_dir, nonexistent_osmajor.osmajor)))