Пример #1
0
def restore_pod_checkpoint(pod, version, hypervisor):
    hypervisor_arg = " hypervisor=" + hypervisor
    pod_arg = " pod=" + pod
    version_arg = " version=" + version
    extra_vars = constants.ansible_become_pass + hypervisor_arg + pod_arg + version_arg

    rc = raas_utils.run_playbook(
        "ansible-playbook logic/checkpoint/restore_checkpoint.yml -i logic/inventory/hosts.yml -v --extra-vars '"
        + extra_vars + "'")
Пример #2
0
    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(
            "ansible-playbook logic/bgp/conf_spine_bgp.yml -i logic/inventory/hosts.yml -vvvv --extra-vars '"
            + extra_vars + "'")
        if (rc != 0):
            raas_utils.log_service("bgp advertisement failed")
            raise

        raas_utils.write_client_spine_data(spine_type, spine_name, vpc_name,
                                           "adv_subnets", advertise)

    except:
        raas_utils.log_service("conf spine bgp failed python failed")
Пример #3
0
        activate_arg = "activate=" + "true"
    else:
        activate_arg = "activate=" + "false"

    try:
        #create_pc
        try:
            extra_vars = constants.ansible_become_pass + " " + \
                    node_name_hyp_arg + " " + self_as_arg +\
                    " " + hypervisor_arg + " " + activate_arg

            raas_utils.log_service(
                "ansible-playbook logic/bgp/bgp_multipath.yml -i logic/inventory/hosts.yml -v --extra-vars '"
                + extra_vars + "'")
            rc = raas_utils.run_playbook(
                "ansible-playbook logic/bgp/bgp_multipath.yml -i logic/inventory/hosts.yml -v --extra-vars '"
                + extra_vars + "'")
            if (rc != 0):
                raas_utils.log_service("bgp config failed playbook")
                raise

            raas_utils.write_client_node_data(node_type, node_name, vpc_name,
                                              "ecmp", True)
            raas_utils.write_client_node_data(node_type, node_name, vpc_name,
                                              "self_as", self_as)
        except:
            raas_utils.log_service("bgp config failed")
            raise
    except:
        raas_utils.log_service("create pc failed python failed")
Пример #4
0
            vpc_hyp_id = hyp_pc_name.split('_')[1]
            pc_hyp_id = hyp_pc_name.split('_')[2]

            leaf_hyp_id = hyp_leaf_name.split('_')[2]

            ve_l_pc_arg = "ve_l_pc=" + c_hyp_id + '_' + vpc_hyp_id + '_ve_' + leaf_hyp_id + ' ' + pc_hyp_id
            ve_pc_l_arg = "ve_pc_l=" + c_hyp_id + '_' + vpc_hyp_id + '_ve_' + pc_hyp_id + ' ' + leaf_hyp_id

            extra_vars = constants.ansible_become_pass + " " + \
                    pc_name_ansible_arg + " " + hypervisor_arg + \
                    " " + hyp_leaf_name_arg + " " + l_br_name_arg + " " + \
                    ve_l_pc_arg + " " + ve_pc_l_arg

            #raas_utils.log_service("here2")
            raas_utils.run_playbook(
                "ansible-playbook logic/subnet/add_to_subnet.yml -i logic/inventory/hosts.yml -v --extra-vars '"
                + extra_vars + "'")

            raas_utils.client_add_leaf_pc(vpc_name, pc_name, leaf_name)

            #raise
            #raas_utils.add_mgmt_ns(hypervisor)
        except:
            raas_utils.log_service("connect pc failed")
            raise
            #raas_utils.log_service("ansible-playbook logic/vpc/delete_pc.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
    else:
        raas_utils.log_service(
            "pc and leaf exist in different hypervisor, vxlan connect")
        exit(1)
