コード例 #1
0
ファイル: node.py プロジェクト: djosborne/calico-containers
def node(arguments):
    """
    Main dispatcher for node commands. Calls the corresponding helper function.

    :param arguments: A dictionary of arguments already processed through
    this file's docstring with docopt
    :return: None
    """
    validate_arguments(arguments)

    backend = get_networking_backend(arguments.get('--backend'))

    as_num = convert_asn_to_asplain(arguments.get("<AS_NUM>") or arguments.get("--as"))

    if arguments.get("bgp"):
        if arguments.get("peer"):
            ip_version = get_container_ipv_from_arguments(arguments)
            if arguments.get("add"):
                node_bgppeer_add(arguments.get("<PEER_IP>"), ip_version,
                                 as_num)
            elif arguments.get("remove"):
                node_bgppeer_remove(arguments.get("<PEER_IP>"), ip_version)
            elif arguments.get("show"):
                if not ip_version:
                    node_bgppeer_show(4)
                    node_bgppeer_show(6)
                else:
                    node_bgppeer_show(ip_version)
    elif arguments.get("stop"):
        node_stop(arguments.get("--force"))
    elif arguments.get("remove"):
        node_remove(arguments.get("--remove-endpoints"),
                    arguments.get("--hostname"))
    elif arguments.get("show"):
        node_show()
    else:
        assert arguments.get("--detach") in ["true", "false"]
        detach = arguments.get("--detach") == "true"

        # Set libnetwork_enabled to False if --libnetwork flag is not passed 
        libnetwork_enabled = False if not arguments.get("--libnetwork") else True

        node_start(ip=arguments.get("--ip"),
                   node_image=arguments.get('--node-image'),
                   runtime=arguments.get("--runtime"),
                   log_dir=arguments.get("--log-dir"),
                   ip6=arguments.get("--ip6"),
                   as_num=as_num,
                   detach=detach,
                   libnetwork_enabled=libnetwork_enabled,
                   no_pull=arguments.get("--no-pull"),
                   backend=backend)
コード例 #2
0
ファイル: node.py プロジェクト: ajaybhatnagar/calico-docker
def node(arguments):
    """
    Main dispatcher for node commands. Calls the corresponding helper function.

    :param arguments: A dictionary of arguments already processed through
    this file's docstring with docopt
    :return: None
    """
    validate_arguments(arguments)

    as_num = convert_asn_to_asplain(arguments.get("<AS_NUM>") or arguments.get("--as"))

    if arguments.get("bgp"):
        if arguments.get("peer"):
            ip_version = get_container_ipv_from_arguments(arguments)
            if arguments.get("add"):
                node_bgppeer_add(arguments.get("<PEER_IP>"), ip_version,
                                 as_num)
            elif arguments.get("remove"):
                node_bgppeer_remove(arguments.get("<PEER_IP>"), ip_version)
            elif arguments.get("show"):
                if not ip_version:
                    node_bgppeer_show(4)
                    node_bgppeer_show(6)
                else:
                    node_bgppeer_show(ip_version)
    elif arguments.get("stop"):
        node_stop(arguments.get("--force"))
    elif arguments.get("remove"):
        node_remove(arguments.get("--remove-libnetwork"))
    else:
        assert arguments.get("--detach") in ["true", "false"]
        detach = arguments.get("--detach") == "true"

        kubernetes_version = None if not arguments.get("--kubernetes") \
                                else arguments.get("--kube-plugin-version")
        libnetwork_image = None if not arguments.get("--libnetwork") \
                                else arguments.get("--libnetwork-image")
        node_start(ip=arguments.get("--ip"),
                   node_image=arguments.get('--node-image'),
                   runtime=arguments.get("--runtime"),
                   log_dir=arguments.get("--log-dir"),
                   ip6=arguments.get("--ip6"),
                   as_num=as_num,
                   detach=detach,
                   kubernetes_version=kubernetes_version,
                   rkt=arguments.get("--rkt"),
                   libnetwork_image=libnetwork_image)
