Merge branch '2.0' into 2.1

This commit is contained in:
Julien Duponchelle committed 2017-02-28 14:25:38 +01:00
commit 1ab9ca2333
29 files changed
+548 -55

No files matched your search

@@ -211,7 +211,8 @@ class EthernetSwitch(Device):
nio = self._nios[port_number]
if isinstance(nio, NIOUDP):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
yield from self._hypervisor.send('ethsw remove_nio "{name}" {nio}'.format(name=self._name, nio=nio))
if self._hypervisor:
yield from self._hypervisor.send('ethsw remove_nio "{name}" {nio}'.format(name=self._name, nio=nio))
log.info('Ethernet switch "{name}" [{id}]: NIO {nio} removed from port {port}'.format(name=self._name,
id=self._id,
+2 -1
View File
@@ -24,6 +24,7 @@ import asyncio
import time
import sys
import os
import re
import glob
import shlex
import base64
@@ -1474,7 +1475,7 @@ class Router(BaseNode):
try:
with open(startup_config_path, "r+", encoding="utf-8", errors="replace") as f:
old_config = f.read()
new_config = old_config.replace(self.name, new_name)
new_config = re.sub(r"^hostname .+$", "hostname " + new_name, old_config, flags=re.MULTILINE)
f.seek(0)
f.write(new_config)
except OSError as e:
+2 -2
View File
@@ -301,7 +301,7 @@ class IOUVM(BaseNode):
if self.startup_config_file:
content = self.startup_config_content
content = content.replace(self._name, new_name)
content = re.sub(r"^hostname .+$", "hostname " + new_name, content, flags=re.MULTILINE)
self.startup_config_content = content
super(IOUVM, IOUVM).name.__set__(self, new_name)
@@ -1161,7 +1161,7 @@ class IOUVM(BaseNode):
bay=adapter_number,
unit=port_number,
output_file=output_file,
data_link_type=data_link_type))
data_link_type=re.sub("^DLT_", "", data_link_type)))
@asyncio.coroutine
def stop_capture(self, adapter_number, port_number):
@@ -303,6 +303,16 @@ class VirtualBoxVM(BaseNode):
if self.acpi_shutdown:
# use ACPI to shutdown the VM
result = yield from self._control_vm("acpipowerbutton")
trial = 0
while True:
vm_state = yield from self._get_vm_state()
if vm_state == "poweroff":
break
yield from asyncio.sleep(1)
trial += 1
if trial >= 120:
yield from self._control_vm("poweroff")
break
self.status = "stopped"
log.debug("ACPI shutdown result: {}".format(result))
else:
+8 -8
View File
@@ -104,7 +104,7 @@ class VPCSVM(BaseNode):
Check if VPCS is available with the correct version.
"""
path = self.vpcs_path
path = self._vpcs_path()
if not path:
raise VPCSError("No path to a VPCS executable has been set")
@@ -144,8 +144,7 @@ class VPCSVM(BaseNode):
else:
return None
@property
def vpcs_path(self):
def _vpcs_path(self):
"""
Returns the VPCS executable path.
@@ -170,6 +169,7 @@ class VPCSVM(BaseNode):
if self.script_file:
content = self.startup_script
content = content.replace(self._name, new_name)
content = re.sub(r"^set pcname .+$", "set pcname " + new_name, content, flags=re.MULTILINE)
self.startup_script = content
super(VPCSVM, VPCSVM).name.__set__(self, new_name)
@@ -215,7 +215,7 @@ class VPCSVM(BaseNode):
Checks if the VPCS executable version is >= 0.8b or == 0.6.1.
"""
try:
output = yield from subprocess_check_output(self.vpcs_path, "-v", cwd=self.working_dir)
output = yield from subprocess_check_output(self._vpcs_path(), "-v", cwd=self.working_dir)
match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output)
if match:
version = match.group(1)
@@ -223,7 +223,7 @@ class VPCSVM(BaseNode):
if self._vpcs_version < parse_version("0.6.1"):
raise VPCSError("VPCS executable version must be >= 0.6.1 but not a 0.8")
else:
raise VPCSError("Could not determine the VPCS version for {}".format(self.vpcs_path))
raise VPCSError("Could not determine the VPCS version for {}".format(self._vpcs_path()))
except (OSError, subprocess.SubprocessError) as e:
raise VPCSError("Error while looking for the VPCS version: {}".format(e))
@@ -268,8 +268,8 @@ class VPCSVM(BaseNode):
self.status = "started"
except (OSError, subprocess.SubprocessError) as e:
vpcs_stdout = self.read_vpcs_stdout()
log.error("Could not start VPCS {}: {}\n{}".format(self.vpcs_path, e, vpcs_stdout))
raise VPCSError("Could not start VPCS {}: {}\n{}".format(self.vpcs_path, e, vpcs_stdout))
log.error("Could not start VPCS {}: {}\n{}".format(self._vpcs_path(), e, vpcs_stdout))
raise VPCSError("Could not start VPCS {}: {}\n{}".format(self._vpcs_path(), e, vpcs_stdout))
def _termination_callback(self, returncode):
"""
@@ -512,7 +512,7 @@ class VPCSVM(BaseNode):
"""
command = [self.vpcs_path]
command = [self._vpcs_path()]
command.extend(["-p", str(self._internal_console_port)]) # listen to console port
command.extend(["-m", str(self._manager.get_mac_id(self.id))]) # the unique ID is used to set the MAC address offset
command.extend(["-i", "1"]) # option to start only one VPC instance