Adding VIM refresh period to RO charm config
[osm/devops.git] / installers / charm / ro / src / charm.py
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"