Пример #5
0
    try:
        #create_spine
        try:
            sid = hyp_utils.get_spine_id(hypervisor, vpc_name)
            spine_name_ansible = vpcid + "_" + "s" + str(sid)
            spine_name_ansible_arg = "c_name="+spine_name_ansible

            s_ram_arg = "c_ram=" + str(mem)
            s_vcpu_arg = "c_vcpu=" + str(vcpu)

            extra_vars = constants.ansible_become_pass + " " + \
                    s_ram_arg + " " + s_vcpu_arg + " " + \
                    " " +  hypervisor_arg + " " + spine_name_ansible_arg

            rc = raas_utils.run_playbook("ansible-playbook logic/misc/create_router_container.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
            if (rc != 0):
                raise
                
            hyp_utils.write_spine_id(sid+1, vpc_name, hypervisor)
            hyp_utils.vpc_add_spine(hypervisor, vpc_name, spine_name, spine_name_ansible)
            raas_utils.client_add_spine(hypervisor, vpc_name, spine_name, spine_capacity, self_as)
            raas_utils.log_client("Spine creation completed successfully")
            raas_utils.log_service("Spine creation completed successfully")
        except:
            raas_utils.log_service("create spine failed")
            raas_utils.log_client("create spine failed")
            os.system("ansible-playbook logic/misc/delete_container.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
            raise
    except:
        raas_utils.log_client("create spine failed")
Пример #6
0
                                           grep_lo_net)

        leaf2_lo_ip = raas_utils.get_ns_ip(leaf2_hypervisor_name, leaf2_id,
                                           grep_lo_net)

        try:
            # Configure VXLAN on Leaf 1 Transit
            leaf1_id_arg = " l_name=" + leaf1_id
            l_local_ip_arg = " l_ip=" + leaf1_lo_ip
            l_remote_ip_arg = " remote_l_ip=" + leaf2_lo_ip
            br_name_arg = " l_br_name=" + leaf1_id + "_br"

            extra_vars = constants.ansible_become_pass + l1_hypervisor_arg + leaf1_id_arg + l_local_ip_arg + l_remote_ip_arg + vxlan_tunnel_name_arg + br_name_arg

            raas_utils.run_playbook(
                "ansible-playbook logic/subnet/add_vxlan_to_leaf.yml -i logic/inventory/hosts.yml -v --extra-vars '"
                + extra_vars + "'")
        except Exception as e:
            raas_utils.log_service("Configure VXLAN on leaf 1 subnet failed" +
                                   str(e))
            raise

        try:
            # Configure VXLAN on Leaf 1 Transit
            leaf2_id_arg = " l_name=" + leaf2_id
            l_local_ip_arg = " l_ip=" + leaf2_lo_ip
            l_remote_ip_arg = " remote_l_ip=" + leaf1_lo_ip
            br_name_arg = " l_br_name=" + leaf2_id + "_br"

            extra_vars = constants.ansible_become_pass + l2_hypervisor_arg + leaf2_id_arg + l_local_ip_arg + l_remote_ip_arg + vxlan_tunnel_name_arg + br_name_arg
Пример #7
0
            hypervisor_ip = hyp_utils.get_hyp_ip(l1_transit_hypervisor_name)

            network=raas_utils.get_new_veth_subnet('l1t_l2t')
            subnet = network.split('/')

            l1t_ip = str(ipaddress.ip_address(subnet[0])+1) + '/' + subnet[1]
            l2t_ip = str(ipaddress.ip_address(subnet[0])+2) + '/' + subnet[1]
            l1t_ip_arg = " ns1_ip=" + l1t_ip
            l2t_ip_arg = " ns2_ip=" + l2t_ip 

            veth_1=" ve_ns1_ns2=c" + cid + "ve" + l1_transit_id.split('_')[1] + l2_transit_id.split('_')[1]
            veth_2=" ve_ns2_ns1=c" + cid + "ve" + l2_transit_id.split('_')[1] + l1_transit_id.split('_')[1]
            l2_transit_id_arg=" ns2="+l2_transit_id
            l1_transit_id_arg=" ns1="+l1_transit_id

            extra_vars = constants.ansible_become_pass + l1t_ip_arg + l2t_ip_arg + \
                        veth_1 + veth_2 + l1_transit_id_arg + l2_transit_id_arg + " " + hypervisor_arg
            raas_utils.run_playbook("ansible-playbook logic/misc/connect_ns_ns.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")    


            new_subnet=str(ipaddress.ip_address(subnet[0])+8) + '/' + subnet[1]
            raas_utils.update_veth_subnet('l1t_l2t',new_subnet)

        except Exception as e:
            raas_utils.log_service("l1 transit to l2 transit local failed"+e)
            raise
    else:
        raas_utils.log_service("l1 and l2 transits exist in different hypervisor, GRE connect")
        exit(1)

Пример #8
0
              
            t_h_net = l1_transit_name_ansible + "_h_net"
            t_h_net_arg = "t_h_net=" + t_h_net

            t_h_br = l1_transit_name_ansible + "_h_br"
            t_h_br_arg = "t_h_br=" + t_h_br

            extra_vars = constants.ansible_become_pass + " " + \
                    image_arg + " " +  \
                    t_ram_arg + " " + t_vcpu_arg + " " + \
                    mgt_net_arg + " " + l1_transit_name_ansible_arg + \
                    " " + c_t_image_path_arg + " " +  hypervisor_arg + \
                    " " + t_h_net_arg + " " + t_h_br_arg + " " + b_ip_arg + \
                    " " + dhcp_range_arg

            rc = raas_utils.run_playbook("ansible-playbook logic/transit/create_transit.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
            if (rc != 0):
                raise
                
            new_subnet=str(ipaddress.ip_address(subnet[0])+4) + '/' + subnet[1]
            raas_utils.update_veth_subnet('l1t_h',new_subnet)

            hyp_utils.write_l1_transit_id(l1id+1, hypervisor)
            hyp_utils.hyp_add_l1_transit(hypervisor, l1_transit_name, l1_transit_name_ansible)
            raas_utils.client_add_l1_transit(hypervisor, l1_transit_name, l1_transit_capacity)

        except Exception as e:
            print("create l1_transit failed deleting transit", e)
            #raas_utils.run_playbook("ansible-playbook logic/vpc/delete_l1_transit.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
            raise
Пример #9
0
                dhcp_range_arg = "dhcp_range=" + str(ipaddress.ip_address(subnet[0])+2)+','+ \
                        str(ipaddress.ip_address(subnet[0])+254)
            print('here4')
            l_br_arg = "br_name=" + leaf_name_hyp + "_br"
            #l_net_arg = "l_net=" + leaf_name_hyp + "_net"
            #ve_l_br_arg = "ve_l_br=" + vpc_id + "_ve_" + "l" + str(lid) + "_br"
            #ve_br_l_arg = "ve_br_l=" + vpc_id + "_ve_" + "br_l" + str(lid)
            c_vcpu_arg = " c_vcpu="+"1,1"
            c_ram_arg = " c_ram="+"1G"

            #create container
            try:
                extra_vars = constants.ansible_become_pass + " " + \
                        leaf_name_hyp_arg + " " + hypervisor_arg + " " + c_vcpu_arg + c_ram_arg
                
                raas_utils.run_playbook("ansible-playbook logic/misc/create_container.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
            except Exception as e:
                raas_utils.log_client("Container creation failed......aborting")
                raas_utils.log_service("create container failed "+ str(e))
                raise

            l_name_arg = "l_name=" + leaf_name_hyp

            t_loopback_ip = raas_utils.get_new_veth_subnet('loopbacks')
            t_loopback_ip_arg = "t_loopback_ip="+str(t_loopback_ip)

            extra_vars = constants.ansible_become_pass + " " + \
                    l_name_arg + " " + " " + l_br_arg + " " + \
                    hypervisor_arg + " " + t_loopback_ip_arg

            if (dhcp_flag):