mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
If the compute node is remote do not send project path
This commit is contained in:
parent
d97325b113
commit
a9b95eb242
@ -119,7 +119,21 @@ class Project:
|
||||
if node_id not in self._nodes:
|
||||
node = Node(self, compute, node_id=node_id, **kwargs)
|
||||
if compute not in self._project_created_on_compute:
|
||||
yield from compute.post("/projects", self)
|
||||
# For a local server we send the project path
|
||||
if compute.id == "local":
|
||||
yield from compute.post("/projects", {
|
||||
"name": self._name,
|
||||
"project_id": self._id,
|
||||
"temporary": self._temporary,
|
||||
"path": self._path
|
||||
})
|
||||
else:
|
||||
yield from compute.post("/projects", {
|
||||
"name": self._name,
|
||||
"project_id": self._id,
|
||||
"temporary": self._temporary
|
||||
})
|
||||
|
||||
self._project_created_on_compute.add(compute)
|
||||
yield from node.create()
|
||||
self._nodes[node.id] = node
|
||||
|
@ -68,6 +68,7 @@ def test_captures_directory(tmpdir):
|
||||
assert p.captures_directory == str(tmpdir / "project-files" / "captures")
|
||||
assert os.path.exists(p.captures_directory)
|
||||
|
||||
|
||||
def test_add_compute(async_run):
|
||||
compute = MagicMock()
|
||||
project = Project()
|
||||
@ -75,8 +76,12 @@ def test_add_compute(async_run):
|
||||
assert compute in project._computes
|
||||
|
||||
|
||||
def test_add_node(async_run):
|
||||
def test_add_node_local(async_run):
|
||||
"""
|
||||
For a local server we send the project path
|
||||
"""
|
||||
compute = MagicMock()
|
||||
compute.id = "local"
|
||||
project = Project()
|
||||
|
||||
response = MagicMock()
|
||||
@ -85,9 +90,40 @@ def test_add_node(async_run):
|
||||
|
||||
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
|
||||
compute.post.assert_any_call('/projects', {
|
||||
"name": project._name,
|
||||
"project_id": project._id,
|
||||
"temporary": project._temporary,
|
||||
"path": project._path
|
||||
})
|
||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': node.id,
|
||||
'startup_config': 'test.cfg',
|
||||
'name': 'test'})
|
||||
assert compute in project._project_created_on_compute
|
||||
|
||||
|
||||
def test_add_node_non_local(async_run):
|
||||
"""
|
||||
For a non local server we do not send the project path
|
||||
"""
|
||||
compute = MagicMock()
|
||||
compute.id = "remote"
|
||||
project = Project()
|
||||
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
|
||||
compute.post.assert_any_call('/projects', {
|
||||
"name": project._name,
|
||||
"project_id": project._id,
|
||||
"temporary": project._temporary
|
||||
})
|
||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': node.id,
|
||||
'console_type': 'telnet',
|
||||
'startup_config': 'test.cfg',
|
||||
'name': 'test'})
|
||||
assert compute in project._project_created_on_compute
|
||||
|
Loading…
Reference in New Issue
Block a user