How to use _set_host_profile method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...49 raise ValueError("No system %s registered on install server" %50 host.hostname)51 system_handle = self.server.get_system_handle(system, self.token)52 return (system, system_handle)53 def _set_host_profile(self, host, profile=''):54 system, system_handle = self.get_system_handle(host)55 system_info = self.server.get_system(system)56 # If no fallback profile is enabled, we don't want to mess57 # with the currently profile set for that machine.58 if profile:59 self.server.modify_system(system_handle, 'profile', profile,60 self.token)61 self.server.save_system(system_handle, self.token)62 # Enable netboot for that machine (next time it'll reboot and be63 # reinstalled)64 self.server.modify_system(system_handle, 'netboot_enabled', 'True',65 self.token)66 self.server.save_system(system_handle, self.token)67 try:68 # Cobbler only generates the DHCP configuration for netboot enabled69 # machines, so we need to synchronize the dhcpd file after changing70 # the value above71 self.server.sync_dhcp(self.token)72 except xmlrpclib.Fault, err:73 # older Cobbler will not recognize the above command74 if "unknown remote method" not in err.faultString:75 logging.error("DHCP sync failed, error code: %s, error string: %s",76 err.faultCode, err.faultString)77 def install_host(self, host, profile='', timeout=None, num_attempts=2):78 """79 Install a host object with profile name defined by distro.80 :param host: Autotest host object.81 :param profile: String with cobbler profile name.82 :param timeout: Amount of time to wait for the install.83 :param num_attempts: Maximum number of install attempts.84 """85 if not self.xmlrpc_url:86 return87 installations_attempted = 188 step_time = 6089 if timeout is None:90 # 1 hour of timeout by default91 timeout = 360092 system, system_handle = self.get_system_handle(host)93 if not profile:94 profile = self.server.get_system(system).get('profile')95 if not profile:96 e_msg = 'Unable to determine profile for host %s' % host.hostname97 raise error.HostInstallProfileError(e_msg)98 host.record("START", None, "install", host.hostname)99 host.record("GOOD", None, "install.start", host.hostname)100"Installing machine %s with profile %s (timeout %s s)",101 host.hostname, profile, timeout)102 install_start = time.time()103 time_elapsed = 0104 install_successful = False105 while ((not install_successful) and106 (installations_attempted <= self.num_attempts) and107 (time_elapsed < timeout)):108 self._set_host_profile(host, profile)109 self.server.power_system(system_handle,110 'reboot', self.token)111 installations_attempted += 1112 while time_elapsed < timeout:113 time.sleep(step_time)114 # Cobbler signals that installation if finished by running115 # a %post script that unsets netboot_enabled. So, if it's116 # still set, installation has not finished. Loop and sleep.117 if not self.server.get_system(system).get('netboot_enabled'):118 logging.debug('Cobbler got signaled that host %s '119 'installation is finished',120 host.hostname)121 break122 # Check if the installed profile matches what we asked for...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?