def _wait_for_vmware_tools(self): """ Wait until vmware tools is ready """ timeout_loop( self.timeout, 'Vmware tools readiness', 1, False, lambda: self._vm_object.summary.guest.toolsRunningStatus == 'guestToolsRunning' )
def _wait_for_ssh_service(self, username, password): """ Wait until ssh service is ready :param username: SSH username :param password: SSH password """ timeout_loop(self.timeout, 'Check SSH service', 1, True, check_ssh_service, self.ip(), username, password)
def _wait_for_winrm_service(self, username, password, **kwargs): """ Wait until winrm service is ready :param username: WinRM username :param password: WinRM password :param kwargs: pywinrm Protocol kwargs """ timeout_loop(self.timeout, 'Check WinRM service', 1, True, check_winrm_service, self.ip(), username, password, **kwargs)
def ip(self): """ Poll vcenter to get the virtual machine IP :return: Return the ip """ if self._vm_object: if not self._vm_object.summary.guest.ipAddress: timeout_loop(self.timeout, 'Get IP', 1, False, lambda: self._vm_object.summary.guest.ipAddress) ip = self._vm_object.summary.guest.ipAddress validate_ip(ip) return ip
def test_timeout_loop_fail(): with pytest.raises(TimeoutError): timeout_loop(1, '', 1, False, lambda: False)
def test_timeout_loop_success(): timeout_loop(1, '', 1, False, lambda: True)
def wait_for_power_state_or_die(vm_object, state): timeout_loop(300, '', 1, True, lambda: vm_object.summary.runtime.powerState == state)