From 02f30c9a9038277f8b7a2f87c6817e769c3a0146 Mon Sep 17 00:00:00 2001 From: jkriwet Date: Tue, 11 Jul 2023 09:59:46 +0200 Subject: [PATCH 1/4] Added version checker for correct cb version #190 --- filip/clients/ngsi_v2/cb.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/filip/clients/ngsi_v2/cb.py b/filip/clients/ngsi_v2/cb.py index 3d7fe1bf..44b09890 100644 --- a/filip/clients/ngsi_v2/cb.py +++ b/filip/clients/ngsi_v2/cb.py @@ -12,6 +12,7 @@ PositiveFloat, \ AnyHttpUrl from typing import Any, Dict, List , Optional, TYPE_CHECKING, Union +from packaging import version import re import requests from urllib.parse import urljoin @@ -74,6 +75,8 @@ def __init__(self, fiware_header=fiware_header, **kwargs) + self._check_correct_cb_version() + def __pagination(self, *, method: PaginationMethod = PaginationMethod.GET, @@ -157,6 +160,22 @@ def get_version(self) -> Dict: self.logger.error(err) raise + def _check_correct_cb_version(self) -> None: + """ + Checks whether Orion version is >= 3.6.0, since breaking change was introduced there which introduced new + option, which is implemented in FiLiP, but won't work with lower orion versions. + """ + orion_version = self.get_version()['orion']['version'] + if version.parse(orion_version) < version.parse('3.6.0'): + warnings.warn( + f"You are using orion version {orion_version}. There was a breaking change in Orion Version 3.6.0," + f"which changed the default metadata update semantics and introduced the 'overrideMetadata' option. " + f"See https://github.com/telefonicaid/fiware-orion/releases/tag/3.6.0 for further details. " + f"In your used version {orion_version}, this option is not supported. This will only be a problem, if" + f" you try to set the 'overrideMetadata' option in FiLiP (implemented since v0.2.3)." + ) + + def get_resources(self) -> Dict: """ Gets reo From 15eba574f737e2549aaa0ed4d742dc4deeb04a17 Mon Sep 17 00:00:00 2001 From: JunsongDu Date: Wed, 19 Jul 2023 16:09:54 +0200 Subject: [PATCH 2/4] chore: add change log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a8c0be2..1c6bd2ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -#### v0.2.5 +#### v0.2.6 - fixed inconsistency of `entity_type` as required argument ([#188](https://github.com/RWTH-EBC/FiLiP/issues/188)) +- add warning if ``Orion`` version is not supported ([#200](https://github.com/RWTH-EBC/FiLiP/issues/200)) #### v0.2.5 - fixed service group edition not working ([#170](https://github.com/RWTH-EBC/FiLiP/issues/170)) From 94206774b73ae4307d3f46e882f23cc7ff020d5f Mon Sep 17 00:00:00 2001 From: jkriwet Date: Wed, 19 Jul 2023 16:43:44 +0200 Subject: [PATCH 3/4] changed version checker, so that minimum orion version is part of default settings #190 --- filip/clients/ngsi_v2/cb.py | 10 ++++------ filip/config.py | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/filip/clients/ngsi_v2/cb.py b/filip/clients/ngsi_v2/cb.py index 44b09890..1c642a69 100644 --- a/filip/clients/ngsi_v2/cb.py +++ b/filip/clients/ngsi_v2/cb.py @@ -166,13 +166,11 @@ def _check_correct_cb_version(self) -> None: option, which is implemented in FiLiP, but won't work with lower orion versions. """ orion_version = self.get_version()['orion']['version'] - if version.parse(orion_version) < version.parse('3.6.0'): + if version.parse(orion_version) < version.parse(settings.minimum_orion_version): warnings.warn( - f"You are using orion version {orion_version}. There was a breaking change in Orion Version 3.6.0," - f"which changed the default metadata update semantics and introduced the 'overrideMetadata' option. " - f"See https://github.com/telefonicaid/fiware-orion/releases/tag/3.6.0 for further details. " - f"In your used version {orion_version}, this option is not supported. This will only be a problem, if" - f" you try to set the 'overrideMetadata' option in FiLiP (implemented since v0.2.3)." + f"You are using orion version {orion_version}. There was a breaking change in Orion Version " + f"{settings.minimum_orion_version}, therefore functionality is not assured when using " + f"version {orion_version}." ) diff --git a/filip/config.py b/filip/config.py index db072518..8a129b92 100644 --- a/filip/config.py +++ b/filip/config.py @@ -21,6 +21,7 @@ class Settings(BaseSettings): QL_URL: AnyHttpUrl = Field(default="http://127.0.0.1:8668", env=['QUANTUMLEAP_URL', 'QL_URL']) + minimum_orion_version: str = '3.6.0' class Config: env_file = '.env.filip' env_file_encoding = 'utf-8' From 13ea081207e6fffc8ce6c79efcca3935fa36b75c Mon Sep 17 00:00:00 2001 From: jkriwet Date: Wed, 19 Jul 2023 17:05:04 +0200 Subject: [PATCH 4/4] changed version checker, so that minimum orion version is part of default settings #190 --- filip/clients/ngsi_v2/cb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filip/clients/ngsi_v2/cb.py b/filip/clients/ngsi_v2/cb.py index 1c642a69..c8a98ac8 100644 --- a/filip/clients/ngsi_v2/cb.py +++ b/filip/clients/ngsi_v2/cb.py @@ -162,8 +162,8 @@ def get_version(self) -> Dict: def _check_correct_cb_version(self) -> None: """ - Checks whether Orion version is >= 3.6.0, since breaking change was introduced there which introduced new - option, which is implemented in FiLiP, but won't work with lower orion versions. + Checks whether the used Orion version is greater or equal than the minimum required orion version of + the current filip version """ orion_version = self.get_version()['orion']['version'] if version.parse(orion_version) < version.parse(settings.minimum_orion_version):