def config_changed(): utils.update_nrpe_config() auth_mode = config.get("auth-mode") if auth_mode not in ("rbac", "cloud-admin", "no-auth"): raise Exception("Config is invalid. auth-mode must one of: " "rbac, cloud-admin, no-auth.") if config.changed("control-network") or config.changed("data-network"): ip = common_utils.get_ip() data_ip = common_utils.get_ip(config_param="data-network", fallback=ip) rel_settings = {"private-address": ip} for rname in ("http-services", "https-services"): for rid in relation_ids(rname): relation_set(relation_id=rid, relation_settings=rel_settings) cluster_settings = {"unit-address": ip, "data-address": data_ip} if config.get('local-rabbitmq-hostname-resolution'): cluster_settings.update({ "rabbitmq-hostname": utils.get_contrail_rabbit_hostname(), }) # this will also take care of updating the hostname in case # control-network changes to something different although # such host reconfiguration is unlikely utils.update_rabbitmq_cluster_hostnames() for rid in relation_ids("controller-cluster"): relation_set(relation_id=rid, relation_settings=cluster_settings) if is_leader(): _address_changed(local_unit(), ip, 'ip') _address_changed(local_unit(), data_ip, 'data_ip') if config.changed("local-rabbitmq-hostname-resolution"): if config.get("local-rabbitmq-hostname-resolution"): # enabling this option will trigger events on other units # so their hostnames will be added as -changed events fire # we just need to set our hostname utils.update_rabbitmq_cluster_hostnames() else: kvstore = kv() rabbitmq_hosts = kvstore.get(key='rabbitmq_hosts', default={}) for ip, hostname in rabbitmq_hosts: utils.update_hosts_file(ip, hostname, remove_hostname=True) docker_utils.config_changed() utils.update_charm_status() # leave it after update_charm_status - in case of exception in previous steps # config.changed doesn't work sometimes... if config.get("saved-image-tag") != config["image-tag"]: utils.update_ziu("image-tag") config["saved-image-tag"] = config["image-tag"] config.save() update_http_relations() update_https_relations() update_northbound_relations() update_southbound_relations() update_issu_relations()
def tls_certificates_relation_departed(): config['tls_present'] = False common_utils.tls_changed(utils.MODULE, None) update_southbound_relations() update_http_relations() update_https_relations() utils.update_nrpe_config() utils.update_charm_status()
def tls_certificates_relation_departed(): if not common_utils.tls_changed(utils.MODULE, None): return update_southbound_relations() update_http_relations() update_https_relations() utils.update_nrpe_config() utils.update_charm_status()
def tls_certificates_relation_changed(): # it can be fired several times without server's cert if not common_utils.tls_changed(utils.MODULE, relation_get()): return update_southbound_relations() update_http_relations() update_https_relations() utils.update_nrpe_config() utils.update_charm_status()
def nrpe_external_master_relation_changed(): utils.update_nrpe_config()
def tls_certificates_relation_changed(): if common_utils.tls_changed(utils.MODULE, relation_get()): update_southbound_relations() utils.update_nrpe_config() utils.update_charm_status()
def tls_certificates_relation_departed(): if common_utils.tls_changed(utils.MODULE, None): update_southbound_relations() _notify_haproxy_services() utils.update_nrpe_config() utils.update_charm_status()