How to use _wait_for_reboot method in autotest

Best Python code snippet using autotest_python

bigip_provision.py

Source:bigip_provision.py Github

copy

Full Screen

...182 return True183 self.update_on_device()184 self._wait_for_module_provisioning()185 if self.want.module == 'vcmp':186 self._wait_for_reboot()187 self._wait_for_module_provisioning()188 return True189 def should_update(self):190 result = self._update_changed_options()191 if result:192 return True193 return False194 def update_on_device(self):195 params = self.want.api_params()196 provision = self.client.api.tm.sys.provision197 resource = getattr(provision, self.want.module)198 resource = resource.load()199 resource.update(**params)200 def read_current_from_device(self):201 provision = self.client.api.tm.sys.provision202 resource = getattr(provision, str(self.want.module))203 resource = resource.load()204 result = resource.attrs205 return Parameters(result)206 def absent(self):207 if self.exists():208 return self.remove()209 return False210 def remove(self):211 if self.client.check_mode:212 return True213 self.remove_from_device()214 self._wait_for_module_provisioning()215 # For vCMP, because it has to reboot, we also wait for mcpd to become available216 # before "moving on", or else the REST API would not be available and subsequent217 # Tasks would fail.218 if self.want.module == 'vcmp':219 self._wait_for_reboot()220 self._wait_for_module_provisioning()221 if self.exists():222 raise F5ModuleError("Failed to de-provision the module")223 return True224 def remove_from_device(self):225 provision = self.client.api.tm.sys.provision226 resource = getattr(provision, self.want.module)227 resource = resource.load()228 resource.update(level='none')229 def _wait_for_module_provisioning(self):230 # To prevent things from running forever, the hack is to check231 # for mprov's status twice. If mprov is finished, then in most232 # cases (not ASM) the provisioning is probably ready.233 nops = 0234 # Sleep a little to let provisioning settle and begin properly235 time.sleep(5)236 while nops < 4:237 try:238 if not self._is_mprov_running_on_device():239 nops += 1240 else:241 nops = 0242 except Exception:243 # This can be caused by restjavad restarting.244 pass245 time.sleep(10)246 def _is_mprov_running_on_device(self):247 output = self.client.api.tm.util.bash.exec_cmd(248 'run',249 utilCmdArgs='-c "ps aux | grep \'[m]prov\'"'250 )251 if hasattr(output, 'commandResult'):252 return True253 return False254 def _get_last_reboot(self):255 output = self.client.api.tm.util.bash.exec_cmd(256 'run',257 utilCmdArgs='-c "/usr/bin/last reboot | head - 1"'258 )259 if hasattr(output, 'commandResult'):260 return str(output.commandResult)261 return None262 def _wait_for_reboot(self):263 nops = 0264 last_reboot = self._get_last_reboot()265 # Sleep a little to let provisioning settle and begin properly266 time.sleep(5)267 while nops < 6:268 try:269 next_reboot = self._get_last_reboot()270 if next_reboot is None:271 nops = 0272 if next_reboot == last_reboot:273 nops = 0274 else:275 nops += 1276 except Exception as ex:...

Full Screen

Full Screen

ipmimixin.py

Source:ipmimixin.py Github

copy

Full Screen

...104 ret_val, result = self._run_ipmi_cmd('power cycle')105 if(ret_val == 0):106 #ipmi commands take a few moments to process107 time.sleep(5)108 if not self._wait_for_reboot():109 msg = self.ipmi_power_on()110 if not (msg == "Chassis powered on..."):111 return "Unable to power cycle host..."112 return "Power cycle successful..."113 return "Power cycle successful..."114 else:115 return "Error: %s" % msg116 def ipmi_power_status(self):117 """Checks the power status of a ipmi enabled hosts118 and returns the status as a string119 """120 ret_val, result = self._run_ipmi_cmd('power status') 121 return result122 def _wait_for_reboot(self, wait_time=15):123 """ Waits for ipmi enabled host to be turned on. Accepts the124 ipmi hostname and the wait time in seconds(defaults to 15).125 Returns True if chassis is on before the wait time is up.126 Otherwise returns False meaning the chassis is still off.127 """128 #measured in seconds129 while (wait_time > 0):130 result = self.ipmi_power_status()131 if (result == "Chassis Power is on"):132 wait_time = 0133 ret_val = True134 else:135 time.sleep(5)136 wait_time -= 5...

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:

YouTube

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?

Helpful

NotHelpful