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

Use HDD disk image as startup QEMU config disk

This commit is contained in:
Bernhard Ehlers 2020-10-19 03:19:22 +02:00
parent 4843084158
commit de2b9caeeb

View File

@ -1722,11 +1722,21 @@ class QemuVM(BaseNode):
async def _import_config(self): async def _import_config(self):
disk_name = getattr(self, "config_disk_name") disk_name = getattr(self, "config_disk_name")
if not disk_name:
return
disk = os.path.join(self.working_dir, disk_name)
zip_file = os.path.join(self.working_dir, "config.zip") zip_file = os.path.join(self.working_dir, "config.zip")
if not disk_name or not os.path.exists(zip_file): startup_config = self.hdd_disk_image
if startup_config and startup_config.lower().endswith(".zip") and \
not os.path.exists(zip_file) and not os.path.exists(disk):
try:
shutil.copyfile(startup_config, zip_file)
except OSError as e:
log.warning("Can't access startup config: {}".format(e))
self.project.emit("log.warning", {"message": "{}: Can't access startup config: {}".format(self._name, e)})
if not os.path.exists(zip_file):
return return
config_dir = os.path.join(self.working_dir, "configs") config_dir = os.path.join(self.working_dir, "configs")
disk = os.path.join(self.working_dir, disk_name)
disk_tmp = disk + ".tmp" disk_tmp = disk + ".tmp"
try: try:
os.mkdir(config_dir) os.mkdir(config_dir)