Merge branch '1.5' into 2.0

This commit is contained in:
Julien Duponchelle
2016-05-24 10:13:53 +02:00
10 changed files with 69 additions and 32 deletions

View File

@ -19,6 +19,7 @@
Represents a Dynamips hypervisor and starts/stops the associated Dynamips process.
"""
import sys
import os
import subprocess
import asyncio
@ -117,6 +118,12 @@ class Hypervisor(DynamipsHypervisor):
"""
self._command = self._build_command()
env = os.environ.copy()
if sys.platform.startswith("win"):
# add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if installed)
system_root = os.path.join(os.path.expandvars("%SystemRoot%"), "System32", "Npcap")
if os.path.isdir(system_root):
env["PATH"] = system_root + ';' + env["PATH"]
try:
log.info("Starting Dynamips: {}".format(self._command))
self._stdout_file = os.path.join(self.working_dir, "dynamips_i{}_stdout.txt".format(self._id))
@ -125,7 +132,8 @@ class Hypervisor(DynamipsHypervisor):
self._process = yield from asyncio.create_subprocess_exec(*self._command,
stdout=fd,
stderr=subprocess.STDOUT,
cwd=self._working_dir)
cwd=self._working_dir,
env=env)
log.info("Dynamips process started PID={}".format(self._process.pid))
self._started = True
except (OSError, subprocess.SubprocessError) as e: