Adding VIM refresh period to RO charm config 86/12286/8
authoraticig <gulsum.atici@canonical.com>
Thu, 30 Jun 2022 00:50:07 +0000 (03:50 +0300)
committerbeierlm <mark.beierl@canonical.com>
Wed, 3 Aug 2022 15:40:03 +0000 (17:40 +0200)
Refresh period is allowed >=60 or -1. Setting it -1
will disable the updating VM status.

Change-Id: I94ec37f68303128ba7af67f14121436005fd9259
Signed-off-by: aticig <gulsum.atici@canonical.com>
installers/charm/ro/config.yaml
installers/charm/ro/src/charm.py

index 8c5740a..31bf8cb 100644 (file)
@@ -35,6 +35,15 @@ options:
     description: "Log Level"
     type: string
     default: "INFO"
+  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
   mysql_host:
     type: string
     description: MySQL Host (external database)
index b196b19..b76fba7 100755 (executable)
@@ -81,6 +81,7 @@ class ConfigModel(ModelValidator):
     image_pull_policy: str
     debug_mode: bool
     security_context: bool
+    period_refresh_active: Optional[int]
 
     @validator("log_level")
     def validate_log_level(cls, v):
@@ -122,6 +123,14 @@ class ConfigModel(ModelValidator):
     def certificates_dict(cls):
         return _extract_certificates(cls.certificates) if cls.certificates else {}
 
+    @validator("period_refresh_active")
+    def validate_vim_refresh_period(cls, v):
+        if v and v < 60 and v != -1:
+            raise ValueError(
+                "Refresh Period is too tight, insert >= 60 seconds or disable using -1"
+            )
+        return v
+
 
 class RoCharm(CharmedOsmBase):
     """GrafanaCharm Charm."""
@@ -271,7 +280,12 @@ class RoCharm(CharmedOsmBase):
                 "OSMRO_LOG_LEVEL": config.log_level,
             }
         )
-
+        if config.period_refresh_active:
+            container_builder.add_envs(
+                {
+                    "OSMRO_PERIOD_REFRESH_ACTIVE": config.period_refresh_active,
+                }
+            )
         if config.enable_ng_ro:
             # Add secrets to the pod
             mongodb_secret_name = f"{self.app.name}-mongodb-secret"