mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Wait more time for ioucon thread to be completed. Prevent IOS to be
started or stopped if the status isn't right.
This commit is contained in:
1 parent
9b55a8623c
commit
6a839c4b7b
5 files changed
+66
-40
No files matched your search
@@ -22,10 +22,10 @@ Manages Dynamips hypervisors (load-balancing etc.)
|
||||
from .hypervisor import Hypervisor
|
||||
from .dynamips_error import DynamipsError
|
||||
from ..attic import find_unused_port
|
||||
from ..attic import wait_socket_is_ready
|
||||
from pkg_resources import parse_version
|
||||
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
import logging
|
||||
|
||||
@@ -513,26 +513,9 @@ class HypervisorManager(object):
|
||||
:param timeout: timeout value (default is 10 seconds)
|
||||
"""
|
||||
|
||||
# connect to a local address by default
|
||||
# if listening to all addresses (IPv4 or IPv6)
|
||||
if host == "0.0.0.0":
|
||||
host = "127.0.0.1"
|
||||
elif host == "::":
|
||||
host = "::1"
|
||||
|
||||
connection_success = False
|
||||
begin = time.time()
|
||||
# try to connect for 10 seconds
|
||||
while(time.time() - begin < 10.0):
|
||||
time.sleep(0.01)
|
||||
try:
|
||||
with socket.create_connection((host, port), timeout):
|
||||
pass
|
||||
except OSError as e:
|
||||
last_exception = e
|
||||
continue
|
||||
connection_success = True
|
||||
break
|
||||
# wait for the socket for a maximum of 10 seconds.
|
||||
connection_success, last_exception = wait_socket_is_ready(host, port, wait=10.0)
|
||||
|
||||
if not connection_success:
|
||||
# FIXME: throw exception here
|
||||
|
||||
@@ -313,9 +313,10 @@ class Router(object):
|
||||
At least the IOS image must be set before starting it.
|
||||
"""
|
||||
|
||||
if self.get_status() == "suspended":
|
||||
status = self.get_status()
|
||||
if status == "suspended":
|
||||
self.resume()
|
||||
else:
|
||||
elif status == "inactive":
|
||||
|
||||
if not os.path.isfile(self._image):
|
||||
raise DynamipsError("IOS image '{}' is not accessible".format(self._image))
|
||||
@@ -340,8 +341,9 @@ class Router(object):
|
||||
The settings are kept.
|
||||
"""
|
||||
|
||||
self._hypervisor.send("vm stop {}".format(self._name))
|
||||
log.info("router {name} [id={id}] has been stopped".format(name=self._name, id=self._id))
|
||||
if self.get_status() != "inactive":
|
||||
self._hypervisor.send("vm stop {}".format(self._name))
|
||||
log.info("router {name} [id={id}] has been stopped".format(name=self._name, id=self._id))
|
||||
|
||||
def suspend(self):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user