Merge branch '2.2' into 3.0

# Conflicts:
#	gns3server/compute/iou/iou_vm.py
This commit is contained in:
grossmj 2024-12-16 18:08:51 +07:00
commit db067579db
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7

View File

@ -436,14 +436,16 @@ class IOUVM(BaseNode):
)
)
async def _check_iou_licence(self):
def _is_iou_licence_check_enabled(self):
"""
Checks for a valid IOU key in the iourc file (paranoid mode).
Returns if IOU licence check is enabled.
:return: boolean
"""
# license check is sent by the controller
if self.license_check is False:
return
return False
try:
# we allow license check to be disabled server wide
@ -453,7 +455,14 @@ class IOUVM(BaseNode):
if server_wide_license_check is False:
log.warning("License check is explicitly disabled on this server")
return
return False
return True
async def _check_iou_licence(self):
"""
Checks for a valid IOU key in the iourc file (paranoid mode).
"""
config = configparser.ConfigParser()
try:
@ -559,15 +568,16 @@ class IOUVM(BaseNode):
except OSError as e:
raise IOUError(f"Could not rename nvram files: {e}")
iourc_path = self.iourc_path
if not iourc_path:
raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license")
if not os.path.isfile(iourc_path):
raise IOUError(f"The iourc path '{iourc_path}' is not a regular file")
if self._is_iou_licence_check_enabled():
iourc_path = self.iourc_path
if not iourc_path:
raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license")
if not os.path.isfile(iourc_path):
raise IOUError(f"The iourc path '{iourc_path}' is not a regular file")
await self._check_iou_licence()
await self._check_iou_licence()
await self._start_ubridge()
self._create_netmap_config()
if self.use_default_iou_values:
# make sure we have the default nvram amount to correctly push the configs
@ -579,7 +589,7 @@ class IOUVM(BaseNode):
self._nvram_watcher = FileWatcher(self._nvram_file(), self._nvram_changed, delay=2)
# created a environment variable pointing to the iourc file.
# created an environment variable pointing to the iourc file.
env = os.environ.copy()
if "IOURC" not in os.environ and iourc_path:
env["IOURC"] = iourc_path