mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix project path
This commit is contained in:
1 parent
ba91cbaac0
commit
df31b2ad5a
9 files changed
+18
-18
No files matched your search
@@ -25,6 +25,7 @@ import struct
|
||||
import socket
|
||||
import stat
|
||||
import time
|
||||
import aiohttp
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -87,7 +87,7 @@ class BaseVM:
|
||||
Return VM working directory
|
||||
"""
|
||||
|
||||
return self._project.vm_working_directory(self._uuid)
|
||||
return self._project.vm_working_directory(self.module_name, self._uuid)
|
||||
|
||||
def create(self):
|
||||
"""
|
||||
|
||||
@@ -148,9 +148,9 @@ class PortManager:
|
||||
continue
|
||||
|
||||
raise HTTPConflict(text="Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port,
|
||||
end_port,
|
||||
host,
|
||||
last_exception))
|
||||
end_port,
|
||||
host,
|
||||
last_exception))
|
||||
|
||||
def get_free_console_port(self):
|
||||
"""
|
||||
|
||||
@@ -45,11 +45,9 @@ class Project:
|
||||
if location is None:
|
||||
self._location = tempfile.mkdtemp()
|
||||
|
||||
self._path = os.path.join(self._location, self._uuid, "vms")
|
||||
self._path = os.path.join(self._location, self._uuid)
|
||||
try:
|
||||
os.makedirs(self._path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
os.makedirs(os.path.join(self._path, 'vms'), exist_ok=True)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not create project directory: {}".format(e))
|
||||
|
||||
@@ -68,22 +66,23 @@ class Project:
|
||||
|
||||
return self._path
|
||||
|
||||
def vm_working_directory(self, vm_uuid):
|
||||
def vm_working_directory(self, module, vm_uuid):
|
||||
"""
|
||||
Return a working directory for a specific VM.
|
||||
If the directory doesn't exist, the directory is created.
|
||||
|
||||
:param module: The module name (vpcs, dynamips...)
|
||||
:param vm_uuid: VM UUID
|
||||
"""
|
||||
|
||||
path = os.path.join(self._path, "vms", vm_uuid)
|
||||
p = os.path.join(self._path, "vms", module, vm_uuid)
|
||||
try:
|
||||
os.makedirs(self._path)
|
||||
os.makedirs(p, exist_ok=True)
|
||||
except FileExistsError:
|
||||
pass
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPInternalServerError(text="Could not create VM working directory: {}".format(e))
|
||||
return path
|
||||
return p
|
||||
|
||||
def __json__(self):
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import shutil
|
||||
|
||||
from .virtualbox_error import VirtualBoxError
|
||||
from ..adapters.ethernet_adapter import EthernetAdapter
|
||||
from ..attic import find_unused_port
|
||||
from .telnet_server import TelnetServer
|
||||
from ..base_vm import BaseVM
|
||||
|
||||
@@ -105,7 +104,6 @@ class VirtualBoxVM(BaseVM):
|
||||
# create the device own working directory
|
||||
self.working_dir = working_dir_path
|
||||
|
||||
|
||||
if linked_clone:
|
||||
if vbox_id and os.path.isdir(os.path.join(self.working_dir, self._vmname)):
|
||||
vbox_file = os.path.join(self.working_dir, self._vmname, self._vmname + ".vbox")
|
||||
|
||||
@@ -43,6 +43,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VPCSVM(BaseVM):
|
||||
module_name = 'vpcs'
|
||||
|
||||
"""
|
||||
VPCS vm implementation.
|
||||
|
||||
Reference in new issue
Block a user