Project global variables

This commit is contained in:
ziajka committed 2018-05-04 14:34:44 +02:00
1 parent 80958e8a6d
commit e267f8a8b8
9 files changed
+167 -8

No files matched your search

+4
View File
@@ -325,6 +325,10 @@ class DockerVM(BaseNode):
# Give the information to the container the list of volume path mounted
params["Env"].append("GNS3_VOLUMES={}".format(":".join(self._volumes)))
if self.project.variables:
for var in self.project.variables:
params["Env"].append("{}={}".format(var["name"], var.get('value', '')))
if self._environment:
for e in self._environment.strip().split("\n"):
e = e.strip()
+12 -2
View File
@@ -46,7 +46,7 @@ class Project:
:param path: path of the project. (None use the standard directory)
"""
def __init__(self, name=None, project_id=None, path=None):
def __init__(self, name=None, project_id=None, path=None, variables=None):
self._name = name
if project_id:
@@ -61,6 +61,7 @@ class Project:
self._nodes = set()
self._used_tcp_ports = set()
self._used_udp_ports = set()
self._variables = variables
if path is None:
location = get_default_project_directory()
@@ -83,7 +84,8 @@ class Project:
return {
"name": self._name,
"project_id": self._id
"project_id": self._id,
"variables": self._variables
}
def _config(self):
@@ -131,6 +133,14 @@ class Project:
return self._nodes
@property
def variables(self):
return self._variables
@variables.setter
def variables(self, variables):
self._variables = variables
def record_tcp_port(self, port):
"""
Associate a reserved TCP port number with this project.