Fix: do not use the iourc file if IOU licence check is not enabled

This commit is contained in:
grossmj 2024-12-16 18:07:02 +07:00
parent 6c521b5f7a
commit 6314dd3c35
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7

View File

@ -390,14 +390,16 @@ class IOUVM(BaseNode):
raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path, raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path,
", ".join(missing_libs))) ", ".join(missing_libs)))
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 # license check is sent by the controller
if self.license_check is False: if self.license_check is False:
return return False
try: try:
# we allow license check to be disabled server wide # we allow license check to be disabled server wide
@ -407,7 +409,14 @@ class IOUVM(BaseNode):
if server_wide_license_check is False: if server_wide_license_check is False:
log.warning("License check is explicitly disabled on this server") 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() config = configparser.ConfigParser()
try: try:
@ -511,15 +520,15 @@ class IOUVM(BaseNode):
except OSError as e: except OSError as e:
raise IOUError("Could not rename nvram files: {}".format(e)) raise IOUError("Could not rename nvram files: {}".format(e))
if self._is_iou_licence_check_enabled():
iourc_path = self.iourc_path iourc_path = self.iourc_path
if not iourc_path: if not iourc_path:
raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license") raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license")
if not os.path.isfile(iourc_path): if not os.path.isfile(iourc_path):
raise IOUError("The iourc path '{}' is not a regular file".format(iourc_path)) raise IOUError("The iourc path '{}' is not a regular file".format(iourc_path))
await self._check_iou_licence() await self._check_iou_licence()
await self._start_ubridge()
await self._start_ubridge()
self._create_netmap_config() self._create_netmap_config()
if self.use_default_iou_values: if self.use_default_iou_values:
# make sure we have the default nvram amount to correctly push the configs # make sure we have the default nvram amount to correctly push the configs
@ -531,7 +540,7 @@ class IOUVM(BaseNode):
self._nvram_watcher = FileWatcher(self._nvram_file(), self._nvram_changed, delay=2) 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() env = os.environ.copy()
if "IOURC" not in os.environ and iourc_path: if "IOURC" not in os.environ and iourc_path:
env["IOURC"] = iourc_path env["IOURC"] = iourc_path