mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 22:41:12 +02:00
Use "template" to name what we use to create new nodes.
This commit is contained in:
1 parent
21c0a35f77
commit
d7c2e16c21
262 files changed
+16588
-16863
No files matched your search
@@ -466,7 +466,7 @@ def test_load_base_files(controller, config, tmpdir):
|
||||
assert f.read() == 'test'
|
||||
|
||||
|
||||
def test_appliance_templates(controller, async_run, tmpdir):
|
||||
def test_appliances(controller, async_run, tmpdir):
|
||||
my_appliance = {
|
||||
"name": "My Appliance",
|
||||
"status": "stable"
|
||||
@@ -481,14 +481,14 @@ def test_appliance_templates(controller, async_run, tmpdir):
|
||||
json.dump(my_appliance, f)
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"appliances_path": str(tmpdir)}):
|
||||
controller.load_appliance_templates()
|
||||
assert len(controller.appliance_templates) > 0
|
||||
for appliance in controller.appliance_templates.values():
|
||||
controller.load_appliances()
|
||||
assert len(controller.appliances) > 0
|
||||
for appliance in controller.appliances.values():
|
||||
assert appliance.__json__()["status"] != "broken"
|
||||
assert "Alpine Linux" in [c.__json__()["name"] for c in controller.appliance_templates.values()]
|
||||
assert "My Appliance" in [c.__json__()["name"] for c in controller.appliance_templates.values()]
|
||||
assert "Alpine Linux" in [c.__json__()["name"] for c in controller.appliances.values()]
|
||||
assert "My Appliance" in [c.__json__()["name"] for c in controller.appliances.values()]
|
||||
|
||||
for c in controller.appliance_templates.values():
|
||||
for c in controller.appliances.values():
|
||||
j = c.__json__()
|
||||
if j["name"] == "Alpine Linux":
|
||||
assert j["builtin"]
|
||||
@@ -496,29 +496,29 @@ def test_appliance_templates(controller, async_run, tmpdir):
|
||||
assert not j["builtin"]
|
||||
|
||||
|
||||
def test_load_appliances(controller):
|
||||
def test_load_templates(controller):
|
||||
controller._settings = {}
|
||||
controller.load_appliances()
|
||||
controller.load_templates()
|
||||
|
||||
assert "Cloud" in [appliance.name for appliance in controller.appliances.values()]
|
||||
assert "VPCS" in [appliance.name for appliance in controller.appliances.values()]
|
||||
assert "Cloud" in [template.name for template in controller.templates.values()]
|
||||
assert "VPCS" in [template.name for template in controller.templates.values()]
|
||||
|
||||
for appliance in controller.appliances.values():
|
||||
if appliance.name == "VPCS":
|
||||
assert appliance._settings["properties"] == {"base_script_file": "vpcs_base_config.txt"}
|
||||
for template in controller.templates.values():
|
||||
if template.name == "VPCS":
|
||||
assert template._settings["properties"] == {"base_script_file": "vpcs_base_config.txt"}
|
||||
|
||||
# UUID should not change when you run again the function
|
||||
for appliance in controller.appliances.values():
|
||||
if appliance.name == "Test":
|
||||
qemu_uuid = appliance.id
|
||||
elif appliance.name == "Cloud":
|
||||
cloud_uuid = appliance.id
|
||||
controller.load_appliances()
|
||||
for appliance in controller.appliances.values():
|
||||
if appliance.name == "Test":
|
||||
assert qemu_uuid == appliance.id
|
||||
elif appliance.name == "Cloud":
|
||||
assert cloud_uuid == appliance.id
|
||||
for template in controller.templates.values():
|
||||
if template.name == "Test":
|
||||
qemu_uuid = template.id
|
||||
elif template.name == "Cloud":
|
||||
cloud_uuid = template.id
|
||||
controller.load_templates()
|
||||
for template in controller.templates.values():
|
||||
if template.name == "Test":
|
||||
assert qemu_uuid == template.id
|
||||
elif template.name == "Cloud":
|
||||
assert cloud_uuid == template.id
|
||||
|
||||
|
||||
def test_autoidlepc(controller, async_run):
|
||||
|
||||
@@ -122,7 +122,7 @@ def test_json(node, compute):
|
||||
"compute_id": str(compute.id),
|
||||
"project_id": node.project.id,
|
||||
"node_id": node.id,
|
||||
"appliance_id": None,
|
||||
"template_id": None,
|
||||
"node_type": node.node_type,
|
||||
"name": "demo",
|
||||
"console": node.console,
|
||||
@@ -158,7 +158,7 @@ def test_json(node, compute):
|
||||
assert node.__json__(topology_dump=True) == {
|
||||
"compute_id": str(compute.id),
|
||||
"node_id": node.id,
|
||||
"appliance_id": None,
|
||||
"template_id": None,
|
||||
"node_type": node.node_type,
|
||||
"name": "demo",
|
||||
"console": node.console,
|
||||
|
||||
@@ -28,7 +28,7 @@ from unittest.mock import patch
|
||||
from uuid import uuid4
|
||||
|
||||
from gns3server.controller.project import Project
|
||||
from gns3server.controller.appliance import Appliance
|
||||
from gns3server.controller.template import Template
|
||||
from gns3server.controller.ports.ethernet_port import EthernetPort
|
||||
from gns3server.config import Config
|
||||
|
||||
@@ -205,7 +205,7 @@ def test_add_node_non_local(async_run, controller):
|
||||
controller.notification.project_emit.assert_any_call("node.created", node.__json__())
|
||||
|
||||
|
||||
def test_add_node_from_appliance(async_run, controller):
|
||||
def test_add_node_from_template(async_run, controller):
|
||||
"""
|
||||
For a local server we send the project path
|
||||
"""
|
||||
@@ -213,20 +213,20 @@ def test_add_node_from_appliance(async_run, controller):
|
||||
compute.id = "local"
|
||||
project = Project(controller=controller, name="Test")
|
||||
controller._notification = MagicMock()
|
||||
appliance = Appliance(str(uuid.uuid4()), {
|
||||
template = Template(str(uuid.uuid4()), {
|
||||
"compute_id": "local",
|
||||
"name": "Test",
|
||||
"appliance_type": "vpcs",
|
||||
"template_type": "vpcs",
|
||||
"builtin": False,
|
||||
})
|
||||
controller._appliances[appliance.id] = appliance
|
||||
controller._templates[template.id] = template
|
||||
controller._computes["local"] = compute
|
||||
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
node = async_run(project.add_node_from_appliance(appliance.id, x=23, y=12))
|
||||
node = async_run(project.add_node_from_template(template.id, x=23, y=12))
|
||||
compute.post.assert_any_call('/projects', data={
|
||||
"name": project._name,
|
||||
"project_id": project._id,
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
import pytest
|
||||
import jsonschema
|
||||
|
||||
from gns3server.controller.appliance import Appliance
|
||||
from gns3server.controller.template import Template
|
||||
|
||||
|
||||
def test_appliance_json():
|
||||
a = Appliance(None, {
|
||||
def test_template_json():
|
||||
a = Template(None, {
|
||||
"node_type": "qemu",
|
||||
"name": "Test",
|
||||
"default_name_format": "{name}-{0}",
|
||||
@@ -32,14 +32,14 @@ def test_appliance_json():
|
||||
"platform": "i386"
|
||||
})
|
||||
settings = a.__json__()
|
||||
assert settings["appliance_id"] == a.id
|
||||
assert settings["appliance_type"] == "qemu"
|
||||
assert settings["template_id"] == a.id
|
||||
assert settings["template_type"] == "qemu"
|
||||
assert settings["builtin"] == False
|
||||
|
||||
|
||||
def test_appliance_json_with_not_known_category():
|
||||
def test_template_json_with_not_known_category():
|
||||
with pytest.raises(jsonschema.ValidationError):
|
||||
a = Appliance(None, {
|
||||
a = Template(None, {
|
||||
"node_type": "qemu",
|
||||
"name": "Test",
|
||||
"default_name_format": "{name}-{0}",
|
||||
@@ -50,8 +50,8 @@ def test_appliance_json_with_not_known_category():
|
||||
})
|
||||
|
||||
|
||||
def test_appliance_json_with_platform():
|
||||
a = Appliance(None, {
|
||||
def test_template_json_with_platform():
|
||||
a = Template(None, {
|
||||
"node_type": "dynamips",
|
||||
"name": "Test",
|
||||
"default_name_format": "{name}-{0}",
|
||||
@@ -62,18 +62,18 @@ def test_appliance_json_with_platform():
|
||||
"platform": "c3725"
|
||||
})
|
||||
settings = a.__json__()
|
||||
assert settings["appliance_id"] == a.id
|
||||
assert settings["appliance_type"] == "dynamips"
|
||||
assert settings["template_id"] == a.id
|
||||
assert settings["template_type"] == "dynamips"
|
||||
assert settings["builtin"] == False
|
||||
assert settings["platform"] == "c3725"
|
||||
|
||||
|
||||
def test_appliance_fix_linked_base():
|
||||
def test_template_fix_linked_base():
|
||||
"""
|
||||
Version of the gui before 2.1 use linked_base and the server
|
||||
linked_clone
|
||||
"""
|
||||
a = Appliance(None, {
|
||||
a = Template(None, {
|
||||
"node_type": "qemu",
|
||||
"name": "Test",
|
||||
"default_name_format": "{name}-{0}",
|
||||
Reference in new issue
Block a user