def analyticsdb_changed(): # this method catches hook from controller and from analytics - so read all data = relation_get() _value_changed(data, "auth-info", "auth_info") _value_changed(data, "orchestrator-info", "orchestrator_info") _value_changed(data, "maintenance", "maintenance") _value_changed(data, "controller_ips", "controller_ips") _value_changed(data, "controller_data_ips", "controller_data_ips") _value_changed(data, "analytics_ips", "analytics_ips") # TODO: handle changing of all values # TODO: set error if orchestrator is changing and container was started utils.update_ziu("analyticsdb-changed") utils.update_charm_status()
def analyticsdb_cluster_changed(): data = relation_get() log("Peer relation changed with {}: {}".format(remote_unit(), data)) ip = data.get("unit-address") if not ip: log("There is no unit-address in the relation") elif is_leader(): unit = remote_unit() if _address_changed(unit, ip): _update_analyticsdb() utils.update_charm_status() utils.update_ziu("cluster-changed")
def config_changed(): utils.update_nrpe_config() if config.changed("control-network"): _update_cluster() if is_leader() and _address_changed(local_unit(), common_utils.get_ip()): _update_analyticsdb() docker_utils.config_changed() utils.update_charm_status() # leave it as latest - in case of exception in previous steps # config.changed doesn't work sometimes (when we saved config in this hook before) if config.get("saved-image-tag") != config["image-tag"]: utils.update_ziu("image-tag") config["saved-image-tag"] = config["image-tag"] config.save()
def update_status(): utils.update_ziu("update-status") utils.update_charm_status()