Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
fixed timeout and condition
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Oct 26, 2023
1 parent b7ce2ee commit 1e07925
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ def check_server_status(self, openstack_id: str) -> VM:
serv = server.to_dict()

try:
if serv["status"] == self.ACTIVE:
if serv["status"] == self.ACTIVE and serv["task_state"] not in ["powering-off", "powering-on"]:
host = self.get_server(openstack_id).floating_ip
port = self.SSH_PORT

Expand Down Expand Up @@ -2528,8 +2528,10 @@ def netcat(self, host, port):
:return: True if successfully connected, False if not
"""
self.LOG.info(f"Checking SSH Connection {host}:{port}")
if serv["status"] == self.ACTIVE and serv["task_state"] not in ["powering-off", "powering-on"]:

with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(2500)
sock.settimeout(5)
try:
r = sock.connect_ex((host, port))
self.LOG.info(f"Checking SSH Connection {host}:{port} Result = {r}")
Expand Down

0 comments on commit 1e07925

Please sign in to comment.