gui-x: 0
gui-y: 50
nbi-k8s:
- charm: "cs:~charmed-osm/nbi-k8s"
+ charm: "%(prefix)s/nbi-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
gui-x: 0
gui-y: -200
ro-k8s:
- charm: "cs:~charmed-osm/ro-k8s"
+ charm: "%(prefix)s/ro-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
gui-x: -250
gui-y: 300
ui-k8s:
- charm: "cs:~charmed-osm/ui-k8s"
+ charm: "%(prefix)s/ui-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
gui-x: 500
gui-y: 100
lcm-k8s:
- charm: "cs:~charmed-osm/lcm-k8s"
+ charm: "%(prefix)s/lcm-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
gui-x: -250
gui-y: 50
mon-k8s:
- charm: "cs:~charmed-osm/mon-k8s"
+ charm: "%(prefix)s/mon-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
gui-x: 250
gui-y: 50
pol-k8s:
- charm: "cs:~charmed-osm/pol-k8s"
+ charm: "%(prefix)s/pol-k8s%(suffix)s"
channel: "%(channel)s"
scale: 3
series: kubernetes
)
from charms import layer
import yaml
+import logging
+
+logger = logging.getLogger(__name__)
+
@hook("upgrade-charm")
@when("leadership.is_leader")
@when_not("kafka.ready")
@when_not("lcm-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("lcm-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_mongo():
layer.status.waiting("Waiting for mongo to be ready")
@when_not("ro.ready")
@when_not("lcm-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_ro():
layer.status.waiting("Waiting for ro to be ready")
layer.status.blocked("k8s spec failed to deploy: {}".format(e))
+@when("kafka.ready", "mongo.ready", "ro.ready")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
@when("lcm-k8s.configured")
+@when("leadership.is_leader")
def set_lcm_active():
layer.status.active("ready")
"mongo_uri": mongo_uri,
}
data.update(cfg)
-
- spec = yaml.safe_dump(pod_spec_template % data)
+ logs = pod_spec_template % data
+ spec = yaml.safe_load(pod_spec_template % data)
if "vca_apiproxy" in cfg and cfg["vca_apiproxy"] != "":
spec["containers"][0]["config"]["OSMLCM_VCA_APIPROXY"] = cfg["vca_apiproxy"]
- return spec
\ No newline at end of file
+ return spec
@when_not("kafka.ready")
@when_not("mon-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("mon-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_mongo():
layer.status.waiting("Waiting for mongo to be ready")
@when_not("endpoint.prometheus.available")
@when_not("mon-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_prometheus():
layer.status.waiting("Waiting for prometheus to be ready")
layer.status.blocked("k8s spec failed to deploy: {}".format(e))
+@when("kafka.ready", "mongo.ready", "endpoint.prometheus.available")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
@when("mon-k8s.configured")
def set_mon_active():
layer.status.active("ready")
@when_not("kafka.ready")
@when_not("nbi-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("nbi-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_mongo():
layer.status.waiting("Waiting for mongo to be ready")
@when_not("endpoint.prometheus.available")
@when_not("nbi-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_prometheus():
layer.status.waiting("Waiting for prometheus to be ready")
@when_not("keystone.ready")
+@when("leadership.is_leader")
+@when_not("nbi-k8s.configured")
+def waiting_for_keystone():
+ auth_backend = config().get("auth-backend")
+ if auth_backend == "keystone":
+ layer.status.waiting("Waiting for Keystone to be ready")
+ else:
+ set_flag("keystone.ready")
+
+
+@when_not("keystone.ready")
+@when("leadership.is_leader")
@when_not("nbi-k8s.configured")
def waiting_for_keystone():
auth_backend = config().get("auth-backend")
log("Error: {}".format(traceback.format_exc()))
+@when("kafka.ready", "mongo.ready", "endpoint.prometheus.available")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
@when("nbi-k8s.configured")
def set_nbi_active():
layer.status.active("ready")
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+.vscode
+build
+ng-ui.charm
\ No newline at end of file
+++ /dev/null
-../src/charm.py
\ No newline at end of file
+++ /dev/null
-../mod/operator/ops
\ No newline at end of file
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ops
},
}
)
- logger.debug(files)
+
spec = {
"version": 2,
"containers": [
self.on_start(event)
def on_nbi_relation_changed(self, event):
- unit = self.model.unit
- if not unit.is_leader():
- return
- self.state.nbi_host = event.relation.data[event.unit].get("host")
- self.state.nbi_port = event.relation.data[event.unit].get("port")
+ nbi_host = event.relation.data[event.unit].get("host")
+ nbi_port = event.relation.data[event.unit].get("port")
+ if nbi_host and self.state.nbi_host != nbi_host:
+ self.state.nbi_host = nbi_host
+ if nbi_port and self.state.nbi_port != nbi_port:
+ self.state.nbi_port = nbi_port
self._apply_spec()
PYTHONHASHSEED=0
whitelist_externals = juju
passenv = HOME TERM CS_API_* OS_* AMULET_*
-deps = -r{toxinidir}/test-requirements.txt
install_command =
pip install {opts} {packages}
+[testenv:build]
+basepython = python3
+passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
+whitelist_externals = charmcraft
+ rm
+ unzip
+commands =
+ rm -rf release
+ charmcraft build
+ unzip ng-ui.charm -d release
+
[testenv:black]
basepython = python3
deps =
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+.vscode
+build
+pla.charm
\ No newline at end of file
+++ /dev/null
-../src/charm.py
\ No newline at end of file
+++ /dev/null
-../src/charm.py
\ No newline at end of file
+++ /dev/null
-../src/charm.py
\ No newline at end of file
+++ /dev/null
-../mod/operator/ops
\ No newline at end of file
--- /dev/null
+# Copyright 2020 Canonical Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+ops
config = self.framework.model.config
ports = [
- {"name": "port", "containerPort": config["port"], "protocol": "TCP", },
+ {"name": "port", "containerPort": config["port"], "protocol": "TCP",},
]
config_spec = {
"""Upgrade the charm."""
unit = self.model.unit
unit.status = MaintenanceStatus("Upgrading charm")
- self.on_start(event)
+ self._apply_spec()
def on_kafka_relation_changed(self, event):
- unit = self.model.unit
- if not unit.is_leader():
- return
- self.state.kafka_host = event.relation.data[event.unit].get("host")
- self.state.kafka_port = event.relation.data[event.unit].get("port")
+ kafka_host = event.relation.data[event.unit].get("host")
+ kafka_port = event.relation.data[event.unit].get("port")
+ if kafka_host and self.state.kafka_host != kafka_host:
+ self.state.kafka_host = kafka_host
+ if kafka_port and self.state.kafka_port != kafka_port:
+ self.state.kafka_port = kafka_port
self._apply_spec()
def on_mongo_relation_changed(self, event):
- unit = self.model.unit
- if not unit.is_leader():
- return
- self.state.mongodb_uri = event.relation.data[event.unit].get(
+ mongodb_uri = event.relation.data[event.unit].get(
"connection_string"
)
+ if mongodb_uri and self.state.mongodb_uri != mongodb_uri:
+ self.state.mongodb_uri = mongodb_uri
self._apply_spec()
PYTHONHASHSEED=0
whitelist_externals = juju
passenv = HOME TERM CS_API_* OS_* AMULET_*
-deps = -r{toxinidir}/test-requirements.txt
install_command =
pip install {opts} {packages}
+
+[testenv:build]
+basepython = python3
+passenv=HTTP_PROXY HTTPS_PROXY NO_PROXY
+whitelist_externals = charmcraft
+ rm
+ unzip
+commands =
+ rm -rf release
+ charmcraft build
+ unzip pla.charm -d release
+
[testenv:black]
basepython = python3
deps =
@when_not("kafka.ready")
+@when("leadership.is_leader")
@when_not("pol-k8s.configured")
def waiting_for_kafka():
layer.status.waiting("Waiting for kafka to be ready")
@when_not("mongo.ready")
+@when("leadership.is_leader")
@when_not("pol-k8s.configured")
def waiting_for_mongo():
layer.status.waiting("Waiting for mongo to be ready")
layer.status.blocked("k8s spec failed to deploy: {}".format(e))
+@when("kafka.ready", "mongo.ready")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
@when("pol-k8s.configured")
def set_pol_active():
layer.status.active("ready")
@when_not("mysql.available")
@when_not("ro-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_mysql():
layer.status.waiting("Waiting for mysql to be ready")
try:
mysql = endpoint_from_flag("mysql.available")
- 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")
+ 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("mysql.available")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
@when("ro-k8s.configured")
def set_ro_active():
layer.status.active("ready")
@when_not("mysql.available")
@when_not("ui-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_mysql():
layer.status.waiting("Waiting for mysql to be available")
@when_not("nbi.ready")
@when_not("ui-k8s.configured")
+@when("leadership.is_leader")
def waiting_for_nbi():
layer.status.waiting("Waiting for nbi to be available")
layer.status.blocked("k8s spec failed to deploy: {}".format(e))
+@when("mysql.available", "nbi.ready")
+@when_not("leadership.is_leader")
+def non_leaders_active():
+ layer.status.active("ready")
+
+
@when("ui-k8s.configured")
def set_ui_active():
layer.status.active("ready")