Bug 2192 - MON charm to support the MON attribute vm_infra_metrics in osm-mon Charm 12/12712/2
authorGuillermo Calvino <guillermo.calvino@canonical.com>
Wed, 23 Nov 2022 09:31:18 +0000 (10:31 +0100)
committerbeierlm <mark.beierl@canonical.com>
Thu, 24 Nov 2022 19:44:05 +0000 (20:44 +0100)
Change-Id: I153b196f67c5b4cf017af15d9a10c8ed98e0dee4
Signed-off-by: Guillermo Calvino <guillermo.calvino@canonical.com>
installers/charm/osm-mon/config.yaml
installers/charm/osm-mon/src/charm.py

index 2b80711..0163151 100644 (file)
@@ -72,6 +72,10 @@ options:
     description: MON will use Keystone backend
     type: boolean
     default: false
+  vm-infra-metrics:
+    description: Enables querying the VIMs asking for the status of the VMs
+    type: boolean
+    default: true
   certificates:
     type: string
     description: |
index f666bd5..176f896 100755 (executable)
@@ -151,10 +151,15 @@ class OsmMonCharm(CharmBase):
     def _on_get_debug_mode_information_action(self, event: ActionEvent) -> None:
         """Handler for the get-debug-mode-information action event."""
         if not self.debug_mode.started:
-            event.fail("debug-mode has not started. Hint: juju config mon debug-mode=true")
+            event.fail(
+                "debug-mode has not started. Hint: juju config mon debug-mode=true"
+            )
             return
 
-        debug_info = {"command": self.debug_mode.command, "password": self.debug_mode.password}
+        debug_info = {
+            "command": self.debug_mode.command,
+            "password": self.debug_mode.password,
+        }
         event.set_results(debug_info)
 
     # ---------------------------------------------------------------------------
@@ -174,9 +179,13 @@ class OsmMonCharm(CharmBase):
             # Action events
             self.on.get_debug_mode_information_action: self._on_get_debug_mode_information_action,
         }
-        for relation in [self.on[rel_name] for rel_name in ["mongodb", "prometheus", "keystone"]]:
+        for relation in [
+            self.on[rel_name] for rel_name in ["mongodb", "prometheus", "keystone"]
+        ]:
             event_handler_mapping[relation.relation_changed] = self._on_config_changed
-            event_handler_mapping[relation.relation_broken] = self._on_required_relation_broken
+            event_handler_mapping[
+                relation.relation_broken
+            ] = self._on_required_relation_broken
 
         for event, handler in event_handler_mapping.items():
             self.framework.observe(event, handler)
@@ -210,7 +219,9 @@ class OsmMonCharm(CharmBase):
         if missing_relations:
             relations_str = ", ".join(missing_relations)
             one_relation_missing = len(missing_relations) == 1
-            error_msg = f'need {relations_str} relation{"" if one_relation_missing else "s"}'
+            error_msg = (
+                f'need {relations_str} relation{"" if one_relation_missing else "s"}'
+            )
             logger.warning(error_msg)
             raise CharmError(error_msg)
 
@@ -225,10 +236,13 @@ class OsmMonCharm(CharmBase):
         environment = {
             # General configuration
             "OSMMON_GLOBAL_LOGLEVEL": self.config["log-level"],
-            "OSMMON_OPENSTACK_DEFAULT_GRANULARITY": self.config["openstack-default-granularity"],
+            "OSMMON_OPENSTACK_DEFAULT_GRANULARITY": self.config[
+                "openstack-default-granularity"
+            ],
             "OSMMON_GLOBAL_REQUEST_TIMEOUT": self.config["global-request-timeout"],
             "OSMMON_COLLECTOR_INTERVAL": self.config["collector-interval"],
             "OSMMON_EVALUATOR_INTERVAL": self.config["evaluator-interval"],
+            "OSMMON_COLLECTOR_VM_INFRA_METRICS": self.config["vm-infra-metrics"],
             # Kafka configuration
             "OSMMON_MESSAGE_DRIVER": "kafka",
             "OSMMON_MESSAGE_HOST": self.kafka.host,
@@ -248,7 +262,7 @@ class OsmMonCharm(CharmBase):
             "OSMMON_KEYSTONE_URL": self.keystone_client.host,
             "OSMMON_KEYSTONE_DOMAIN_NAME": self.keystone_client.user_domain_name,
             "OSMMON_KEYSTONE_SERVICE_PROJECT": self.keystone_client.service,
-            "OSMMON_KEYSTONE_SERVICE_USER": self.keystone_client.username ,
+            "OSMMON_KEYSTONE_SERVICE_USER": self.keystone_client.username,
             "OSMMON_KEYSTONE_SERVICE_PASSWORD": self.keystone_client.password,
             "OSMMON_KEYSTONE_SERVICE_PROJECT_DOMAIN_NAME": self.keystone_client.project_domain_name,
         }