mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Export vpcs config path
This commit is contained in:
parent
985c23a40e
commit
ebb865d973
@ -106,7 +106,22 @@ class VPCSVM(BaseVM):
|
||||
"vm_id": self.id,
|
||||
"console": self._console,
|
||||
"project_id": self.project.id,
|
||||
"startup_script": self.startup_script}
|
||||
"startup_script": self.startup_script,
|
||||
"startup_script_path": self.relative_startup_script}
|
||||
|
||||
@property
|
||||
def relative_startup_script(self):
|
||||
"""
|
||||
Returns the startup config file relative to the project directory.
|
||||
|
||||
:returns: path to config file. None if the file doesn't exist
|
||||
"""
|
||||
|
||||
path = os.path.join(self.working_dir, 'startup.vpc')
|
||||
if os.path.exists(path):
|
||||
return 'startup.vpc'
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def vpcs_path(self):
|
||||
|
@ -165,7 +165,11 @@ VPCS_OBJECT_SCHEMA = {
|
||||
"description": "Content of the VPCS startup script",
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"startup_script_path": {
|
||||
"description": "Path of the VPCS startup script relative to project directory",
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
},
|
||||
"additionalProperties": False,
|
||||
"required": ["name", "vm_id", "console", "project_id"]
|
||||
"required": ["name", "vm_id", "console", "project_id", "startup_script_path"]
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ def test_vpcs_get(server, project, vm):
|
||||
assert response.route == "/projects/{project_id}/vpcs/vms/{vm_id}"
|
||||
assert response.json["name"] == "PC TEST 1"
|
||||
assert response.json["project_id"] == project.id
|
||||
assert response.json["startup_script_path"] == None
|
||||
|
||||
|
||||
def test_vpcs_create_startup_script(server, project):
|
||||
@ -51,6 +52,7 @@ def test_vpcs_create_startup_script(server, project):
|
||||
assert response.json["name"] == "PC TEST 1"
|
||||
assert response.json["project_id"] == project.id
|
||||
assert response.json["startup_script"] == "ip 192.168.1.2\necho TEST"
|
||||
assert response.json["startup_script_path"] == "startup.vpc"
|
||||
|
||||
|
||||
def test_vpcs_create_port(server, project, free_console_port):
|
||||
|
Loading…
Reference in New Issue
Block a user