コード例 #3
0
ファイル: node.py プロジェクト: izogain/calico-containers
def node(arguments):
    """
    Main dispatcher for node commands. Calls the corresponding helper function.

    :param arguments: A dictionary of arguments already processed through
    this file's docstring with docopt
    :return: None
    """
    validate_arguments(arguments)

    as_num = convert_asn_to_asplain(
        arguments.get("<AS_NUM>") or arguments.get("--as"))

    if arguments.get("bgp"):
        if arguments.get("peer"):
            ip_version = get_container_ipv_from_arguments(arguments)
            if arguments.get("add"):
                node_bgppeer_add(arguments.get("<PEER_IP>"), ip_version,
                                 as_num)
            elif arguments.get("remove"):
                node_bgppeer_remove(arguments.get("<PEER_IP>"), ip_version)
            elif arguments.get("show"):
                if not ip_version:
                    node_bgppeer_show(4)
                    node_bgppeer_show(6)
                else:
                    node_bgppeer_show(ip_version)
    elif arguments.get("stop"):
        node_stop(arguments.get("--force"))
    elif arguments.get("remove"):
        node_remove(arguments.get("--remove-endpoints"))
    else:
        assert arguments.get("--detach") in ["true", "false"]
        detach = arguments.get("--detach") == "true"

        libnetwork_image = None if not arguments.get("--libnetwork") \
                                else arguments.get("--libnetwork-image")
        node_start(ip=arguments.get("--ip"),
                   node_image=arguments.get('--node-image'),
                   runtime=arguments.get("--runtime"),
                   log_dir=arguments.get("--log-dir"),
                   ip6=arguments.get("--ip6"),
                   as_num=as_num,
                   detach=detach,
                   libnetwork_image=libnetwork_image)
コード例 #4
0
ファイル: bgp.py プロジェクト: DockerLab/calico-containers
def bgp(arguments):
    """
    Main dispatcher for bgp commands. Calls the corresponding helper function.

    :param arguments: A dictionary of arguments already processed through
    this file's docstring with docopt
    :return: None
    """
    validate_arguments(arguments)

    ip_version = get_container_ipv_from_arguments(arguments)
    as_num = convert_asn_to_asplain(arguments.get("<AS_NUM>"))

    if arguments.get("peer"):
        if arguments.get("add"):
            bgp_peer_add(arguments.get("<PEER_IP>"), ip_version,
                         as_num)
        elif arguments.get("remove"):
            bgp_peer_remove(arguments.get("<PEER_IP>"), ip_version)
        elif arguments.get("show"):
            if not ip_version:
                bgp_peer_show(4)
                bgp_peer_show(6)
            else:
                bgp_peer_show(ip_version)

    elif arguments.get("node-mesh"):
        if arguments.get("on") or arguments.get("off"):
            set_bgp_node_mesh(arguments.get("on"))
        else:
            show_bgp_node_mesh()
    elif arguments.get("default-node-as"):
        if arguments.get("<AS_NUM>"):
            set_default_node_as(as_num)
        else:
            show_default_node_as()
コード例 #5
0
def bgp(arguments):
    """
    Main dispatcher for bgp commands. Calls the corresponding helper function.

    :param arguments: A dictionary of arguments already processed through
    this file's docstring with docopt
    :return: None
    """
    validate_arguments(arguments)

    ip_version = get_container_ipv_from_arguments(arguments)
    as_num = convert_asn_to_asplain(arguments.get("<AS_NUM>"))

    if arguments.get("peer"):
        if arguments.get("add"):
            bgp_peer_add(arguments.get("<PEER_IP>"), ip_version,
                         as_num)
        elif arguments.get("remove"):
            bgp_peer_remove(arguments.get("<PEER_IP>"), ip_version)
        elif arguments.get("show"):
            if not ip_version:
                bgp_peer_show(4)
                bgp_peer_show(6)
            else:
                bgp_peer_show(ip_version)

    elif arguments.get("node-mesh"):
        if arguments.get("on") or arguments.get("off"):
            set_bgp_node_mesh(arguments.get("on"))
        else:
            show_bgp_node_mesh()
    elif arguments.get("default-node-as"):
        if arguments.get("<AS_NUM>"):
            set_default_node_as(as_num)
        else:
            show_default_node_as()