GNS3 / gns3-gui

GNS3 Graphical Network Simulator
http://www.gns3.com
GNU General Public License v3.0
2.16k stars 435 forks source link

1.5: Can't save topology containing docker VM #1038

Closed ghost closed 8 years ago

ghost commented 8 years ago

GNS3 version 1.5.0dev1 on Linux (64-bit) with Python 3.4.2 Qt 5.3.2.

When I try to save a newly created topology containing just a docker VM and a dynamips router, I get the following exception:

2016-02-15 11:48:26 INFO topology.py:489 Starting to save the topology (version 1.5.0dev1)
2016-02-15 11:48:26 INFO topology.py:509 Saving node: R1
2016-02-15 11:48:26 INFO topology.py:509 Saving node: alpine-1
****** Exception detected, traceback information saved in /home/behlers/.config/GNS3/exceptions.log ******

PLEASE REPORT ON https://www.gns3.com

Traceback (most recent call last):
  File "/opt/GNS3/lib/python3.4/site-packages/gns3_gui-1.5.0dev1-py3.4.egg/gns3/main_window.py", line 463, in _saveProjectActionSlot
    return self.saveProject(self._project.topologyFile())
  File "/opt/GNS3/lib/python3.4/site-packages/gns3_gui-1.5.0dev1-py3.4.egg/gns3/main_window.py", line 1294, in saveProject
    topo = topology.dump(random_id=random_id)
  File "/opt/GNS3/lib/python3.4/site-packages/gns3_gui-1.5.0dev1-py3.4.egg/gns3/topology.py", line 510, in dump
    topology_nodes.append(node.dump())
  File "/opt/GNS3/lib/python3.4/site-packages/gns3_gui-1.5.0dev1-py3.4.egg/gns3/modules/docker/docker_vm.py", line 210, in dump
    container["properties"][name] = value
NameError: name 'container' is not defined
ghost commented 8 years ago

Commit https://github.com/GNS3/gns3-gui/commit/b6fa4f3242dcfc05f855d5701979f8237dacb982 seems to be the reason. This fixes it for me. Just made some basic tests.

diff --git a/gns3/modules/docker/docker_vm.py b/gns3/modules/docker/docker_vm.py
index abfe642..03be0f9 100644
--- a/gns3/modules/docker/docker_vm.py
+++ b/gns3/modules/docker/docker_vm.py
@@ -207,14 +207,14 @@ class DockerVM(VM):
         # add the properties
         for name, value in self._settings.items():
             if value is not None and value != "":
-                container["properties"][name] = value
+                docker["properties"][name] = value

         # add the ports
         if self._ports:
-            ports = container["ports"] = []
+            ports = docker["ports"] = []
             for port in self._ports:
                 ports.append(port.dump())
-        return container
+        return docker

     def info(self):
         """Returns information about this Docker container.
julien-duponchelle commented 8 years ago

Thanks it's fixed