def test_delete_install_options(self): with session.begin(): self.system.provisions[self.distro_tree.arch] = Provision( arch=self.distro_tree.arch, ks_meta=u'some_ks_meta_var=1', kernel_options=u'some_kernel_option=1', kernel_options_post=u'some_kernel_option=2') orig_date_modified = self.system.date_modified b = self.browser login(b) self.go_to_system_view(tab='Install Options') delete_and_confirm(b, '//tr[th/text()="Architecture"]') b.find_element_by_xpath('//h1[text()="%s"]' % self.system.fqdn) with session.begin(): session.refresh(self.system) self.assert_(self.system.date_modified > orig_date_modified) self.assert_(self.distro_tree.arch not in self.system.provisions) self.assertEquals(self.system.activity[0].action, u'Removed') self.assertEquals(self.system.activity[0].field_name, u'InstallOption:kernel_options_post:i386') self.assertEquals(self.system.activity[1].action, u'Removed') self.assertEquals(self.system.activity[1].field_name, u'InstallOption:kernel_options:i386') self.assertEquals(self.system.activity[2].action, u'Removed') self.assertEquals(self.system.activity[2].field_name, u'InstallOption:ks_meta:i386')
def test_distro_and_system_overrides_recipe(self): with session.begin(): lc = data_setup.create_labcontroller() i386_distro = self._create_i386_distro(lc) system1 = data_setup.create_system(lab_controller=lc, arch=u'x86_64') system2 = data_setup.create_system(lab_controller=lc, arch=u'i386') system2.provisions[system2.arch[0]] = Provision( arch=system2.arch[0], kernel_options_post='usshopper') recipe = self._create_recipe(system1) # recipe uses system1 + x86_64 distro. We pass in system2 and i386 # distro, so we should pick up the provision options of system2 + i386 distro_tree_id = i386_distro.trees[0].id kickstart = self._run_create_kickstart([ '--recipe-id', str(recipe.id), '--system', system2.fqdn, '--distro-tree-id', str(distro_tree_id), ]) # Make sure we are using the tree from --distro-tree-id self.assertIn( 'url=http://lab.test-kickstart.example.com/distros/' 'RHEL-6.3/Workstation/i386/os/', kickstart) self.assertIn('usshopper', kickstart) # Make sure we are using system2 self.assertIn(system2.fqdn, kickstart) self.assertNotIn(system1.fqdn, kickstart)
def test_export_install_options(self): with session.begin(): system = data_setup.create_system(arch=u'i386') distro_tree = data_setup.create_distro_tree(arch=u'i386') system.provisions[distro_tree.arch] = Provision( arch=distro_tree.arch, ks_meta=u'some_ks_meta_var=1', kernel_options=u'some_kernel_option=1', kernel_options_post=u'some_kernel_option=2') system.provisions[distro_tree.arch]\ .provision_families[distro_tree.distro.osversion.osmajor] = \ ProvisionFamily(osmajor=distro_tree.distro.osversion.osmajor, ks_meta=u'some_ks_meta_var=2', kernel_options=u'some_kernel_option=3', kernel_options_post=u'some_kernel_option=4') system.provisions[distro_tree.arch]\ .provision_families[distro_tree.distro.osversion.osmajor]\ .provision_family_updates[distro_tree.distro.osversion] = \ ProvisionFamilyUpdate(osversion=distro_tree.distro.osversion, ks_meta=u'some_ks_meta_var=3', kernel_options=u'some_kernel_option=5', kernel_options_post=u'some_kernel_option=6') login(self.browser) csv_request = self.get_csv('install') csv_rows = [ row for row in csv.DictReader(csv_request) if row['fqdn'] == system.fqdn ] self.assertEquals(csv_rows[0]['arch'], 'i386') self.assertEquals(csv_rows[0]['family'], '') self.assertEquals(csv_rows[0]['update'], '') self.assertEquals(csv_rows[0]['ks_meta'], 'some_ks_meta_var=1') self.assertEquals(csv_rows[0]['kernel_options'], 'some_kernel_option=1') self.assertEquals(csv_rows[0]['kernel_options_post'], 'some_kernel_option=2') self.assertEquals(csv_rows[1]['arch'], 'i386') self.assertEquals(csv_rows[1]['family'], unicode(distro_tree.distro.osversion.osmajor)) self.assertEquals(csv_rows[1]['update'], '') self.assertEquals(csv_rows[1]['ks_meta'], 'some_ks_meta_var=2') self.assertEquals(csv_rows[1]['kernel_options'], 'some_kernel_option=3') self.assertEquals(csv_rows[1]['kernel_options_post'], 'some_kernel_option=4') self.assertEquals(csv_rows[2]['arch'], 'i386') self.assertEquals(csv_rows[2]['family'], unicode(distro_tree.distro.osversion.osmajor)) self.assertEquals(csv_rows[2]['update'], unicode(distro_tree.distro.osversion.osminor)) self.assertEquals(csv_rows[2]['ks_meta'], 'some_ks_meta_var=3') self.assertEquals(csv_rows[2]['kernel_options'], 'some_kernel_option=5') self.assertEquals(csv_rows[2]['kernel_options_post'], 'some_kernel_option=6')
def test_system_overrides_recipe(self): with session.begin(): lc = create_lab_controller() system1 = data_setup.create_system(lab_controller=lc, arch='x86_64') system2 = data_setup.create_system(lab_controller=lc, arch='x86_64') system1.provisions[system1.arch[0]] = Provision(arch=system1.arch[0], kernel_options_post='adalovelace') system2.provisions[system2.arch[0]] = Provision(arch=system2.arch[0], kernel_options_post='phonykerneloption') recipe = self._create_recipe(system1) kickstart = self._run_create_kickstart(['--recipe-id', str(recipe.id), '--system', system2.fqdn,]) self.assertIn('phonykerneloption', kickstart) self.assertIn(system2.fqdn, kickstart) self.assertNotIn('adalovelace', kickstart) self.assertNotIn(system1.fqdn, kickstart)
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(tab='Excluded Families') b = self.browser # simulate the label click for i386 b.find_element_by_xpath( '//li[normalize-space(text())="i386"]' '//label[normalize-space(string(.))="DansAwesomeLinux6.9"]').click( ) # Now check if the appropriate checkbox was selected self.assertTrue( b.find_element_by_xpath( '//input[@name="excluded_families_subsection.i386" and @value="%s"]' % self.distro_tree.distro.osversion_id).is_selected()) self.assertFalse( b.find_element_by_xpath( '//input[@name="excluded_families_subsection.x86_64" and @value="%s"]' % self.distro_tree.distro.osversion_id).is_selected()) # Uncheck the i386 checkbox b.find_element_by_xpath( '//input[@name="excluded_families_subsection.i386" and @value="%s"]' % self.distro_tree.distro.osversion_id).click() # simulate the label click for x86_64 b.find_element_by_xpath( '//li[normalize-space(text())="x86_64"]' '//label[normalize-space(string(.))="DansAwesomeLinux6.9"]').click( ) # Now check if the appropriate checkbox was selected self.assertTrue( b.find_element_by_xpath( '//input[@name="excluded_families_subsection.x86_64" and @value="%s"]' % self.distro_tree.distro.osversion_id).is_selected()) self.assertFalse( b.find_element_by_xpath( '//input[@name="excluded_families_subsection.i386" and @value="%s"]' % self.distro_tree.distro.osversion_id).is_selected())
def setUp(self): self.lab_controller = data_setup.create_labcontroller() self.distro_tree = data_setup.create_distro_tree(osmajor=u'Fedora20', arch=u'i386', lab_controllers=[self.lab_controller]) self.usable_system = data_setup.create_system(arch=u'i386', owner=User.by_user_name(data_setup.ADMIN_USER), status=u'Manual', shared=True) data_setup.configure_system_power(self.usable_system, power_type=u'drac', address=u'nowhere.example.com', user=u'teh_powz0r', password=u'onoffonoff', power_id=u'asdf') self.usable_system.lab_controller = self.lab_controller self.usable_system.user = data_setup.create_user(password=u'password') self.usable_system.provisions[self.distro_tree.arch] = Provision( arch=self.distro_tree.arch, kernel_options='ksdevice=eth0 console=ttyS0') self.server = self.get_server()
def test_kernel_option_with_multiple_values(self): with session.begin(): user = data_setup.create_user(password=u'testing') system = data_setup.create_system(status=SystemStatus.manual, lab_controller=self.lc) system.provisions[self.distro_tree.arch] = \ Provision(arch=self.distro_tree.arch, kernel_options=u'key1=value1 key1=value2 key1 key2=value key3') system.reserve_manually(service=u'testdata', user=user) b = self.browser login(b, user=user.user_name, password='******') provision = self.go_to_provision_tab(system) self.select_distro_tree(self.distro_tree) provision.find_element_by_xpath( './/button[text()="Provision"]').click() b.find_element_by_xpath( './/div[contains(@class, "modal")]//button[text()="OK"]').click() b.find_element_by_xpath('//div[contains(@class, "alert-success")]' '/h4[text()="Provisioning successful"]') self.assert_(u'key1=value1 key1=value2 key2=value key3' in \ system.installations[0].kernel_options)
def _from_csv(cls, system, data, csv_type, log): """ Import data from CSV file into System Objects """ family = None update = None # Arch is required if 'arch' in data: try: arch = Arch.by_name(data['arch']) except ValueError: log.append("%s: Invalid arch %s" % (system.fqdn, data['arch'])) return False else: log.append("%s: Error! Missing arch" % system.fqdn) return False # pull in update and family if present if 'family' in data: family = data['family'] if family: try: family = OSMajor.by_name(family) except InvalidRequestError: log.append("%s: Error! Invalid family %s" % (system.fqdn, data['family'])) return False if 'update' in data: update = data['update'] if update: if not family: log.append( "%s: Error! You must specify Family along with Update" % system.fqdn) return False try: update = OSVersion.by_name(family, unicode(update)) except InvalidRequestError: log.append("%s: Error! Invalid update %s" % (system.fqdn, data['update'])) return False #Import Update specific if update and family: if system.provisions.has_key(arch): system_arch = system.provisions[arch] else: system_arch = Provision(arch=arch) system.provisions[arch] = system_arch if system_arch.provision_families.has_key(family): system_provfam = system_arch.provision_families[family] else: system_provfam = ProvisionFamily(osmajor=family) system_arch.provision_families[family] = system_provfam if system_provfam.provision_family_updates.has_key(update): prov = system_provfam.provision_family_updates[update] else: prov = ProvisionFamilyUpdate(osversion=update) system_provfam.provision_family_updates[update] = prov installlog = '%s/%s' % (arch, update) #Import Family specific if family and not update: if system.provisions.has_key(arch): system_arch = system.provisions[arch] else: system_arch = Provision(arch=arch) system.provisions[arch] = system_arch if system_arch.provision_families.has_key(family): prov = system_arch.provision_families[family] else: prov = ProvisionFamily(osmajor=family) system_arch.provision_families[family] = prov installlog = '%s/%s' % (arch, family) #Import Arch specific if not family and not update: if system.provisions.has_key(arch): prov = system.provisions[arch] else: prov = Provision(arch=arch) system.provisions[arch] = prov installlog = '%s' % arch if 'ks_meta' in data and prov.ks_meta != data['ks_meta']: system.record_activity(user=identity.current.user, service=u'CSV', action=u'Changed', field=u'InstallOption:ks_meta:%s' % installlog, old=prov.ks_meta, new=data['ks_meta']) prov.ks_meta = data['ks_meta'] if 'kernel_options' in data and prov.kernel_options != data[ 'kernel_options']: system.record_activity(user=identity.current.user, service=u'CSV', action=u'Changed', field=u'InstallOption:kernel_options:%s' % installlog, old=prov.kernel_options, new=data['kernel_options']) prov.kernel_options = data['kernel_options'] if 'kernel_options_post' in data and prov.kernel_options_post != data[ 'kernel_options_post']: system.record_activity( user=identity.current.user, service=u'CSV', action=u'Changed', field=u'InstallOption:kernel_options_post:%s' % installlog, old=prov.kernel_options_post, new=data['kernel_options_post']) prov.kernel_options_post = data['kernel_options_post'] return True