本文整理汇总了Python中bkr.server.model.Arch类的典型用法代码示例。如果您正苦于以下问题:Python Arch类的具体用法?Python Arch怎么用?Python Arch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Arch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_distro
def create_distro(name=None, osmajor=u'DansAwesomeLinux6', osminor=u'9',
arches=None, tags=None, harness_dir=True,
osmajor_installopts=None, date_created=None):
osmajor = OSMajor.lazy_create(osmajor=osmajor)
osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=osminor)
if arches:
osversion.arches = [Arch.by_name(arch) for arch in arches]
if not name:
name = unique_name(u'%s.%s-%%s' % (osmajor, osminor))
distro = Distro.lazy_create(name=name, osversion=osversion)
if date_created is not None:
distro.date_created = date_created
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
示例2: create_system
def create_system(arch=u'i386', type=SystemType.machine, status=SystemStatus.automated,
owner=None, fqdn=None, shared=True, exclude_osmajor=[],
exclude_osversion=[], hypervisor=None, kernel_type=None,
date_added=None, **kw):
if owner is None:
owner = create_user()
if fqdn is None:
fqdn = unique_name(u'system%s.testdata')
if System.query.filter(System.fqdn == fqdn).count():
raise ValueError('Attempted to create duplicate system %s' % fqdn)
system = System(fqdn=fqdn,type=type, owner=owner,
status=status, **kw)
if date_added is not None:
system.date_added = date_added
system.shared = shared
system.arch.append(Arch.by_name(arch))
configure_system_power(system)
system.excluded_osmajor.extend(ExcludeOSMajor(arch=Arch.by_name(arch),
osmajor=osmajor) for osmajor in exclude_osmajor)
system.excluded_osversion.extend(ExcludeOSVersion(arch=Arch.by_name(arch),
osversion=osversion) for osversion in exclude_osversion)
if hypervisor:
system.hypervisor = Hypervisor.by_name(hypervisor)
if kernel_type:
system.kernel_type = KernelType.by_name(kernel_type)
system.date_modified = datetime.datetime.utcnow()
log.debug('Created system %r', system)
return system
示例3: 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)
示例4: 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)
示例5: setUp
def setUp(self):
i386 = Arch.by_name(u'i386')
x86_64 = Arch.by_name(u'x86_64')
self.distro = data_setup.create_distro(osmajor=u'MyAwesomeLinux',
tags=[u'STABLE'],
arches=[i386, x86_64])
data_setup.create_distro_tree(distro=self.distro,
arch=u'i386')
data_setup.create_distro_tree(distro=self.distro,
arch=u'x86_64')
示例6: 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
示例7: test_add_distro_tree
def test_add_distro_tree(self):
self.server.auth.login_password(self.lc.user.user_name, u'logmein')
self.server.labcontrollers.add_distro_tree(self.distro_data)
with session.begin():
distro = Distro.by_name(u'RHEL-6-U1')
self.assertEquals(distro.osversion.osmajor.osmajor, u'RedHatEnterpriseLinux6')
self.assertEquals(distro.osversion.osminor, u'1')
self.assertEquals(distro.osversion.arches,
[Arch.by_name(u'i386'), Arch.by_name(u'x86_64')])
self.assertEquals(distro.date_created,
datetime.datetime(2011, 5, 10, 22, 53, 18))
distro_tree = DistroTree.query.filter_by(distro=distro,
variant=u'Workstation', arch=Arch.by_name('x86_64')).one()
self.assertEquals(distro_tree.date_created,
datetime.datetime(2011, 5, 10, 22, 53, 18))
self.assertEquals(distro_tree.url_in_lab(self.lc, scheme='nfs'),
'nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/')
self.assertEquals(distro_tree.repo_by_id('Workstation').path,
'')
self.assertEquals(distro_tree.repo_by_id('ScalableFileSystem').path,
'ScalableFileSystem/')
self.assertEquals(distro_tree.repo_by_id('optional').path,
'../../optional/x86_64/os/')
self.assertEquals(distro_tree.repo_by_id('debuginfo').path,
'../debug/')
self.assertEquals(distro_tree.image_by_type(ImageType.kernel,
KernelType.by_name(u'default')).path,
'images/pxeboot/vmlinuz')
self.assertEquals(distro_tree.image_by_type(ImageType.initrd,
KernelType.by_name(u'default')).path,
'images/pxeboot/initrd.img')
self.assertEquals(distro_tree.activity[0].field_name, u'lab_controller_assocs')
self.assertEquals(distro_tree.activity[0].action, u'Added')
self.assert_(self.lc.fqdn in distro_tree.activity[0].new_value,
distro_tree.activity[0].new_value)
del distro, distro_tree
# another lab controller adds the same distro tree
self.server.auth.login_password(self.lc2.user.user_name, u'logmein')
self.server.labcontrollers.add_distro_tree(self.distro_data)
with session.begin():
distro = Distro.by_name(u'RHEL-6-U1')
distro_tree = DistroTree.query.filter_by(distro=distro,
variant=u'Workstation', arch=Arch.by_name('x86_64')).one()
self.assertEquals(distro_tree.url_in_lab(self.lc2, scheme='nfs'),
'nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/')
self.assertEquals(distro_tree.activity[0].field_name, u'lab_controller_assocs')
self.assertEquals(distro_tree.activity[0].action, u'Added')
self.assert_(self.lc2.fqdn in distro_tree.activity[0].new_value,
distro_tree.activity[0].new_value)
del distro, distro_tree
示例8: test_add_distro_tree
def test_add_distro_tree(self):
self.server.auth.login_password(self.lc.user.user_name, u"logmein")
self.server.labcontrollers.add_distro_tree(self.distro_data)
with session.begin():
distro = Distro.by_name(u"RHEL-6-U1")
self.assertEquals(distro.osversion.osmajor.osmajor, u"RedHatEnterpriseLinux6")
self.assertEquals(distro.osversion.osminor, u"1")
self.assertEquals(distro.osversion.arches, [Arch.by_name(u"i386"), Arch.by_name(u"x86_64")])
self.assertEquals(distro.date_created, datetime.datetime(2011, 5, 10, 22, 53, 18))
distro_tree = DistroTree.query.filter_by(
distro=distro, variant=u"Workstation", arch=Arch.by_name("x86_64")
).one()
self.assertEquals(distro_tree.date_created, datetime.datetime(2011, 5, 10, 22, 53, 18))
self.assertEquals(
distro_tree.url_in_lab(self.lc, scheme="nfs"), "nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/"
)
self.assertEquals(distro_tree.repo_by_id("Workstation").path, "")
self.assertEquals(distro_tree.repo_by_id("ScalableFileSystem").path, "ScalableFileSystem/")
self.assertEquals(distro_tree.repo_by_id("optional").path, "../../optional/x86_64/os/")
self.assertEquals(distro_tree.repo_by_id("debuginfo").path, "../debug/")
self.assertEquals(
distro_tree.image_by_type(ImageType.kernel, KernelType.by_name(u"default")).path,
"images/pxeboot/vmlinuz",
)
self.assertEquals(
distro_tree.image_by_type(ImageType.initrd, KernelType.by_name(u"default")).path,
"images/pxeboot/initrd.img",
)
self.assertEquals(distro_tree.activity[0].field_name, u"lab_controller_assocs")
self.assertEquals(distro_tree.activity[0].action, u"Added")
self.assert_(self.lc.fqdn in distro_tree.activity[0].new_value, distro_tree.activity[0].new_value)
del distro, distro_tree
# another lab controller adds the same distro tree
self.server.auth.login_password(self.lc2.user.user_name, u"logmein")
self.server.labcontrollers.add_distro_tree(self.distro_data)
with session.begin():
distro = Distro.by_name(u"RHEL-6-U1")
distro_tree = DistroTree.query.filter_by(
distro=distro, variant=u"Workstation", arch=Arch.by_name("x86_64")
).one()
self.assertEquals(
distro_tree.url_in_lab(self.lc2, scheme="nfs"),
"nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/",
)
self.assertEquals(distro_tree.activity[0].field_name, u"lab_controller_assocs")
self.assertEquals(distro_tree.activity[0].action, u"Added")
self.assert_(self.lc2.fqdn in distro_tree.activity[0].new_value, distro_tree.activity[0].new_value)
del distro, distro_tree
示例9: create_distro_tree
def create_distro_tree(distro=None, distro_name=None, osmajor=u'DansAwesomeLinux6',
distro_tags=None, arch=u'i386', variant=u'Server', lab_controllers=None,
urls=None):
if distro is None:
if distro_name is None:
distro = create_distro(osmajor=osmajor, tags=distro_tags)
else:
distro = Distro.by_name(distro_name)
if not distro:
distro = create_distro(name=distro_name)
distro_tree = DistroTree.lazy_create(distro=distro,
arch=Arch.by_name(arch), variant=variant)
session.add(distro_tree)
if distro_tree.arch not in distro.osversion.arches:
distro.osversion.arches.append(distro_tree.arch)
distro_tree.repos.append(DistroTreeRepo(repo_id=variant,
repo_type=u'variant', path=u''))
existing_urls = [lc_distro_tree.url for lc_distro_tree in distro_tree.lab_controller_assocs]
# make it available in all lab controllers
for lc in (lab_controllers or LabController.query):
default_urls = [u'%s://%s%s/distros/%s/%s/%s/os/' % (scheme, lc.fqdn,
scheme == 'nfs' and ':' or '',
distro_tree.distro.name, distro_tree.variant,
distro_tree.arch.arch) for scheme in ['nfs', 'http', 'ftp']]
for url in (urls or default_urls):
if url in existing_urls:
break
lab_controller_distro_tree = LabControllerDistroTree(
lab_controller=lc, url=url)
distro_tree.lab_controller_assocs.append(lab_controller_distro_tree)
log.debug('Created distro tree %r', distro_tree)
return distro_tree
示例10: test_system
def test_system(self):
login(self.browser)
orig_date_modified = self.system.date_modified
self.import_csv((u'csv_type,fqdn,location,arch\n'
u'system,%s,Under my desk,ia64' % self.system.fqdn)
.encode('utf8'))
self.failUnless(is_text_present(self.browser, "No Errors"))
with session.begin():
session.refresh(self.system)
self.assertEquals(self.system.location, u'Under my desk')
self.assert_(Arch.by_name(u'ia64') in self.system.arch)
self.assert_(self.system.date_modified > orig_date_modified)
# attempting to import a system with no FQDN should fail
self.import_csv((u'csv_type,fqdn,location,arch\n'
u'system,'',Under my desk,ia64').encode('utf8'))
self.assertEquals(self.browser.find_element_by_xpath(
'//table[@id="csv-import-log"]//td').text,
"Error importing line 2: "
"System must have an associated FQDN")
# attempting to import a system with an invalid FQDN should fail
self.import_csv((u'csv_type,fqdn,location,arch\n'
u'system,invalid--fqdn,Under my desk,ia64').encode('utf8'))
self.assertEquals(self.browser.find_element_by_xpath(
'//table[@id="csv-import-log"]//td').text,
"Error importing line 2: "
"Invalid FQDN for system: invalid--fqdn")
示例11: _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
示例12: create_rhel62_server_x86_64
def create_rhel62_server_x86_64(lab_controller):
rhel62 = create_rhel62()
x86_64 = Arch.by_name(u'x86_64')
try:
return DistroTree.query.filter_by(distro=rhel62, variant=u'Server', arch=x86_64).one()
except NoResultFound:
rhel62_server_x86_64 = data_setup.create_distro_tree(
distro=rhel62, variant=u'Server', arch=u'x86_64',
lab_controllers=[lab_controller],
urls=[u'http://lab.test-kickstart.invalid/distros/RHEL-6.2/Server/x86_64/os/',
u'nfs://lab.test-kickstart.invalid:/distros/RHEL-6.2/Server/x86_64/os/'])
rhel62_server_x86_64.repos[:] = [
DistroTreeRepo(repo_id=u'HighAvailability', repo_type=u'addon',
path=u'HighAvailability'),
DistroTreeRepo(repo_id=u'LoadBalancer', repo_type=u'addon',
path=u'LoadBalancer'),
DistroTreeRepo(repo_id=u'ResilientStorage', repo_type=u'addon',
path=u'ResilientStorage'),
DistroTreeRepo(repo_id=u'ScalableFileSystem', repo_type=u'addon',
path=u'ScalableFileSystem'),
DistroTreeRepo(repo_id=u'Server', repo_type=u'os', path=u'Server'),
DistroTreeRepo(repo_id=u'optional-x86_64-os', repo_type=u'addon',
path=u'../../optional/x86_64/os'),
DistroTreeRepo(repo_id=u'debug', repo_type=u'debug',
path=u'../debug'),
DistroTreeRepo(repo_id=u'optional-x86_64-debug', repo_type=u'debug',
path=u'../../optional/x86_64/debug'),
]
return rhel62_server_x86_64
示例13: test_change_url
def test_change_url(self):
self.server.auth.login_password(self.lc.user.user_name, u"logmein")
self.server.labcontrollers.add_distro_tree(self.distro_data)
# add it again, but with different urls
new_distro_data = dict(self.distro_data)
new_distro_data["urls"] = [
# nfs:// is not included here, so it shouldn't change
"nfs+iso://example.invalid:/RHEL-6-Workstation/U1/x86_64/iso/",
"http://moved/",
]
self.server.labcontrollers.add_distro_tree(new_distro_data)
with session.begin():
distro = Distro.by_name(u"RHEL-6-U1")
distro_tree = DistroTree.query.filter_by(
distro=distro, variant=u"Workstation", arch=Arch.by_name("x86_64")
).one()
self.assertEquals(
distro_tree.url_in_lab(self.lc, scheme="nfs"), "nfs://example.invalid:/RHEL-6-Workstation/U1/x86_64/os/"
)
self.assertEquals(
distro_tree.url_in_lab(self.lc, scheme="nfs+iso"),
"nfs+iso://example.invalid:/RHEL-6-Workstation/U1/x86_64/iso/",
)
self.assertEquals(distro_tree.url_in_lab(self.lc, scheme="http"), "http://moved/")
del distro, distro_tree
示例14: test_excluded_families
def test_excluded_families(self):
# Uses the default distro tree which goes by the name
# of DansAwesomeLinux created in setUp()
# append the x86_64 architecture to the system
self.system.arch.append(Arch.by_name(u"x86_64"))
# set up the distro tree for x86_64
with session.begin():
distro_tree = data_setup.create_distro_tree(arch=u"x86_64")
self.system.provisions[distro_tree.arch] = Provision(arch=distro_tree.arch)
self.go_to_system_view(self.system)
sel = self.selenium
# go to the Excluded Families Tab
sel.click('//ul[@class="tabbernav"]//a[text()="Excluded Families"]')
# simulate the label click for i386
sel.click('//li[label/text()="i386"]//label[text()="DansAwesomeLinux6.9"]')
# Now check if the appropriate checkbox was selected
self.assertEquals(
sel.is_checked(
'//input[@name="excluded_families_subsection.i386" and @value="%s"]'
% self.distro_tree.distro.osversion_id
),
True,
)
self.assertEquals(
sel.is_checked(
'//input[@name="excluded_families_subsection.x86_64" and @value="%s"]'
% self.distro_tree.distro.osversion_id
),
False,
)
# Uncheck the i386 checkbox
sel.uncheck(
'//input[@name="excluded_families_subsection.i386" and @value="%s"]' % self.distro_tree.distro.osversion_id
)
# simulate the label click for x86_64
sel.click('//li[label/text()="x86_64"]//label[text()="DansAwesomeLinux6.9"]')
# Now check if the appropriate checkbox was selected
self.assertEquals(
sel.is_checked(
'//input[@name="excluded_families_subsection.x86_64" and @value="%s"]'
% self.distro_tree.distro.osversion_id
),
True,
)
self.assertEquals(
sel.is_checked(
'//input[@name="excluded_families_subsection.i386" and @value="%s"]'
% self.distro_tree.distro.osversion_id
),
False,
)
示例15: 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)