def analyticsdb_departed():
    units = [unit for rid in relation_ids("contrail-controller")
                  for unit in related_units(rid)]
    if not units:
        for key in ["auth_info", "orchestrator_info", "ssl_enabled"]:
            config.pop(key, None)
        if is_container_launched(CONTAINER_NAME):
            status_set(
                "blocked",
                "Container is present but cloud orchestrator was disappeared."
                " Please kill container by yourself or restore"
                " cloud orchestrator.")
    update_charm_status()
Example #2
0
def check_run_prerequisites(name, config_name, update_config_func, services):
    if is_container_launched(name):
        # already launched. just sync config if needed.
        check = True
        if update_config_func and update_config_func():
            check = apply_config_in_container(name, config_name)
        if check:
            update_services_status(name, services)
        return False

    if is_container_present(name):
        status_set(
            "blocked",
            "Container is present but is not running. Run or remove it.")
        return False

    image_name = config.get("image-name")
    image_tag = config.get("image-tag")
    if not image_name or not image_tag:
        image_name, image_tag = load_docker_image(name)
        if not image_name or not image_tag:
            status_set(
                "blocked", "No image is available. Resourse is not "
                "attached and there are no image-name/image-tag "
                "defined in charm configuration.")
            return False
        config["image-name"] = image_name
        config["image-tag"] = image_tag
        config.save()

    if "version" not in config:
        # current jinja2 doesn't support version_compare filter.
        # so build version variable as: a.b.c.d => a*1e4 + b*1e2 + c and then
        # compare it with integers like: 40002, 40100
        # 4.0.0 => 40000
        # 4.0.1 => 40001
        # 4.0.2 => 40002
        # 4.1.0 => 40100
        version = get_contrail_version()
        application_version_set(version)
        config["version_with_build"] = version
        version = version.split('-')[0].split('.')
        m = int(version[0])
        r = int(version[1]) if len(version) > 1 else 0
        a = int(version[2]) if len(version) > 2 else 0
        config["version"] = (m * 1e4) + (r * 1e2) + a
        config.save()

    return True
Example #3
0
def contrail_controller_departed():
    # while we have at least one openstack unit on the remote end
    # then we can suggest that orchestrator is still openstack
    for rid in relation_ids("contrail-controller"):
        for unit in related_units(rid):
            utype = relation_get('unit-type', unit, rid)
            if utype == "openstack":
                return

    config.pop("orchestrator_info", None)
    if is_leader():
        update_northbound_relations()
    if is_container_launched(CONTAINER_NAME):
        status_set(
            "blocked",
            "Container is present but cloud orchestrator was disappeared. "
            "Please kill container by yourself or restore cloud orchestrator.")
def contrail_controller_departed():
    if not remote_unit().startswith("contrail-openstack-compute"):
        return

    units = [
        unit for rid in relation_ids("contrail-openstack-compute")
        for unit in related_units(rid)
    ]
    if units:
        return
    config.pop("orchestrator_info", None)
    if is_leader():
        update_northbound_relations()
    if is_container_launched(CONTAINER_NAME):
        status_set(
            "blocked",
            "Container is present but cloud orchestrator was disappeared. "
            "Please kill container by yourself or restore cloud orchestrator.")
Example #5
0
def contrail_analytics_departed():
    units = [
        unit for rid in relation_ids("contrail-controller")
        for unit in related_units(rid)
    ]
    if not units:
        for key in [
                "auth_info", "auth_mode", "orchestrator_info", "ssl_ca",
                "ssl_cert", "ssl_key", "rabbitmq_vhost", "rabbitmq_user",
                "rabbitmq_password"
        ]:
            config.pop(key, None)
        if is_container_launched(CONTAINER_NAME):
            status_set(
                "blocked",
                "Container is present but cloud orchestrator was disappeared."
                " Please kill container by yourself or restore cloud orchestrator."
            )
    update_charm_status()
Example #6
0
def check_run_prerequisites(name, config_name, update_config_func, services):
    if is_container_launched(name):
        check = True
        if update_config_func:
            update_config_func()
            check = apply_config_in_container(name, config_name)
        if check:
            update_services_status(name, services)
        return False

    if is_container_present(name):
        status_set(
            "blocked",
            "Container is present but is not running. Run or remove it.")
        return False

    image_id = get_docker_image_id(name)
    if not image_id:
        image_id = load_docker_image(name)
        if not image_id:
            status_set("waiting", "Awaiting for container resource")
            return False

    return True