mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-30 13:03:46 +02:00
Fix IOU detection of layer 1 keepalive support. Fixes #1183.
This commit is contained in:
parent
67c78ba2e3
commit
1524493c33
@ -945,13 +945,13 @@ class IOUVM(BaseNode):
|
|||||||
if "IOURC" not in os.environ:
|
if "IOURC" not in os.environ:
|
||||||
env["IOURC"] = self.iourc_path
|
env["IOURC"] = self.iourc_path
|
||||||
try:
|
try:
|
||||||
output = yield from gns3server.utils.asyncio.subprocess_check_output(self._path, "-h", cwd=self.working_dir, env=env)
|
output = yield from gns3server.utils.asyncio.subprocess_check_output(self._path, "-h", cwd=self.working_dir, env=env, stderr=True)
|
||||||
if re.search("-l\s+Enable Layer 1 keepalive messages", output):
|
if re.search("-l\s+Enable Layer 1 keepalive messages", output):
|
||||||
command.extend(["-l"])
|
command.extend(["-l"])
|
||||||
else:
|
else:
|
||||||
raise IOUError("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path)))
|
raise IOUError("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path)))
|
||||||
except (OSError, subprocess.SubprocessError) as e:
|
except (OSError, subprocess.SubprocessError) as e:
|
||||||
log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e))
|
log.warning("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def startup_config_content(self):
|
def startup_config_content(self):
|
||||||
|
@ -41,18 +41,23 @@ def wait_run_in_executor(func, *args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def subprocess_check_output(*args, cwd=None, env=None):
|
def subprocess_check_output(*args, cwd=None, env=None, stderr=False):
|
||||||
"""
|
"""
|
||||||
Run a command and capture output
|
Run a command and capture output
|
||||||
|
|
||||||
:param *args: List of command arguments
|
:param *args: List of command arguments
|
||||||
:param cwd: Current working directory
|
:param cwd: Current working directory
|
||||||
:param env: Command environment
|
:param env: Command environment
|
||||||
|
:param stderr: Read on stderr
|
||||||
:returns: Command output
|
:returns: Command output
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc = yield from asyncio.create_subprocess_exec(*args, stdout=asyncio.subprocess.PIPE, cwd=cwd, env=env)
|
if stderr:
|
||||||
output = yield from proc.stdout.read()
|
proc = yield from asyncio.create_subprocess_exec(*args, stderr=asyncio.subprocess.PIPE, cwd=cwd, env=env)
|
||||||
|
output = yield from proc.stderr.read()
|
||||||
|
else:
|
||||||
|
proc = yield from asyncio.create_subprocess_exec(*args, stdout=asyncio.subprocess.PIPE, cwd=cwd, env=env)
|
||||||
|
output = yield from proc.stdout.read()
|
||||||
if output is None:
|
if output is None:
|
||||||
return ""
|
return ""
|
||||||
# If we received garbage we ignore invalid characters
|
# If we received garbage we ignore invalid characters
|
||||||
@ -60,7 +65,6 @@ def subprocess_check_output(*args, cwd=None, env=None):
|
|||||||
# and the code of VPCS, dynamips... Will detect it's not the correct binary
|
# and the code of VPCS, dynamips... Will detect it's not the correct binary
|
||||||
return output.decode("utf-8", errors="ignore")
|
return output.decode("utf-8", errors="ignore")
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def wait_for_process_termination(process, timeout=10):
|
def wait_for_process_termination(process, timeout=10):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user