Merge branch 'master' into unstable

Conflicts:
	tests/modules/test_manager.py
This commit is contained in:
Julien Duponchelle committed 2015-04-28 10:46:59 +02:00
commit 5f6d1bfdd6
43 files changed
+608 -677

No files matched your search

+1 -1
View File
@@ -110,7 +110,6 @@ class VirtualBox(BaseManager):
raise VirtualBoxError("VBoxManage has timed out after {} seconds!".format(timeout))
if process.returncode:
# only the first line of the output is useful
vboxmanage_error = stderr_data.decode("utf-8", errors="ignore")
raise VirtualBoxError("VirtualBox has returned an error: {}".format(vboxmanage_error))
@@ -133,6 +132,7 @@ class VirtualBox(BaseManager):
if not extra_data[0].strip() == "Value: yes":
# get the amount of RAM
info_results = yield from self.execute("showvminfo", [vmname, "--machinereadable"])
ram = 0
for info in info_results:
try:
name, value = info.split('=', 1)
+17 -7
View File
@@ -209,7 +209,7 @@ class VirtualBoxVM(BaseVM):
log.info("VirtualBox VM '{name}' [{id}] stopped".format(name=self.name, id=self.id))
log.debug("Stop result: {}".format(result))
yield from asyncio.sleep(0.5) # give some time for VirtualBox to unlock the VM
# yield from asyncio.sleep(0.5) # give some time for VirtualBox to unlock the VM
try:
# deactivate the first serial port
yield from self._modify_vm("--uart1 off")
@@ -276,7 +276,7 @@ class VirtualBoxVM(BaseVM):
hdd_info_file = os.path.join(self.working_dir, self._vmname, "hdd_info.json")
try:
with open(hdd_info_file, "r") as f:
with open(hdd_info_file, "r", encoding="utf-8") as f:
hdd_table = json.load(f)
except OSError as e:
raise VirtualBoxError("Could not read HDD info file: {}".format(e))
@@ -321,6 +321,7 @@ class VirtualBoxVM(BaseVM):
if self._linked_clone:
hdd_table = []
hdd_files_to_close = []
if os.path.exists(self.working_dir):
hdd_files = yield from self._get_all_hdd_files()
vm_info = yield from self._get_vm_info()
@@ -331,6 +332,7 @@ class VirtualBoxVM(BaseVM):
port = match.group(2)
device = match.group(3)
if value in hdd_files:
hdd_files_to_close.append(value)
log.info("VirtualBox VM '{name}' [{id}] detaching HDD {controller} {port} {device}".format(name=self.name,
id=self.id,
controller=controller,
@@ -351,10 +353,16 @@ class VirtualBoxVM(BaseVM):
log.info("VirtualBox VM '{name}' [{id}] unregistering".format(name=self.name, id=self.id))
yield from self.manager.execute("unregistervm", [self._name])
for hdd_file in hdd_files_to_close:
log.info("VirtualBox VM '{name}' [{id}] closing disk {disk}".format(name=self.name,
id=self.id,
disk=os.path.basename(hdd_file)))
yield from self.manager.execute("closemedium", ["disk", hdd_file])
if hdd_table:
try:
hdd_info_file = os.path.join(self.working_dir, self._vmname, "hdd_info.json")
with open(hdd_info_file, "w") as f:
with open(hdd_info_file, "w", encoding="utf-8") as f:
json.dump(hdd_table, f, indent=4)
except OSError as e:
log.warning("VirtualBox VM '{name}' [{id}] could not write HHD info file: {error}".format(name=self.name,
@@ -586,12 +594,14 @@ class VirtualBoxVM(BaseVM):
:returns: pipe path (string)
"""
p = re.compile('\s+', re.UNICODE)
pipe_name = p.sub("_", self._vmname)
if sys.platform.startswith("win"):
pipe_name = r"\\.\pipe\VBOX\{}".format(pipe_name)
pipe_name = r"\\.\pipe\gns3_vbox\{}".format(self.id)
else:
pipe_name = os.path.join(tempfile.gettempdir(), "pipe_{}".format(pipe_name))
pipe_name = os.path.join(tempfile.gettempdir(), "gns3_vbox", "{}".format(self.id))
try:
os.makedirs(os.path.dirname(pipe_name), exist_ok=True)
except OSError as e:
raise VirtualBoxError("Could not create the VirtualBox pipe directory: {}".format(e))
return pipe_name
@asyncio.coroutine