mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-30 01:28:56 +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.symbols = Symbols()
|
||||
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_file = Config.instance().controller_vars
|
||||
log.info(f'Loading controller vars file "{self._vars_file}"')
|
||||
@ -208,19 +208,15 @@ class Controller:
|
||||
if self._vars_loaded:
|
||||
controller_vars = {
|
||||
"appliances_etag": self._appliance_manager.appliances_etag,
|
||||
"iou_license_check": self._iou_license_settings["license_check"],
|
||||
"version": __version__
|
||||
}
|
||||
|
||||
if self._iou_license_settings["iourc_content"]:
|
||||
|
||||
iou_config = Config.instance().settings.IOU
|
||||
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)
|
||||
iourc_path = os.path.join(server_config.secrets_dir, "gns3_iourc_license")
|
||||
os.makedirs(server_config.secrets_dir, exist_ok=True)
|
||||
iourc_path = os.path.join(server_config.secrets_dir, "iou_license")
|
||||
|
||||
try:
|
||||
with open(iourc_path, "w+") as f:
|
||||
@ -251,15 +247,11 @@ class Controller:
|
||||
return []
|
||||
|
||||
# load the IOU license settings
|
||||
iou_config = Config.instance().settings.IOU
|
||||
server_config = Config.instance().settings.Server
|
||||
|
||||
if iou_config.iourc_path:
|
||||
iourc_path = iou_config.iourc_path
|
||||
else:
|
||||
if not server_config.secrets_dir:
|
||||
server_config.secrets_dir = os.path.dirname(Config.instance().server_config)
|
||||
iourc_path = os.path.join(server_config.secrets_dir, "gns3_iourc_license")
|
||||
if not server_config.secrets_dir:
|
||||
server_config.secrets_dir = os.path.dirname(Config.instance().server_config)
|
||||
iourc_path = os.path.join(server_config.secrets_dir, "iou_license")
|
||||
|
||||
if os.path.exists(iourc_path):
|
||||
try:
|
||||
@ -268,7 +260,10 @@ class Controller:
|
||||
log.info(f"iourc file '{iourc_path}' loaded")
|
||||
except OSError as 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
|
||||
if Config.instance().settings.Server.install_builtin_appliances:
|
||||
|
@ -572,17 +572,13 @@ class Node:
|
||||
Start a node
|
||||
"""
|
||||
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":
|
||||
license_check = self._project.controller.iou_license.get("license_check", True)
|
||||
iourc_content = self._project.controller.iou_license.get("iourc_content", None)
|
||||
# if license_check and not iourc_content:
|
||||
# raise aiohttp.web.HTTPConflict(text="IOU licence is not configured")
|
||||
await self.post(
|
||||
"/start", timeout=240, data={"license_check": license_check, "iourc_content": iourc_content}
|
||||
)
|
||||
else:
|
||||
await self.post("/start", data=data, timeout=240)
|
||||
license_check = self._project.controller.iou_license.get("license_check")
|
||||
iourc_content = self._project.controller.iou_license.get("iourc_content")
|
||||
if license_check:
|
||||
data = {"license_check": license_check, "iourc_content": iourc_content}
|
||||
await self.post("/start", data=data, timeout=240)
|
||||
except asyncio.TimeoutError:
|
||||
raise ControllerTimeoutError(f"Timeout when starting {self._name}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user