Fixing hostpaths of RO side car charm, updating osm_lib library.
[osm/devops.git] / installers / charm / osm-ro / src / charm.py
index 8b45191..0c5ab9a 100755 (executable)
@@ -49,10 +49,29 @@ from ops.model import ActiveStatus, Container
 
 from legacy_interfaces import MongoClient
 
+ro_host_paths = {
+    "NG-RO": "/usr/lib/python3/dist-packages/osm_ng_ro",
+    "RO-plugin": "/usr/lib/python3/dist-packages/osm_ro_plugin",
+    "RO-SDN-arista_cloudvision": "/usr/lib/python3/dist-packages/osm_rosdn_arista_cloudvision",
+    "RO-SDN-dpb": "/usr/lib/python3/dist-packages/osm_rosdn_dpb",
+    "RO-SDN-dynpac": "/usr/lib/python3/dist-packages/osm_rosdn_dynpac",
+    "RO-SDN-floodlight_openflow": "/usr/lib/python3/dist-packages/osm_rosdn_floodlightof",
+    "RO-SDN-ietfl2vpn": "/usr/lib/python3/dist-packages/osm_rosdn_ietfl2vpn",
+    "RO-SDN-juniper_contrail": "/usr/lib/python3/dist-packages/osm_rosdn_juniper_contrail",
+    "RO-SDN-odl_openflow": "/usr/lib/python3/dist-packages/osm_rosdn_odlof",
+    "RO-SDN-onos_vpls": "/usr/lib/python3/dist-packages/osm_rosdn_onos_vpls",
+    "RO-VIM-aws": "/usr/lib/python3/dist-packages/osm_rovim_aws",
+    "RO-VIM-azure": "/usr/lib/python3/dist-packages/osm_rovim_azure",
+    "RO-VIM-gcp": "/usr/lib/python3/dist-packages/osm_rovim_gcp",
+    "RO-VIM-openstack": "/usr/lib/python3/dist-packages/osm_rovim_openstack",
+    "RO-VIM-openvim": "/usr/lib/python3/dist-packages/osm_rovim_openvim",
+    "RO-VIM-vmware": "/usr/lib/python3/dist-packages/osm_rovim_vmware",
+}
 HOSTPATHS = [
     HostPath(
         config="ro-hostpath",
-        container_path="/usr/lib/python3/dist-packages/osm_ro",
+        container_path="/usr/lib/python3/dist-packages/",
+        submodules=ro_host_paths,
     ),
     HostPath(
         config="common-hostpath",
@@ -102,7 +121,8 @@ class OsmRoCharm(CharmBase):
             check_container_ready(self.container)
 
             self._configure_certificates()
-            self._configure_service()
+            if not self.debug_mode.started:
+                self._configure_service()
             self._update_ro_relation()
 
             # Update charm status
@@ -203,6 +223,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 +316,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,
                     },
                 }
             },