Example #1
0
def _update_tls(rid=None):
    rids = [rid] if rid else relation_ids("tls-certificates")
    if not rids:
        return

    config['tls_present'] = True
    settings = common_utils.get_tls_settings(utils.get_vhost_ip())
    for rid in rids:
        relation_set(relation_id=rid, relation_settings=settings)
Example #2
0
def contrail_controller_changed():
    data = relation_get()
    log("RelData: " + str(data))

    def _update_config(key, data_key):
        if data_key in data:
            config[key] = data[data_key]
        else:
            config.pop(key, None)

    _update_config("analytics_servers", "analytics-server")
    _update_config("analyticsdb_enabled", "analyticsdb_enabled")
    _update_config("auth_info", "auth-info")
    _update_config("orchestrator_info", "orchestrator-info")
    _update_config("controller_ips", "controller_ips")
    _update_config("controller_data_ips", "controller_data_ips")
    _update_config("issu_controller_ips", "issu_controller_ips")
    _update_config("issu_controller_data_ips", "issu_controller_data_ips")
    _update_config("issu_analytics_ips", "issu_analytics_ips")

    maintenance = None
    if "maintenance" in data:
        maintenance = "issu"
    if "ziu" in data or "ziu_done" in data:
        maintenance = "ziu"
    if maintenance:
        config["maintenance"] = maintenance
    else:
        config.pop("maintenance", None)

    info = common_utils.json_loads(data.get("agents-info"), dict())
    k8s_info = info.get("k8s_info")
    if k8s_info:
        ip = unit_private_ip()
        for cluster in k8s_info:
            kubernetes_workers = k8s_info[cluster].get("kubernetes_workers",
                                                       [])
            if kubernetes_workers and ip in kubernetes_workers:
                config["pod_subnets"] = k8s_info[cluster].get("pod_subnets")
                break

    if "controller_data_ips" in data:
        settings = {"vhost-address": utils.get_vhost_ip()}
        for rid in relation_ids("agent-cluster"):
            relation_set(relation_id=rid, relation_settings=settings)

    utils.update_ziu("controller-changed")
    utils.update_charm_status()
Example #3
0
def contrail_controller_changed():
    data = relation_get()
    log("RelData: " + str(data))

    def _update_config(key, data_key):
        if data_key in data:
            config[key] = data[data_key]
        else:
            config.pop(key, None)

    _update_config("analytics_servers", "analytics-server")
    _update_config("auth_info", "auth-info")
    _update_config("orchestrator_info", "orchestrator-info")
    _update_config("controller_ips", "controller_ips")
    _update_config("controller_data_ips", "controller_data_ips")
    _update_config("issu_controller_ips", "issu_controller_ips")
    _update_config("issu_controller_data_ips", "issu_controller_data_ips")
    _update_config("issu_analytics_ips", "issu_analytics_ips")

    if "controller_data_ips" in data:
        settings = {"vhost-address": utils.get_vhost_ip()}
        for rid in relation_ids("agent-cluster"):
            relation_set(relation_id=rid, relation_settings=settings)

    maintenance = None
    if "maintenance" in data:
        maintenance = "issu"
    if "ziu" in data or "ziu_done" in data:
        maintenance = "ziu"
    if maintenance:
        config["maintenance"] = maintenance
    else:
        config.pop("maintenance", None)

    config.save()

    utils.update_ziu("controller-changed")
    utils.update_charm_status()
Example #4
0
def tls_certificates_relation_joined():
    settings = common_utils.get_tls_settings(utils.get_vhost_ip())
    relation_set(relation_settings=settings)