def pool(arguments): """ Main dispatcher for pool 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) if arguments.get("add"): if arguments.get("range"): ip_pool_range_add(arguments.get("<START_IP>"), arguments.get("<END_IP>"), ip_version, arguments.get("--ipip"), arguments.get("--nat-outgoing")) else: ip_pool_add(arguments.get("<CIDRS>"), ip_version, arguments.get("--ipip"), arguments.get("--nat-outgoing")) elif arguments.get("remove"): ip_pool_remove(arguments.get("<CIDRS>"), ip_version) elif arguments.get("show"): if not ip_version: ip_pool_show(4) ip_pool_show(6) else: ip_pool_show(ip_version)
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) if arguments.get("peer"): if arguments.get("add"): bgp_peer_add(arguments.get("<PEER_IP>"), ip_version, arguments.get("<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(arguments.get("<AS_NUM>")) else: show_default_node_as()
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()
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)
def container(arguments): """ Main dispatcher for container 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) try: if arguments.get("endpoint-id"): container_endpoint_id_show(arguments.get("<CONTAINER>")) elif arguments.get("ip"): if arguments.get("add"): container_ip_add(arguments.get("<CONTAINER>"), arguments.get("<IP>"), ip_version, arguments.get("--interface")) elif arguments.get("remove"): container_ip_remove(arguments.get("<CONTAINER>"), arguments.get("<IP>"), ip_version, arguments.get("--interface")) else: if arguments.get("add"): container_add(arguments.get("<CONTAINER>"), arguments.get("<IP>"), arguments.get("--interface")) if arguments.get("remove"): container_remove(arguments.get("<CONTAINER>")) else: if arguments.get("add"): container_add(arguments.get("<CONTAINER>"), arguments.get("<IP>"), arguments.get("--interface")) if arguments.get("remove"): container_remove(arguments.get("<CONTAINER>")) except ConnectionError as e: # We hit a "Permission denied error (13) if the docker daemon # does not have sudo permissions if permission_denied_error(e): print_paragraph("Unable to run command. Re-run the " "command as root, or configure the docker " "group to run with sudo privileges (see docker " "installation guide for details).") else: print_paragraph("Unable to run docker commands. Is the docker " "daemon running?") sys.exit(1)
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)
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" 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)
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)
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) 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, arguments.get("<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")) else: assert arguments.get("--detach") in ["true", "false"] detach = arguments.get("--detach") == "true" node_start(ip=arguments.get("--ip"), node_image=arguments['--node-image'], log_dir=arguments.get("--log-dir"), ip6=arguments.get("--ip6"), as_num=arguments.get("--as"), detach=detach, kubernetes=arguments.get("--kubernetes"))