Support controller reloading for templates, appliances and projects. Ref #1743

This commit is contained in:
grossmj committed 2020-04-30 15:30:50 +09:30
1 parent 7b61724213
commit 02c0fa26e1
8 files changed
+44 -12

No files matched your search

+9 -3
View File
@@ -80,7 +80,7 @@ class Controller:
if name == "gns3vm":
name = "Main server"
computes = await self._load_controller_settings()
computes = self._load_controller_settings()
try:
self._local_server = await self.add_compute(compute_id="local",
name=name,
@@ -118,7 +118,7 @@ class Controller:
async def stop(self):
log.info("Controller is Stopping")
log.info("Controller is stopping")
for project in self._projects.values():
await project.close()
for compute in self._computes.values():
@@ -132,6 +132,12 @@ class Controller:
self._computes = {}
self._projects = {}
async def reload(self):
log.info("Controller is reloading")
self._load_controller_settings()
await self.load_projects()
def check_can_write_config(self):
"""
Check if the controller configuration can be written on disk
@@ -182,7 +188,7 @@ class Controller:
except OSError as e:
log.error("Cannot write controller configuration file '{}': {}".format(self._config_file, e))
async def _load_controller_settings(self):
def _load_controller_settings(self):
"""
Reload the controller configuration from disk
"""
+10
View File
@@ -18,6 +18,9 @@
import copy
import uuid
import logging
log = logging.getLogger(__name__)
class Appliance:
@@ -33,6 +36,9 @@ class Appliance:
if "appliance_id" in self._data:
del self._data["appliance_id"]
if self.status != 'broken':
log.debug('Appliance "{name}" [{id}] loaded'.format(name=self.name, id=self._id))
@property
def id(self):
return self._id
@@ -45,6 +51,10 @@ class Appliance:
def symbol(self):
return self._data.get("symbol")
@property
def name(self):
return self._data.get("name")
@symbol.setter
def symbol(self, new_symbol):
self._data["symbol"] = new_symbol
+2
View File
@@ -129,6 +129,8 @@ class Project:
self._iou_id_lock = asyncio.Lock()
log.debug('Project "{name}" [{id}] loaded'.format(name=self.name, id=self._id))
def emit_notification(self, action, event):
"""
Emit a notification to all clients using this project.
+2
View File
@@ -147,6 +147,8 @@ class Template:
# special case for Dynamips to cover all platform types that contain specific settings
self.validate_and_apply_defaults(DYNAMIPS_PLATFORM_TO_SHEMA[self._settings["platform"]])
log.debug('Template "{name}" [{id}] loaded'.format(name=self.name, id=self._id))
@property
def id(self):
return self._id