From 29896151e7724d9bd45e6cd83bff38a3bea12ddd Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 6 Jan 2015 15:31:50 -0700 Subject: [PATCH] Support spaces in the controller name of VirtualBox clones. --- gns3server/modules/virtualbox/__init__.py | 2 +- gns3server/modules/virtualbox/virtualbox_vm.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gns3server/modules/virtualbox/__init__.py b/gns3server/modules/virtualbox/__init__.py index 00b15c28..09f8054e 100644 --- a/gns3server/modules/virtualbox/__init__.py +++ b/gns3server/modules/virtualbox/__init__.py @@ -731,7 +731,7 @@ class VirtualBox(IModule): result = subprocess.check_output(command, stderr=subprocess.STDOUT, timeout=60) else: 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: raise VirtualBoxError("Could not execute VBoxManage {}".format(e)) return result.decode("utf-8", errors="ignore") diff --git a/gns3server/modules/virtualbox/virtualbox_vm.py b/gns3server/modules/virtualbox/virtualbox_vm.py index e3257970..2ff943f5 100644 --- a/gns3server/modules/virtualbox/virtualbox_vm.py +++ b/gns3server/modules/virtualbox/virtualbox_vm.py @@ -305,10 +305,10 @@ class VirtualBoxVM(object): hdd_file = os.path.join(self._working_dir, self._vmname, "Snapshots", hdd_info["hdd"]) if os.path.exists(hdd_file): log.debug("reattaching hdd {}".format(hdd_file)) - self._storage_attach('--storagectl {} --port {} --device {} --type hdd --medium "{}"'.format(hdd_info["controller"], - hdd_info["port"], - hdd_info["device"], - hdd_file)) + self._storage_attach('--storagectl "{}" --port {} --device {} --type hdd --medium "{}"'.format(hdd_info["controller"], + hdd_info["port"], + hdd_info["device"], + hdd_file)) def delete(self): """ @@ -328,13 +328,13 @@ class VirtualBoxVM(object): hdd_files = self._get_all_hdd_files() vm_info = self._get_vm_info() for entry, value in vm_info.items(): - match = re.search("^(\w+)\-(\d)\-(\d)$", entry) + match = re.search("^([\s\w]+)\-(\d)\-(\d)$", entry) if match: controller = match.group(1) port = match.group(2) device = match.group(3) 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": os.path.basename(value),