mirror of
https://github.com/GNS3/gns3-server
synced 2025-02-26 07:02:12 +00:00
Linked clone support for VirtualBox (still problems with temporary projects).
This commit is contained in:
parent
2509ee70e8
commit
5a7e482dac
@ -197,7 +197,7 @@ class VirtualBox(IModule):
|
|||||||
self._working_dir = new_working_dir
|
self._working_dir = new_working_dir
|
||||||
for vbox_id in self._vbox_instances:
|
for vbox_id in self._vbox_instances:
|
||||||
vbox_instance = self._vbox_instances[vbox_id]
|
vbox_instance = self._vbox_instances[vbox_id]
|
||||||
vbox_instance.working_dir = os.path.join(self._working_dir, "vbox", "vm-{}".format(vbox_instance.id))
|
vbox_instance.working_dir = os.path.join(self._working_dir, "vbox", "{}".format(vbox_instance.name))
|
||||||
|
|
||||||
if "vboxmanage_path" in request:
|
if "vboxmanage_path" in request:
|
||||||
self._vboxmanage_path = request["vboxmanage_path"]
|
self._vboxmanage_path = request["vboxmanage_path"]
|
||||||
|
@ -303,7 +303,7 @@ class VirtualBoxVM(object):
|
|||||||
for hdd_info in hdd_table:
|
for hdd_info in hdd_table:
|
||||||
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):
|
||||||
print("Reattaching: {}".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"],
|
||||||
@ -322,6 +322,7 @@ class VirtualBoxVM(object):
|
|||||||
self._allocated_console_ports.remove(self.console)
|
self._allocated_console_ports.remove(self.console)
|
||||||
|
|
||||||
if self._linked_clone:
|
if self._linked_clone:
|
||||||
|
if os.path.exists(self._working_dir):
|
||||||
hdd_table = []
|
hdd_table = []
|
||||||
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()
|
||||||
@ -343,7 +344,8 @@ class VirtualBoxVM(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._execute("unregistervm", [self._vmname])
|
self._execute("unregistervm", [self._vmname])
|
||||||
print(self._working_dir)
|
|
||||||
|
if hdd_table:
|
||||||
try:
|
try:
|
||||||
hdd_info_file = os.path.join(self._working_dir, self._vmname, "hdd_info.json")
|
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") as f:
|
||||||
@ -353,7 +355,6 @@ class VirtualBoxVM(object):
|
|||||||
raise VirtualBoxError("Could not write HDD info file: {}".format(e))
|
raise VirtualBoxError("Could not write HDD info file: {}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log.info("VirtualBox VM {name} [id={id}] has been deleted".format(name=self._name,
|
log.info("VirtualBox VM {name} [id={id}] has been deleted".format(name=self._name,
|
||||||
id=self._id))
|
id=self._id))
|
||||||
|
|
||||||
@ -743,6 +744,9 @@ class VirtualBoxVM(object):
|
|||||||
self._modify_vm("--nic{} none".format(adapter_id + 1))
|
self._modify_vm("--nic{} none".format(adapter_id + 1))
|
||||||
|
|
||||||
def _create_linked_clone(self):
|
def _create_linked_clone(self):
|
||||||
|
"""
|
||||||
|
Creates a new linked clone.
|
||||||
|
"""
|
||||||
|
|
||||||
gns3_snapshot_exists = False
|
gns3_snapshot_exists = False
|
||||||
vm_info = self._get_vm_info()
|
vm_info = self._get_vm_info()
|
||||||
@ -752,8 +756,7 @@ class VirtualBoxVM(object):
|
|||||||
|
|
||||||
if not gns3_snapshot_exists:
|
if not gns3_snapshot_exists:
|
||||||
result = self._execute("snapshot", [self._vmname, "take", "GNS3 Linked Base for clones"])
|
result = self._execute("snapshot", [self._vmname, "take", "GNS3 Linked Base for clones"])
|
||||||
print(result)
|
log.debug("GNS3 snapshot created: {}".format(result))
|
||||||
#log.debug("cloned VirtualBox VM: {}".format(result))
|
|
||||||
|
|
||||||
args = [self._vmname,
|
args = [self._vmname,
|
||||||
"--snapshot",
|
"--snapshot",
|
||||||
|
Loading…
Reference in New Issue
Block a user