X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fpla%2Fsrc%2Fcharm.py;h=1fc6386fa64270e98667e97fc0abf40115a917ed;hb=45a6b9d19e387e82ef80141fab27be076e3a9f74;hp=f90b407a0a90d5a7ad7d9c2079595783daacfbc4;hpb=5863d3e8d8dca5108d89b993d5eb019ab16df587;p=osm%2Fdevops.git diff --git a/installers/charm/pla/src/charm.py b/installers/charm/pla/src/charm.py index f90b407a..1fc6386f 100755 --- a/installers/charm/pla/src/charm.py +++ b/installers/charm/pla/src/charm.py @@ -43,8 +43,6 @@ class PLACharm(CharmBase): self.state.set_default(kafka_host=None) self.state.set_default(kafka_port=None) self.state.set_default(mongodb_uri=None) - self.state.set_default(mysql_host=None) - self.state.set_default(mysql_port=None) # Observe Charm related events self.framework.observe(self.on.config_changed, self.on_config_changed) @@ -58,15 +56,12 @@ class PLACharm(CharmBase): self.framework.observe( self.on.mongo_relation_changed, self.on_mongo_relation_changed ) - self.framework.observe( - self.on.mysql_relation_changed, self.on_mysql_relation_changed - ) def _apply_spec(self): # Only apply the spec if this unit is a leader. unit = self.model.unit if not unit.is_leader(): - unit.status = ActiveStatus("Ready") + unit.status = ActiveStatus("ready") return if not self.state.kafka_host or not self.state.kafka_port: unit.status = WaitingStatus("Waiting for Kafka") @@ -74,31 +69,22 @@ class PLACharm(CharmBase): if not self.state.mongodb_uri: unit.status = WaitingStatus("Waiting for MongoDB") return - if not self.state.mysql_host or not self.state.mysql_port: - unit.status = WaitingStatus("Waiting for MySQL") - return unit.status = MaintenanceStatus("Applying new pod spec") new_spec = self.make_pod_spec() if new_spec == self.state.spec: - unit.status = ActiveStatus("Ready") + unit.status = ActiveStatus("ready") return self.framework.model.pod.set_spec(new_spec) self.state.spec = new_spec - unit.status = ActiveStatus("Ready") + unit.status = ActiveStatus("ready") def make_pod_spec(self): config = self.framework.model.config - mysql_uri = "mysql://root:{}@{}:{}/{}".format( - self.state.mysql_root_password, - self.state.mysql_host, - self.state.mysql_port, - self.state.mysql_database, - ) ports = [ - {"name": "port", "containerPort": config["port"], "protocol": "TCP",}, + {"name": "port", "containerPort": config["port"], "protocol": "TCP", }, ] config_spec = { @@ -108,7 +94,6 @@ class PLACharm(CharmBase): "OSMPLA_DATABASE_DRIVER": "mongo", "OSMPLA_DATABASE_URI": self.state.mongodb_uri, "OSMPLA_GLOBAL_LOG_LEVEL": config["log_level"], - "OSMPLA_SQL_DATABASE_URI": mysql_uri, "OSMPLA_DATABASE_COMMONKEY": config["database_common_key"], } @@ -157,17 +142,6 @@ class PLACharm(CharmBase): ) self._apply_spec() - def on_mysql_relation_changed(self, event): - unit = self.model.unit - if not unit.is_leader(): - return - unit_data = event.relation.data[event.unit] - self.state.mysql_host = unit_data.get("host") - self.state.mysql_port = unit_data.get("port") - self.state.mysql_root_password = unit_data.get("root_password") - self.state.mysql_database = self.model.config["database"] - self._apply_spec() - if __name__ == "__main__": main(PLACharm)