Exemplo n.º 1
0
def is_vrouter_init_successfully_passed():
    init_state = docker_utils.get_container_state(VROUTER_INIT_COMPOSE_PATH,
                                                  "vrouter-kernel-init")
    if not init_state:
        return False
    if init_state.get('Status').lower() == 'running':
        return False
    if init_state.get('ExitCode') != 0:
        return False
    return True
Exemplo n.º 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)
Exemplo n.º 3
0
def compile_kernel_modules():
    modules = '/lib/modules'
    need_to_compile = False
    for item in os.listdir(modules):
        # vrouter doesn't support kernels version 5, remove check after fix
        if item.split('.')[0] == '5':
            continue
        path = os.path.join(modules, item, 'updates/dkms/vrouter.ko')
        if not os.path.exists(path):
            need_to_compile = True
            break
    contrail_version = common_utils.get_contrail_version()
    if not need_to_compile or contrail_version < 2008:
        return

    path = CONFIGS_PATH + "/docker-compose.yaml"
    state = docker_utils.get_container_state(path, "vrouter-kernel-init")
    if state and state.get('Status', '').lower() != 'running':
        docker_utils.restart_container(path, "vrouter-kernel-init")
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
Exemplo n.º 5
0
def _has_provisioning_finished_for_container(name, configs_path):
    try:
        # check tail first. for R2008 and further this should work
        data = docker_utils.execute(name, ['ps', '-ax'])
        return '/provision.sh' not in data
    except Exception:
        pass
    try:
        # for R2005 let's check exit status
        state = docker_utils.get_container_state(configs_path + "/docker-compose.yaml", "provisioner")
        if not state:
            return False
        if state.get('Status').lower() == 'running':
            return False
        if state.get('ExitCode') != 0:
            return False
        return True
    except Exception:
        pass
    return False