diff --git a/gns3server/controller/appliance.py b/gns3server/controller/appliance.py index 9cfb00f0..356ae10e 100644 --- a/gns3server/controller/appliance.py +++ b/gns3server/controller/appliance.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import copy import uuid @@ -54,7 +55,7 @@ class Appliance: @property def data(self): - return self._data + return copy.deepcopy(self._data) @property def name(self): diff --git a/gns3server/controller/appliance_template.py b/gns3server/controller/appliance_template.py index 8b9a3909..de7e98c6 100644 --- a/gns3server/controller/appliance_template.py +++ b/gns3server/controller/appliance_template.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import copy import uuid @@ -43,4 +44,4 @@ class ApplianceTemplate: """ Appliance data (a hash) """ - return self._data + return copy.deepcopy(self._data) diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 16c05a13..4c869acc 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -325,11 +325,12 @@ class Project: Create a node from an appliance """ try: - template = copy.copy(self.controller.appliances[appliance_id].data) + template = self.controller.appliances[appliance_id].data except KeyError: msg = "Appliance {} doesn't exist".format(appliance_id) log.error(msg) raise aiohttp.web.HTTPNotFound(text=msg) + print(template) template["x"] = x template["y"] = y node_type = template.pop("node_type") diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 0c9a929f..96dcb314 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -193,7 +193,10 @@ def test_add_node_from_appliance(async_run, controller): "server": "local", "name": "Test", "default_name_format": "{name}-{0}", - "node_type": "vpcs" + "node_type": "vpcs", + "properties": { + "a": 1 + } }) controller._computes["local"] = compute @@ -211,11 +214,22 @@ def test_add_node_from_appliance(async_run, controller): }) compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), data={'node_id': node.id, - 'name': 'Test-1'}, + 'name': 'Test-1', + 'a': 1, + }, timeout=120) assert compute in project._project_created_on_compute controller.notification.emit.assert_any_call("node.created", node.__json__()) + # Make sure we can call twice the node creation + node = async_run(project.add_node_from_appliance("fakeid", x=13, y=12)) + compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), + data={'node_id': node.id, + 'name': 'Test-2', + 'a': 1 + }, + timeout=120) + def test_create_iou_on_multiple_node(async_run, controller): """