Let the server know about the project name and convert old IOU projects on remote servers.

This commit is contained in:
grossmj committed 2015-03-08 19:13:01 -06:00
1 parent 2934232afb
commit 95766fa30d
5 files changed
+51 -17

No files matched your search

+13 -12
View File
@@ -162,8 +162,7 @@ class BaseManager:
"""
new_id = str(uuid4())
project_name = os.path.basename(project.path)
legacy_project_files_path = os.path.join(project.path, "{}-files".format(project_name))
legacy_project_files_path = os.path.join(project.path, "{}-files".format(project.name))
new_project_files_path = os.path.join(project.path, "project-files")
if os.path.exists(legacy_project_files_path) and not os.path.exists(new_project_files_path):
# move the project files
@@ -175,16 +174,18 @@ class BaseManager:
raise aiohttp.web.HTTPInternalServerError(text="Could not move project files directory: {} to {} {}".format(legacy_project_files_path,
new_project_files_path, e))
legacy_iou_dir = os.path.join(project.path, "iou")
new_iou_dir = os.path.join(project.path, "project-files", "iou")
if os.path.exists(legacy_iou_dir) and not os.path.exists(new_iou_dir):
# move the iou dir on remote server
try:
log.info('Moving "{}" to "{}"'.format(legacy_iou_dir, new_iou_dir))
yield from wait_run_in_executor(shutil.move, legacy_iou_dir, new_iou_dir)
except OSError as e:
raise aiohttp.web.HTTPInternalServerError(text="Could not move IOU directory: {} to {} {}".format(legacy_iou_dir,
new_iou_dir, e))
if project.is_local() is False:
legacy_remote_iou_project = os.path.join(project.location, project.name, "iou")
new_iou_project_path = os.path.join(project.path, "project-files", "iou")
if os.path.exists(legacy_remote_iou_project) and not os.path.exists(new_iou_project_path):
# move the legacy remote IOU project (remote servers only)
log.info("Converting old remote IOU project...")
try:
log.info('Moving "{}" to "{}"'.format(legacy_remote_iou_project, new_iou_project_path))
yield from wait_run_in_executor(shutil.move, legacy_remote_iou_project, new_iou_project_path)
except OSError as e:
raise aiohttp.web.HTTPInternalServerError(text="Could not move IOU directory: {} to {} {}".format(legacy_remote_iou_project,
new_iou_project_path, e))
if hasattr(self, "get_legacy_vm_workdir"):
# rename old project VM working dir
+19 -3
View File
@@ -41,8 +41,9 @@ class Project:
:param temporary: Boolean the project is a temporary project (destroy when closed)
"""
def __init__(self, project_id=None, path=None, location=None, temporary=False):
def __init__(self, name=None, project_id=None, path=None, location=None, temporary=False):
self._name = name
if project_id is None:
self._id = str(uuid4())
else:
@@ -75,6 +76,7 @@ class Project:
def __json__(self):
return {
"name": self._name,
"project_id": self._id,
"location": self._location,
"temporary": self._temporary,
@@ -85,6 +87,10 @@ class Project:
return Config.instance().get_section_config("Server")
def is_local(self):
return self._config().get("local", False)
@classmethod
def _get_default_project_directory(cls):
"""
@@ -113,7 +119,7 @@ class Project:
@location.setter
def location(self, location):
if location != self._location and self._config().get("local", False) is False:
if location != self._location and self.is_local() is False:
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory location")
self._location = location
@@ -127,12 +133,22 @@ class Project:
def path(self, path):
if hasattr(self, "_path"):
if path != self._path and self._config().get("local", False) is False:
if path != self._path and self.is_local() is False:
raise aiohttp.web.HTTPForbidden(text="You are not allowed to modify the project directory location")
self._path = path
self._update_temporary_file()
@property
def name(self):
return self._name
@name.setter
def name(self, name):
self._name = name
@property
def vms(self):
+2 -2
View File
@@ -60,7 +60,7 @@ class ProjectManager:
raise aiohttp.web.HTTPNotFound(text="Project ID {} doesn't exist".format(project_id))
return self._projects[project_id]
def create_project(self, project_id=None, path=None, temporary=False):
def create_project(self, name=None, project_id=None, path=None, temporary=False):
"""
Create a project and keep a references to it in project manager.
@@ -71,7 +71,7 @@ class ProjectManager:
return self._projects[project_id]
# FIXME: should we have an error?
#raise aiohttp.web.HTTPConflict(text="Project ID {} is already in use on this server".format(project_id))
project = Project(project_id=project_id, path=path, temporary=temporary)
project = Project(name=name, project_id=project_id, path=path, temporary=temporary)
self._projects[project.id] = project
return project