mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-24 15:58:08 +00:00
Fix issue with controller config saved before checking current version with previous one
This commit is contained in:
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": [],
|
||||||
|
"templates": [],
|
||||||
|
"gns3vm": self.gns3vm.__json__(),
|
||||||
|
"iou_license": self._iou_license_settings,
|
||||||
|
"appliances_etag": self._appliance_manager.appliances_etag,
|
||||||
|
"version": __version__}
|
||||||
|
|
||||||
controller_settings = {"computes": [],
|
for template in self._template_manager.templates.values():
|
||||||
"templates": [],
|
if not template.builtin:
|
||||||
"gns3vm": self.gns3vm.__json__(),
|
controller_settings["templates"].append(template.__json__())
|
||||||
"iou_license": self._iou_license_settings,
|
|
||||||
"appliances_etag": self._appliance_manager.appliances_etag,
|
|
||||||
"version": __version__}
|
|
||||||
|
|
||||||
for template in self._template_manager.templates.values():
|
for compute in self._computes.values():
|
||||||
if not template.builtin:
|
if compute.id != "local" and compute.id != "vm":
|
||||||
controller_settings["templates"].append(template.__json__())
|
controller_settings["computes"].append({"host": compute.host,
|
||||||
|
"name": compute.name,
|
||||||
for compute in self._computes.values():
|
"port": compute.port,
|
||||||
if compute.id != "local" and compute.id != "vm":
|
"protocol": compute.protocol,
|
||||||
controller_settings["computes"].append({"host": compute.host,
|
"user": compute.user,
|
||||||
"name": compute.name,
|
"password": compute.password,
|
||||||
"port": compute.port,
|
"compute_id": compute.id})
|
||||||
"protocol": compute.protocol,
|
|
||||||
"user": compute.user,
|
|
||||||
"password": compute.password,
|
|
||||||
"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…
Reference in New Issue
Block a user