1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Support spaces in the controller name of VirtualBox clones.

This commit is contained in:
Jeremy 2015-01-06 15:31:50 -07:00
parent 7f6f7022b0
commit 29896151e7
2 changed files with 7 additions and 7 deletions

View File

@ -731,7 +731,7 @@ class VirtualBox(IModule):
result = subprocess.check_output(command, stderr=subprocess.STDOUT, timeout=60) result = subprocess.check_output(command, stderr=subprocess.STDOUT, timeout=60)
else: else:
sudo_command = "sudo -i -u " + user.strip() + " " + " ".join(command) sudo_command = "sudo -i -u " + user.strip() + " " + " ".join(command)
result = subprocess.check_output(sudo_command, stderr=subprocess.STDOUT, shell=True, timeout=30) result = subprocess.check_output(sudo_command, stderr=subprocess.STDOUT, shell=True, timeout=60)
except (OSError, subprocess.SubprocessError) as e: except (OSError, subprocess.SubprocessError) as e:
raise VirtualBoxError("Could not execute VBoxManage {}".format(e)) raise VirtualBoxError("Could not execute VBoxManage {}".format(e))
return result.decode("utf-8", errors="ignore") return result.decode("utf-8", errors="ignore")

View File

@ -305,10 +305,10 @@ class VirtualBoxVM(object):
hdd_file = os.path.join(self._working_dir, self._vmname, "Snapshots", hdd_info["hdd"]) hdd_file = os.path.join(self._working_dir, self._vmname, "Snapshots", hdd_info["hdd"])
if os.path.exists(hdd_file): if os.path.exists(hdd_file):
log.debug("reattaching hdd {}".format(hdd_file)) log.debug("reattaching hdd {}".format(hdd_file))
self._storage_attach('--storagectl {} --port {} --device {} --type hdd --medium "{}"'.format(hdd_info["controller"], self._storage_attach('--storagectl "{}" --port {} --device {} --type hdd --medium "{}"'.format(hdd_info["controller"],
hdd_info["port"], hdd_info["port"],
hdd_info["device"], hdd_info["device"],
hdd_file)) hdd_file))
def delete(self): def delete(self):
""" """
@ -328,13 +328,13 @@ class VirtualBoxVM(object):
hdd_files = self._get_all_hdd_files() hdd_files = self._get_all_hdd_files()
vm_info = self._get_vm_info() vm_info = self._get_vm_info()
for entry, value in vm_info.items(): for entry, value in vm_info.items():
match = re.search("^(\w+)\-(\d)\-(\d)$", entry) match = re.search("^([\s\w]+)\-(\d)\-(\d)$", entry)
if match: if match:
controller = match.group(1) controller = match.group(1)
port = match.group(2) port = match.group(2)
device = match.group(3) device = match.group(3)
if value in hdd_files: if value in hdd_files:
self._storage_attach("--storagectl {} --port {} --device {} --type hdd --medium none".format(controller, port, device)) self._storage_attach('--storagectl "{}" --port {} --device {} --type hdd --medium none'.format(controller, port, device))
hdd_table.append( hdd_table.append(
{ {
"hdd": os.path.basename(value), "hdd": os.path.basename(value),