mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix tests
This commit is contained in:
1 parent
927e6b540d
commit
0695e75e77
14 files changed
+139
-84
No files matched your search
@@ -20,6 +20,7 @@ import asyncio
|
||||
import aiohttp
|
||||
|
||||
from uuid import UUID, uuid4
|
||||
from .project_manager import ProjectManager
|
||||
|
||||
|
||||
class BaseManager:
|
||||
@@ -85,16 +86,24 @@ class BaseManager:
|
||||
return self._vms[uuid]
|
||||
|
||||
@asyncio.coroutine
|
||||
def create_vm(self, name, uuid=None):
|
||||
def create_vm(self, name, project_identifier, uuid=None):
|
||||
"""
|
||||
Create a new VM
|
||||
|
||||
#TODO: support for old projects with normal IDs.
|
||||
:param name VM name
|
||||
:param project_identifier UUID of Project
|
||||
:param uuid Force UUID force VM
|
||||
"""
|
||||
project = ProjectManager.instance().get_project(project_identifier)
|
||||
|
||||
#TODO: support for old projects VM with normal IDs.
|
||||
|
||||
#TODO: supports specific args: pass kwargs to VM_CLASS?
|
||||
|
||||
if not uuid:
|
||||
uuid = str(uuid4())
|
||||
|
||||
vm = self._VM_CLASS(name, uuid, self)
|
||||
vm = self._VM_CLASS(name, uuid, project, self)
|
||||
future = vm.create()
|
||||
if isinstance(future, asyncio.Future):
|
||||
yield from future
|
||||
|
||||
@@ -23,15 +23,21 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class BaseVM:
|
||||
|
||||
def __init__(self, name, uuid, manager):
|
||||
def __init__(self, name, uuid, project, manager):
|
||||
|
||||
self._name = name
|
||||
self._uuid = uuid
|
||||
self._project = project
|
||||
self._manager = manager
|
||||
self._config = Config.instance()
|
||||
|
||||
#TODO: When delete release console ports
|
||||
|
||||
@property
|
||||
def project(self):
|
||||
"""Return VM current project"""
|
||||
return self._project
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
|
||||
@@ -34,6 +34,7 @@ class Project:
|
||||
if uuid is None:
|
||||
self._uuid = str(uuid4())
|
||||
else:
|
||||
assert len(uuid) == 36
|
||||
self._uuid = uuid
|
||||
|
||||
self._location = location
|
||||
|
||||
@@ -48,6 +48,8 @@ class ProjectManager:
|
||||
:returns: Project instance
|
||||
"""
|
||||
|
||||
assert len(project_id) == 36
|
||||
|
||||
if project_id not in self._projects:
|
||||
raise aiohttp.web.HTTPNotFound(text="Project UUID {} doesn't exist".format(project_id))
|
||||
return self._projects[project_id]
|
||||
|
||||
@@ -48,22 +48,22 @@ class VPCSDevice(BaseVM):
|
||||
|
||||
:param name: name of this VPCS device
|
||||
:param uuid: VPCS instance UUID
|
||||
:param project: Project instance
|
||||
:param manager: parent VM Manager
|
||||
:param working_dir: path to a working directory
|
||||
:param console: TCP console port
|
||||
"""
|
||||
def __init__(self, name, uuid, manager, working_dir=None, console=None):
|
||||
def __init__(self, name, uuid, project, manager, working_dir=None, console=None):
|
||||
|
||||
super().__init__(name, uuid, manager)
|
||||
|
||||
# TODO: Hardcodded for testing
|
||||
#self._working_dir = working_dir
|
||||
self._working_dir = "/tmp"
|
||||
super().__init__(name, uuid, project, manager)
|
||||
|
||||
self._path = self._config.get_section_config("VPCS").get("path", "vpcs")
|
||||
|
||||
self._console = console
|
||||
|
||||
#TODO: remove working_dir
|
||||
self._working_dir = "/tmp"
|
||||
|
||||
self._command = []
|
||||
self._process = None
|
||||
self._vpcs_stdout_file = ""
|
||||
|
||||
Reference in new issue
Block a user