Fix issue with controller config saved before checking current version with previous one

pull/2272/head
grossmj 9 months ago
parent a69feb3682
commit 709aa46074

@ -191,29 +191,28 @@ class Controller:
Save the controller configuration on disk Save the controller configuration on disk
""" """
if self._config_loaded is False: controller_settings = dict()
return if self._config_loaded:
controller_settings = {"computes": [],
controller_settings = {"computes": [], "templates": [],
"templates": [], "gns3vm": self.gns3vm.__json__(),
"gns3vm": self.gns3vm.__json__(), "iou_license": self._iou_license_settings,
"iou_license": self._iou_license_settings, "appliances_etag": self._appliance_manager.appliances_etag,
"appliances_etag": self._appliance_manager.appliances_etag, "version": __version__}
"version": __version__}
for template in self._template_manager.templates.values():
for template in self._template_manager.templates.values(): if not template.builtin:
if not template.builtin: controller_settings["templates"].append(template.__json__())
controller_settings["templates"].append(template.__json__())
for compute in self._computes.values(): for compute in self._computes.values():
if compute.id != "local" and compute.id != "vm": if compute.id != "local" and compute.id != "vm":
controller_settings["computes"].append({"host": compute.host, controller_settings["computes"].append({"host": compute.host,
"name": compute.name, "name": compute.name,
"port": compute.port, "port": compute.port,
"protocol": compute.protocol, "protocol": compute.protocol,
"user": compute.user, "user": compute.user,
"password": compute.password, "password": compute.password,
"compute_id": compute.id}) "compute_id": compute.id})
try: try:
os.makedirs(os.path.dirname(self._config_file), exist_ok=True) os.makedirs(os.path.dirname(self._config_file), exist_ok=True)
@ -229,8 +228,7 @@ class Controller:
try: try:
if not os.path.exists(self._config_file): if not os.path.exists(self._config_file):
self._config_loaded = True self.save() # this will create the config file
self.save()
with open(self._config_file) as f: with open(self._config_file) as f:
controller_settings = json.load(f) controller_settings = json.load(f)
except (OSError, ValueError) as e: except (OSError, ValueError) as e:

Loading…
Cancel
Save