コード例 #1
0
def stop_controller():
    docker_utils.compose_down(CONFIG_API_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(CONFIG_DATABASE_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(CONTROL_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(WEBUI_CONFIGS_PATH + "/docker-compose.yaml")

    # TODO: Redis is common service. We can't stop it here.
    if os.path.exists(REDIS_CONFIGS_PATH + "/docker-compose.yaml"):
        docker_utils.compose_down(REDIS_CONFIGS_PATH + "/docker-compose.yaml")
コード例 #2
0
def stop_agent():
    docker_utils.compose_kill(VROUTER_COMPOSE_PATH, "SIGQUIT", "vrouter-agent")
    # wait for exited code for vrouter-agent. Each 5 seconds, max wait 1 minute
    for i in range(0, 12):
        state = docker_utils.get_container_state(VROUTER_COMPOSE_PATH,
                                                 "vrouter-agent")
        if not state or state.get('Status', '').lower() != 'running':
            break
    else:
        raise Exception(
            "vrouter-agent do not react to SIGQUIT. please check it manually and run update-status."
        )
    docker_utils.compose_down(VROUTER_COMPOSE_PATH)
    docker_utils.compose_down(VROUTER_INIT_COMPOSE_PATH)
コード例 #3
0
def stop_agent():
    path = CONFIGS_PATH + "/docker-compose.yaml"
    docker_utils.compose_kill(path, "SIGQUIT", "vrouter-agent")
    # wait for exited code for vrouter-agent. Each 5 seconds, max wait 1 minute
    for i in range(0, 12):
        state = docker_utils.get_container_state(path, "vrouter-agent")
        if not state or state.get('Status', '').lower() != 'running':
            break
    else:
        raise Exception("vrouter-agent do not react to SIGQUIT. please check it manually and re-run operation.")
    docker_utils.compose_down(path)
    # remove all built vrouter.ko
    modules = '/lib/modules'
    for item in os.listdir(modules):
        path = os.path.join(modules, item, 'updates/dkms/vrouter.ko')
        try:
            os.remove(path)
        except Exception:
            pass
コード例 #4
0
def ziu_stage_1(ziu_stage, trigger):
    # stop API services
    cver = common_utils.get_contrail_version()
    docker_utils.compose_down(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(REDIS_CONFIGS_PATH + "/docker-compose.yaml")
    if cver >= 510:
        docker_utils.compose_down(ANALYTICS_ALARM_CONFIGS_PATH +
                                  "/docker-compose.yaml")
        docker_utils.compose_down(ANALYTICS_SNMP_CONFIGS_PATH +
                                  "/docker-compose.yaml")

    signal_ziu("ziu_done", ziu_stage)
コード例 #5
0
def ziu_stage_1(ziu_stage, trigger):
    # stop API services
    ctx = get_context()
    docker_utils.compose_down(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(REDIS_CONFIGS_PATH + "/docker-compose.yaml")
    # can i get_context() here and pass it to ziu_stage_2 ???
    if ctx["contrail_version"] >= 510 and ctx.get("analyticsdb_enabled"):
        docker_utils.compose_down(ANALYTICS_ALARM_CONFIGS_PATH +
                                  "/docker-compose.yaml")
        docker_utils.compose_down(ANALYTICS_SNMP_CONFIGS_PATH +
                                  "/docker-compose.yaml")

    signal_ziu("ziu_done", ziu_stage)
コード例 #6
0
def stop_analytics():
    docker_utils.compose_down(ANALYTICS_CONFIGS_PATH + "/docker-compose.yaml")

    if os.path.exists(ANALYTICS_SNMP_CONFIGS_PATH + "/docker-compose.yaml"):
        docker_utils.compose_down(ANALYTICS_SNMP_CONFIGS_PATH +
                                  "/docker-compose.yaml")
    if os.path.exists(ANALYTICS_ALARM_CONFIGS_PATH + "/docker-compose.yaml"):
        docker_utils.compose_down(ANALYTICS_ALARM_CONFIGS_PATH +
                                  "/docker-compose.yaml")

    # TODO: Redis is a common service. We can't stop it here
    if os.path.exists(REDIS_CONFIGS_PATH + "/docker-compose.yaml"):
        docker_utils.compose_down(REDIS_CONFIGS_PATH + "/docker-compose.yaml")
コード例 #7
0
def ziu_stage_1(ziu_stage, trigger):
    # stop API services
    docker_utils.compose_down(CONFIG_API_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(WEBUI_CONFIGS_PATH + "/docker-compose.yaml")
    docker_utils.compose_down(REDIS_CONFIGS_PATH + "/docker-compose.yaml")
    signal_ziu("ziu_done", ziu_stage)
コード例 #8
0
def stop_analyticsdb():
    docker_utils.compose_down(CONFIGS_PATH + "/docker-compose.yaml")
コード例 #9
0
def stop_kubernetes_node():
    docker_utils.compose_down(CONFIGS_PATH + "/docker-compose.yaml")
コード例 #10
0
def _update_charm_status(ctx):
    missing_relations = []
    if not ctx.get("controller_servers"):
        missing_relations.append("contrail-controller")
    if config.get("wait-for-external-plugin",
                  False) and "plugin_settings" not in ctx:
        missing_relations.append("vrouter-plugin")
    if missing_relations:
        status_set('blocked',
                   'Missing relations: ' + ', '.join(missing_relations))
        return
    if not ctx.get("analytics_servers"):
        status_set(
            'blocked', 'Missing analytics_servers info in relation '
            'with contrail-controller.')
        return
    if not ctx.get("cloud_orchestrator"):
        status_set(
            'blocked', 'Missing cloud_orchestrator info in relation '
            'with contrail-controller.')
        return
    if ctx.get("cloud_orchestrator"
               ) == "openstack" and not ctx.get("keystone_ip"):
        status_set('blocked',
                   'Missing auth info in relation with contrail-controller.')
        return
    if ctx.get("cloud_orchestrator"
               ) == "kubernetes" and not ctx.get("kube_manager_token"):
        status_set('blocked', 'Kube manager token undefined.')
        return
    if ctx.get("cloud_orchestrator"
               ) == "kubernetes" and not ctx.get("kubernetes_api_server"):
        status_set('blocked', 'Kubernetes API unavailable')
        return

    # TODO: what should happens if relation departed?

    # local file for vif utility
    common_utils.render_and_log("contrail-vrouter-agent.conf",
                                "/etc/contrail/contrail-vrouter-agent.conf",
                                ctx,
                                perms=0o440)

    changed = common_utils.apply_keystone_ca(MODULE, ctx)
    changed |= common_utils.render_and_log(
        "vrouter.env", BASE_CONFIGS_PATH + "/common_vrouter.env", ctx)
    changed |= common_utils.render_and_log("vrouter.yaml",
                                           VROUTER_COMPOSE_PATH, ctx)
    changed |= common_utils.render_and_log("vrouter-init.yaml",
                                           VROUTER_INIT_COMPOSE_PATH, ctx)

    if is_vrouter_init_successfully_passed():
        docker_utils.compose_run(VROUTER_COMPOSE_PATH, changed)
    else:
        # let's down this compose. it will not fail but this will guarantee next run
        docker_utils.compose_down(VROUTER_INIT_COMPOSE_PATH)
        docker_utils.compose_run(VROUTER_INIT_COMPOSE_PATH, True)

    if is_reboot_required():
        status_set('blocked',
                   'Reboot is required due to hugepages allocation.')
        return

    common_utils.update_services_status(MODULE, SERVICES)
コード例 #11
0
def stop_openstack_ironic():
    docker_utils.compose_down(CONFIGS_PATH + "/docker-compose.yaml")