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

Strip user from compute in topology and return project filename

This commit is contained in:
Julien Duponchelle 2016-06-15 18:22:11 +02:00
parent c4d619ce3c
commit aa5988788d
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
5 changed files with 14 additions and 8 deletions

View File

@ -238,8 +238,7 @@ class Compute:
"name": self._name,
"protocol": self._protocol,
"host": self._host,
"port": self._port,
"user": self._user
"port": self._port
}
return {
"compute_id": self._id,

View File

@ -322,12 +322,14 @@ class Project:
raise aiohttp.web.HTTPInternalServerError(text="Could not create project directory: {}".format(e))
return path
def _topology_file(self):
def _filename(self):
if self.name is None:
filename = "untitled.gns3"
return "untitled.gns3"
else:
filename = self.name + ".gns3"
return os.path.join(self.path, filename)
return self.name + ".gns3"
def _topology_file(self):
return os.path.join(self.path, self._filename())
@asyncio.coroutine
def open(self):
@ -371,5 +373,6 @@ class Project:
"name": self._name,
"project_id": self._id,
"path": self._path,
"filename": self._filename(),
"status": self._status
}

View File

@ -82,6 +82,11 @@ PROJECT_OBJECT_SCHEMA = {
"type": ["string", "null"],
"minLength": 1
},
"filename": {
"description": "Project filename",
"type": ["string", "null"],
"minLength": 1
},
"status": {
"description": "Project status Read only",
"enum": ["opened", "closed"]

View File

@ -211,7 +211,6 @@ def test_json(compute):
"protocol": "https",
"host": "example.com",
"port": 84,
"user": "test",
}

View File

@ -43,7 +43,7 @@ def test_affect_uuid():
def test_json(tmpdir):
p = Project()
assert p.__json__() == {"name": p.name, "project_id": p.id, "path": p.path, "status": "opened"}
assert p.__json__() == {"name": p.name, "project_id": p.id, "path": p.path, "status": "opened", "filename": "untitled.gns3"}
def test_path(tmpdir):