Exemplo n.º 1
0
    transit_name = leaf_data["l1_transit_name"]
    if not raas_utils.client_exists_l1_transit(transit_name):
      print(transit_name+" transit does not exist")
      exit(1)
    transit_id=hyp_utils.get_hyp_l1_transit_name(hypervisor,transit_name)

    try:
      network=raas_utils.get_new_veth_subnet('spine_l1t')
      subnet = network.split('/')
      
      b_ip = "b_ip="+str(ipaddress.ip_address(subnet[0])+1) + '/' + subnet[1]
      dhcp_range = "dhcp_range="+str(ipaddress.ip_address(subnet[0])+2)+','+ \
                        str(ipaddress.ip_address(subnet[0])+6)
      
      net_name=" s_t_net"+vpc_id + "_net_" + spine_id.split('_')[2]+"_" + transit_id.split('_')[1]
      net_arg=" t_s_net=" +net_name 
      br_arg=" s_t_br=" + vpc_id + "_br_" + spine_id.split('_')[2]+"_" + transit_id.split('_')[1]
      veth_1=" ve_l_s=" + vpc_id + "_ve_" + spine_id.split('_')[2]+"_" + transit_id.split('_')[1]
      veth_2=" ve_s_l=" + vpc_id + "_ve_" + transit_id.split('_')[1]+"_" + spine_id.split('_')[2]
      upper_vm_arg=" t_name="+transit_id
      lower_vm_arg=" s_name="+spine_id
      
      extra_vars = constants.ansible_become_pass + net_arg + br_arg + veth_1 + veth_2 + upper_vm_arg + lower_vm_arg + subnet_ip_arg + subnet_range_arg + " " + hypervisor_arg
                
      raas_utils.run_shell_script("ansible-playbook logic/vpc/connect_spine_transit.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('spine_l1t',new_subnet)

    except Exception as e:
        raas_utils.run_shell_script("ansible-playbook logic/subnet/delete_leaf.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
Exemplo n.º 2
0
            t_hyp_id = l1_transit_name_ansible.split('_')[1]

            ve_t_h_arg = "ve_t_h=" + c_hyp_id + '_ve_' + t_hyp_id + '_h'
            ve_h_t_arg = "ve_h_t=" + c_hyp_id + '_ve_h_' + t_hyp_id 

            extra_vars = constants.ansible_become_pass + " "\
                     + t_name_arg + " " + t_loopback_ip_arg + \
                    " "  +  hypervisor_arg + \
                    " " + t_h_ip_arg + " " + h_t_ip_arg + " " + \
                    " " + ve_t_h_arg + " " + ve_h_t_arg

            rc = raas_utils.run_playbook("ansible-playbook logic/transit/configure_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)

            subnet = t_loopback_ip.split('/')
            new_subnet = str(ipaddress.ip_address(subnet[0])+1) + '/' + subnet[1]
            raas_utils.update_veth_subnet('loopbacks',new_subnet)
            raas_utils.log_client("l1 transit created successfully")
            raas_utils.log_service("l1_transit created successfully")
        except Exception as e:
            raas_utils.log_client("create transit failed.......aborting")
            raas_utils.log_service("create transit failed "+ str(e))
            raise
    except Exception as e:
        raas_utils.log_client("create l1_transit failed python failed......aborting")
        raas_utils.log_service("create l1_transit failed python failed "+ str(e))
Exemplo n.º 3
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)

Exemplo n.º 4
0
                    hypervisor_arg + " " + t_loopback_ip_arg

            if (dhcp_flag):
                extra_vars += l_ip_arg + " " + dhcp_range_arg 

            #create bridge (with or without dhcp decided by extra_vars)
            try:
                raas_utils.run_playbook("ansible-playbook logic/subnet/create_bridge.yml -i logic/inventory/hosts.yml -v --extra-vars '"+extra_vars+"'")
            except Exception as e:
                raas_utils.log_client("create bridge failed.....aborting")
                raas_utils.log_service("create bridge failed "+ str(e))
                raise

            subnet = t_loopback_ip.split('/')
            new_subnet = str(ipaddress.ip_address(subnet[0])+1) + '/' + subnet[1]
            raas_utils.update_veth_subnet('loopbacks',new_subnet)

        except Exception as e:
            raas_utils.log_client("Leaf creation failed.......aborting")
            raas_utils.log_service("Creating leaf failed: "+str(e))
            raise
        
        
        #connect to available spines
        try:
          spines_data = raas_utils.get_all_spines(vpc_name)
          spine_ips=[]
          
          for spine in spines_data:
              spine_id=hyp_utils.get_hyp_spine_name(hypervisor,vpc_name,spine)
              if spine_id is None: