projects
/
osm
/
devops.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better release note check
[osm/devops.git]
/
installers
/
charm
/
lcm-k8s
/
reactive
/
lcm.py
diff --git
a/installers/charm/lcm-k8s/reactive/lcm.py
b/installers/charm/lcm-k8s/reactive/lcm.py
index
3ada8cb
..
87b6b2c
100644
(file)
--- a/
installers/charm/lcm-k8s/reactive/lcm.py
+++ b/
installers/charm/lcm-k8s/reactive/lcm.py
@@
-11,17
+11,23
@@
# 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.
# 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.
-from charms.layer.caas_base import pod_spec_set
-from charms.reactive import endpoint_from_flag
-from charms.reactive import when, when_not, hook
-from charms.reactive.flags import set_flag, clear_flag
+import logging
+import yaml
+
from charmhelpers.core.hookenv import (
log,
metadata,
config,
)
from charms import layer
from charmhelpers.core.hookenv import (
log,
metadata,
config,
)
from charms import layer
-import yaml
+from charms.layer.caas_base import pod_spec_set
+from charms.reactive import endpoint_from_flag
+from charms.reactive import when, when_not, hook
+from charms.reactive.flags import set_flag, clear_flag
+
+
+logger = logging.getLogger(__name__)
+
@hook("upgrade-charm")
@when("leadership.is_leader")
@hook("upgrade-charm")
@when("leadership.is_leader")
@@
-37,18
+43,21
@@
def restart():
@when_not("kafka.ready")
@when_not("lcm-k8s.configured")
@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")
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")
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")
def waiting_for_ro():
layer.status.waiting("Waiting for ro to be ready")
@@
-96,7
+105,14
@@
def configure():
layer.status.blocked("k8s spec failed to deploy: {}".format(e))
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("lcm-k8s.configured")
+@when("leadership.is_leader")
def set_lcm_active():
layer.status.active("ready")
def set_lcm_active():
layer.status.active("ready")
@@
-122,7
+138,6
@@
def make_pod_spec(ro_host, ro_port, kafka_host, kafka_port, mongo_uri):
data = {
"name": md.get("name"),
data = {
"name": md.get("name"),
- "docker_image": cfg.get("image"),
"ro_host": ro_host,
"ro_port": ro_port,
"kafka_host": kafka_host,
"ro_host": ro_host,
"ro_port": ro_port,
"kafka_host": kafka_host,
@@
-130,8
+145,8
@@
def make_pod_spec(ro_host, ro_port, kafka_host, kafka_port, mongo_uri):
"mongo_uri": mongo_uri,
}
data.update(cfg)
"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"]
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