mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-04 12:04:12 +00:00
Store IOU licence in the secrets directory and disable the check by default
This commit is contained in:
parent
5e1b8814b6
commit
014d3f2ad9
@ -64,7 +64,7 @@ class Controller:
|
|||||||
self.gns3vm = GNS3VM(self)
|
self.gns3vm = GNS3VM(self)
|
||||||
self.symbols = Symbols()
|
self.symbols = Symbols()
|
||||||
self._appliance_manager = ApplianceManager()
|
self._appliance_manager = ApplianceManager()
|
||||||
self._iou_license_settings = {"iourc_content": "", "license_check": True}
|
self._iou_license_settings = {"iourc_content": "", "license_check": False}
|
||||||
self._vars_loaded = False
|
self._vars_loaded = False
|
||||||
self._vars_file = Config.instance().controller_vars
|
self._vars_file = Config.instance().controller_vars
|
||||||
log.info(f'Loading controller vars file "{self._vars_file}"')
|
log.info(f'Loading controller vars file "{self._vars_file}"')
|
||||||
@ -208,19 +208,15 @@ class Controller:
|
|||||||
if self._vars_loaded:
|
if self._vars_loaded:
|
||||||
controller_vars = {
|
controller_vars = {
|
||||||
"appliances_etag": self._appliance_manager.appliances_etag,
|
"appliances_etag": self._appliance_manager.appliances_etag,
|
||||||
|
"iou_license_check": self._iou_license_settings["license_check"],
|
||||||
"version": __version__
|
"version": __version__
|
||||||
}
|
}
|
||||||
|
|
||||||
if self._iou_license_settings["iourc_content"]:
|
if self._iou_license_settings["iourc_content"]:
|
||||||
|
|
||||||
iou_config = Config.instance().settings.IOU
|
|
||||||
server_config = Config.instance().settings.Server
|
server_config = Config.instance().settings.Server
|
||||||
|
|
||||||
if iou_config.iourc_path:
|
|
||||||
iourc_path = iou_config.iourc_path
|
|
||||||
else:
|
|
||||||
os.makedirs(server_config.secrets_dir, exist_ok=True)
|
os.makedirs(server_config.secrets_dir, exist_ok=True)
|
||||||
iourc_path = os.path.join(server_config.secrets_dir, "gns3_iourc_license")
|
iourc_path = os.path.join(server_config.secrets_dir, "iou_license")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(iourc_path, "w+") as f:
|
with open(iourc_path, "w+") as f:
|
||||||
@ -251,15 +247,11 @@ class Controller:
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# load the IOU license settings
|
# load the IOU license settings
|
||||||
iou_config = Config.instance().settings.IOU
|
|
||||||
server_config = Config.instance().settings.Server
|
server_config = Config.instance().settings.Server
|
||||||
|
|
||||||
if iou_config.iourc_path:
|
|
||||||
iourc_path = iou_config.iourc_path
|
|
||||||
else:
|
|
||||||
if not server_config.secrets_dir:
|
if not server_config.secrets_dir:
|
||||||
server_config.secrets_dir = os.path.dirname(Config.instance().server_config)
|
server_config.secrets_dir = os.path.dirname(Config.instance().server_config)
|
||||||
iourc_path = os.path.join(server_config.secrets_dir, "gns3_iourc_license")
|
iourc_path = os.path.join(server_config.secrets_dir, "iou_license")
|
||||||
|
|
||||||
if os.path.exists(iourc_path):
|
if os.path.exists(iourc_path):
|
||||||
try:
|
try:
|
||||||
@ -268,7 +260,10 @@ class Controller:
|
|||||||
log.info(f"iourc file '{iourc_path}' loaded")
|
log.info(f"iourc file '{iourc_path}' loaded")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.error(f"Cannot read IOU license file '{iourc_path}': {e}")
|
log.error(f"Cannot read IOU license file '{iourc_path}': {e}")
|
||||||
self._iou_license_settings["license_check"] = iou_config.license_check
|
|
||||||
|
# IOU license check is disabled by default
|
||||||
|
self._iou_license_settings["license_check"] = controller_vars.get("iou_license_check", False)
|
||||||
|
log.info("IOU license check is {} on the controller".format("enabled" if self._iou_license_settings["license_check"] else "disabled"))
|
||||||
|
|
||||||
# install the built-in appliances if needed
|
# install the built-in appliances if needed
|
||||||
if Config.instance().settings.Server.install_builtin_appliances:
|
if Config.instance().settings.Server.install_builtin_appliances:
|
||||||
|
@ -572,16 +572,12 @@ class Node:
|
|||||||
Start a node
|
Start a node
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# For IOU we need to send the licence everytime
|
# For IOU we need to send the licence everytime (if enabled)
|
||||||
if self.node_type == "iou":
|
if self.node_type == "iou":
|
||||||
license_check = self._project.controller.iou_license.get("license_check", True)
|
license_check = self._project.controller.iou_license.get("license_check")
|
||||||
iourc_content = self._project.controller.iou_license.get("iourc_content", None)
|
iourc_content = self._project.controller.iou_license.get("iourc_content")
|
||||||
# if license_check and not iourc_content:
|
if license_check:
|
||||||
# raise aiohttp.web.HTTPConflict(text="IOU licence is not configured")
|
data = {"license_check": license_check, "iourc_content": iourc_content}
|
||||||
await self.post(
|
|
||||||
"/start", timeout=240, data={"license_check": license_check, "iourc_content": iourc_content}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
await self.post("/start", data=data, timeout=240)
|
await self.post("/start", data=data, timeout=240)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
raise ControllerTimeoutError(f"Timeout when starting {self._name}")
|
raise ControllerTimeoutError(f"Timeout when starting {self._name}")
|
||||||
|
Loading…
Reference in New Issue
Block a user