Exemplo n.º 1
0
import raas_utils
import hyp_utils
import constants
import ipaddress
"""@params:
    param1 = connection config name (required)
"""

if __name__ == "__main__":
    if (len(sys.argv) < 2):
        raas_utils.log_service("Please give connection config file")
        exit(1)

    connection_config_file = sys.argv[1]
    connection_name = connection_config_file.split('/')[-1].split('.')[0]
    cid = hyp_utils.get_client_id()

    connection_data = do_json.json_read(connection_config_file)
    raas_utils.log_service(connection_data)
    vpc_name = connection_data["vpc_name"]
    pc_name = connection_data["pc_name"]
    leaf_name = connection_data["leaf_name"]

    if not raas_utils.client_exists_pc(vpc_name, pc_name):
        raas_utils.log_service("pc does not exists " + pc_name)
        exit(1)

    if not raas_utils.client_exists_leaf(vpc_name, leaf_name):
        raas_utils.log_service("leaf does not exist " + leaf_name)
        exit(1)
Exemplo n.º 2
0
    advertise = advertise_data["networks_advertised"]
    advertise_arg = "adv_subnets=" + advertise

    client_spine_data = raas_utils.get_client_node_data(
        "spine", spine_name, vpc_name)

    self_as = str(client_spine_data["self_as"])
    self_as_arg = "self_as=" + self_as

    client_l1_transit_data = raas_utils.get_client_node_data(
        "l1_transit", l1_transit_name, vpc_name)

    ras = str(client_l1_transit_data["self_as"])
    ras_arg = "ras=" + ras

    ve_spine_l1t = "c" + hyp_utils.get_client_id() + "_" + spine_name_hyp.split('_')[-2] + \
            "ve" + \
            l1_transit_name_hyp.split('_')[-1] + \
            spine_name_hyp.split('_')[-1]

    print(ve_spine_l1t)
    l1_transit_ip_arg = "rip=" + raas_utils.get_ns_ip(
        hypervisor, l1_transit_name_hyp, ve_spine_l1t)

    try:
        extra_vars = constants.ansible_become_pass + " " + \
                spine_name_hyp_arg + " " + self_as_arg +\
                " " + hypervisor_arg + " " + advertise_arg + \
                " " + l1_transit_ip_arg + " " + ras_arg

        rc = raas_utils.run_playbook(
Exemplo n.º 3
0
        path_choice_name_hyp = hyp_utils.get_hyp_l2_transit_name(
            hypervisor, path_choice_name)
    else:
        exit(1)

    weight = weight_data["weight"]
    weight_arg = "bgp_weight=" + weight

    client_node_data = raas_utils.get_client_node_data(path_choice_type,
                                                       path_choice_name,
                                                       vpc_name)
    raas_utils.log_service(client_node_data)
    self_as = str(client_node_data["self_as"])
    self_as_arg = "self_as=" + self_as

    ve_ns1_ns2 = "c" + hyp_utils.get_client_id() + \
            "ve" + \
            path_choice_name_hyp.split('_')[-1] + \
            node_name_hyp.split('_')[-1]

    path_choice_ip_arg = "neighbor_ip=" + raas_utils.get_ns_ip(
        hypervisor, path_choice_name_hyp, ve_ns1_ns2)

    try:
        extra_vars = constants.ansible_become_pass + " " + \
                node_name_hyp_arg + " " + self_as_arg +\
                " " + hypervisor_arg + " " + weight_arg + \
                " " + path_choice_ip_arg

        raas_utils.log_service(
            "ansible-playbook logic/bgp/bgp_set_weight.yml -i logic/inventory/hosts.yml -v --extra-vars '"