Pass *args to VM_CLASS.

Move Config the the base manager.
More checks for projects (UUID,  makedirs).
Return error 500 when a VMError exception is raised.
Some more progress to VirtualBox.
This commit is contained in:
Jeremy
2015-01-20 19:02:22 -07:00
parent 3530b85b56
commit 7a19c9062e
11 changed files with 95 additions and 82 deletions

View File

@ -17,6 +17,7 @@
import aiohttp
from .project import Project
from uuid import UUID
class ProjectManager:
@ -40,20 +41,23 @@ class ProjectManager:
cls._instance = cls()
return cls._instance
def get_project(self, project_id):
def get_project(self, project_uuid):
"""
Returns a Project instance.
:param project_id: Project identifier
:param project_uuid: Project UUID
:returns: Project instance
"""
assert len(project_id) == 36
try:
UUID(project_uuid, version=4)
except ValueError:
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(project_uuid))
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]
if project_uuid not in self._projects:
raise aiohttp.web.HTTPNotFound(text="Project UUID {} doesn't exist".format(project_uuid))
return self._projects[project_uuid]
def create_project(self, **kwargs):
"""