From: David Garcia Date: Sat, 28 Nov 2020 13:38:35 +0000 (+0100) Subject: Revert "change charm installation for the New generation RO" X-Git-Tag: release-v9.0-start~29 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=d2d52f7193f400dfcf22d1d90ecb82f7921ff871;p=osm%2Fdevops.git Revert "change charm installation for the New generation RO" This reverts commit a578d7154146a7b80c4e07fc9c07d107c89cbadb. Change-Id: I84e3765b8b05942a8aec6f3b752555a61ee73e77 Signed-off-by: David Garcia --- diff --git a/installers/charm/ro-k8s/reactive/ro.py b/installers/charm/ro-k8s/reactive/ro.py index 8ea80705..8f91b4bd 100644 --- a/installers/charm/ro-k8s/reactive/ro.py +++ b/installers/charm/ro-k8s/reactive/ro.py @@ -31,58 +31,40 @@ def upgrade(): def restart(): clear_flag("ro-k8s.configured") -@when_not("kafka.ready") -@when_not("ro-k8s.configured") -@when("leadership.is_leader") -def waiting_for_kafka(): - layer.status.waiting("Waiting for kafka to be ready") - -@when_not("mongo.ready") +@when_not("mysql.available") @when_not("ro-k8s.configured") @when("leadership.is_leader") -def waiting_for_mongo(): - layer.status.waiting("Waiting for mongo to be ready") +def waiting_for_mysql(): + layer.status.waiting("Waiting for mysql to be ready") -@when("kafka.ready", "mongo.ready") +@when("mysql.available") @when_not("ro-k8s.configured") @when("leadership.is_leader") def configure(): layer.status.maintenance("Configuring ro container") try: - kafka = endpoint_from_flag("kafka.ready") - mongo = endpoint_from_flag("mongo.ready") - - if kafka and mongo: - kafka_units = kafka.kafkas() - kafka_unit = kafka_units[0] - - mongo_uri = mongo.connection_string() - log("Mongo URI: {}".format(mongo_uri)) - - if ( - mongo_uri - and kafka_unit["host"] - and kafka_unit["port"] - and ro_unit["host"] - and ro_unit["port"] - ): - spec = make_pod_spec( - kafka_unit["host"], - kafka_unit["port"], - mongo_uri, - ) - - log("set pod spec:\n{}".format(spec)) - pod_spec_set(spec) - layer.status.active("creating container") - set_flag("ro-k8s.configured") + mysql = endpoint_from_flag("mysql.available") + + if mysql.host() is not None: + spec = make_pod_spec( + mysql.host(), + mysql.port(), + mysql.user(), + mysql.password(), + mysql.root_password(), + ) + + log("set pod spec:\n{}".format(spec)) + pod_spec_set(spec) + layer.status.active("creating container") + set_flag("ro-k8s.configured") except Exception as e: layer.status.blocked("k8s spec failed to deploy: {}".format(e)) -@when("kafka.ready", "mongo.ready") +@when("mysql.available") @when_not("leadership.is_leader") def non_leaders_active(): layer.status.active("ready") @@ -109,13 +91,17 @@ def send_config(): log("Fail sending RO configuration: {}".format(e)) -def make_pod_spec(kafka_host, kafka_port, mongo_uri): +def make_pod_spec( + mysql_host, mysql_port, mysql_user, mysql_password, mysql_root_password +): """Make pod specification for Kubernetes Args: - kafka_host (str): Kafka hostname or IP - kafka_port (int): Kafka port - mongo_uri (str): Mongo URI + mysql_name (str): RO DB name + mysql_host (str): RO DB host + mysql_port (int): RO DB port + mysql_user (str): RO DB user + mysql_password (str): RO DB password Returns: pod_spec: Pod specification for Kubernetes """ @@ -123,14 +109,16 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri): with open("reactive/spec_template.yaml") as spec_file: pod_spec_template = spec_file.read() - cfg = config() md = metadata() + cfg = config() data = { "name": md.get("name"), - "kafka_host": kafka_host, - "kafka_port": kafka_port, - "mongo_uri": mongo_uri, + "mysql_host": mysql_host, + "mysql_port": mysql_port, + "mysql_user": mysql_user, + "mysql_password": mysql_password, + "mysql_root_password": mysql_root_password, } data.update(cfg) diff --git a/installers/charm/ro-k8s/reactive/spec_template.yaml b/installers/charm/ro-k8s/reactive/spec_template.yaml index 3663a725..f2b35350 100644 --- a/installers/charm/ro-k8s/reactive/spec_template.yaml +++ b/installers/charm/ro-k8s/reactive/spec_template.yaml @@ -42,13 +42,17 @@ containers: protocol: TCP config: ALLOW_ANONYMOUS_LOGIN: 'yes' - - OSMRO_MESSAGE_DRIVER: kafka - OSMRO_MESSAGE_HOST: %(kafka_host)s - OSMRO_MESSAGE_PORT: %(kafka_port)s - - OSMRO_DATABASE_DRIVER: mongo - OSMRO_DATABASE_URI: %(mongo_uri)s - OSMRO_DATABASE_COMMONKEY: %(DATABASE_COMMONKEY)s - + RO_DB_HOST: %(mysql_host)s + RO_DB_PORT: %(mysql_port)s + RO_DB_NAME: %(ro_database)s + RO_DB_USER: %(mysql_user)s + RO_DB_ROOT_PASSWORD: %(mysql_root_password)s + RO_DB_PASSWORD: %(mysql_password)s + RO_DB_OVIM_PASSWORD: %(mysql_password)s + RO_DB_OVIM_HOST: %(mysql_host)s + RO_DB_OVIM_PORT: %(mysql_port)s + RO_DB_OVIM_USER: %(mysql_user)s + RO_DB_OVIM_ROOT_PASSWORD: %(mysql_root_password)s + RO_DB_OVIM_NAME: %(vim_database)s + OPENMANO_TENANT: %(OPENMANO_TENANT)s