From 5478dd84ac1982c969a812f164e6e907701508f0 Mon Sep 17 00:00:00 2001 From: aticig Date: Mon, 8 Aug 2022 15:43:49 +0300 Subject: [PATCH] Adding VIM refresh period to RO charm config Refresh period is allowed >=60 or -1. Setting it -1 will disable the updating VM status. Change-Id: I18a8cd8fd39da16d2d0221dac15324a08da76c2a Signed-off-by: aticig --- installers/charm/osm-ro/config.yaml | 12 +++++++++++- installers/charm/osm-ro/src/charm.py | 8 ++++++++ installers/charm/osm-ro/tox.ini | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/installers/charm/osm-ro/config.yaml b/installers/charm/osm-ro/config.yaml index 9638a774..036eecd4 100644 --- a/installers/charm/osm-ro/config.yaml +++ b/installers/charm/osm-ro/config.yaml @@ -90,4 +90,14 @@ options: $ git clone "https://osm.etsi.org/gerrit/osm/common" /home/ubuntu/common $ juju config ro common-hostpath=/home/ubuntu/common - This configuration only applies if option `debug-mode` is set to true. + This configuration only applies if option `debug-mode` is set to true. + + period_refresh_active: + type: int + description: | + Updates the VNF status from VIM for every given period of time seconds. + Values equal or greater than 60 is allowed. + Disable the updates from VIM by setting -1. + Example: + $ juju config ro period_refresh_active=-1 + $ juju config ro period_refresh_active=100 diff --git a/installers/charm/osm-ro/src/charm.py b/installers/charm/osm-ro/src/charm.py index 8b451914..c19281e7 100755 --- a/installers/charm/osm-ro/src/charm.py +++ b/installers/charm/osm-ro/src/charm.py @@ -203,6 +203,12 @@ class OsmRoCharm(CharmBase): ]: raise CharmError("invalid value for log-level option") + refresh_period = self.config.get("period_refresh_active") + if refresh_period and refresh_period < 60 and refresh_period != -1: + raise ValueError( + "Refresh Period is too tight, insert >= 60 seconds or disable using -1" + ) + def _check_relations(self) -> None: """Validate charm relations. @@ -290,6 +296,8 @@ class OsmRoCharm(CharmBase): "OSMRO_STORAGE_PATH": "/app/storage", "OSMRO_STORAGE_COLLECTION": "files", "OSMRO_STORAGE_URI": self.mongodb_client.connection_string, + "OSMRO_PERIOD_REFRESH_ACTIVE": self.config.get("period_refresh_active") + or 60, }, } }, diff --git a/installers/charm/osm-ro/tox.ini b/installers/charm/osm-ro/tox.ini index b5f809ea..90adfe20 100644 --- a/installers/charm/osm-ro/tox.ini +++ b/installers/charm/osm-ro/tox.ini @@ -52,7 +52,7 @@ commands = description = Check code against coding style standards deps = black - flake8 + flake8==4.0.1 flake8-docstrings flake8-copyright flake8-builtins -- 2.17.1