def waiton(self, timeout=DEFAULT_SERVER_WAIT_ON_TIMEOUT):
"""Wait until device is fully operational.
Args:
timeout(int): Wait timeout
Raises:
SwitchException: device doesn't response
Returns:
dict: Status dictionary from probe method or raise an exception.
"""
status = None
message = "Waiting until device {0}({1}) is up.".format(self.name, self.ipaddr)
self.class_logger.info(message)
stop_flag = False
end_time = time.time() + timeout
while not stop_flag:
if loggers.LOG_STREAM:
sys.stdout.write(".")
sys.stdout.flush()
if time.time() < end_time:
# While time isn't elapsed continue probing switch.
try:
status = self.probe()
except KeyboardInterrupt:
message = "KeyboardInterrupt while checking switch {0}({1})...".format(
self.name, self.ipaddr)
self.class_logger.info(message)
self.sanitize()
pytest.exit(message)
if status["isup"]:
stop_flag = True
else:
# Time is elapsed.
port = self._get_port_for_probe()
message = "Timeout exceeded. IP address {0} port {1} doesn't respond.".format(
self.ipaddr, port)
self.class_logger.warning(message)
raise Exception(message)
if not stop_flag:
time.sleep(0.75)
return status
评论列表
文章目录