예제 #1
0
def mpls_remove_fns(desc):

    fns_id= libnetvirt.getUuidFromFNS(desc) 
    print "remove id " + str(fns_id) + "num of endpoints: " + str(libnetvirt.getNepFromFNS(desc))
    
    #libnetvirt.printFNS(desc)
    
    D = Database ('libnetvirt.sqlite')
    for i in range(0,libnetvirt.getNepFromFNS(desc)):

        ep = libnetvirt.getEndpoint(desc,i)
        r_id = libnetvirt.getSwIdFromEp(ep)
        
        # Get router name
        #r_name = str(libnetvirt.getSwIdFromEp(ep))
        r_name = D.getRouterName(r_id)
        # Get the router user name
        r_uname = D.getRouterUserName(r_id)             
        vlan =  libnetvirt.getVlanFromEp(ep)
        pe_if = libnetvirt.getPortFromEp
        vrf = 'vrf' +  str(fns_id)
        
        #Calling the scripts for configuration. Uncomment when the network is available
        NM = NetworkManager(r_name, r_uname)
        if NM != None:
            NM.stop_configuration(vlan, vrf,pe_if)
            NM.close_ssh()
        else:
            print "Error in applying configuration"
        


    return 0
예제 #2
0
def mpls_create_fns(desc):
    print "create fns"
    #libnetvirt.printFNS(desc)
    fns_id= libnetvirt.getUuidFromFNS(desc)
    D = Database ('libnetvirt.sqlite')
    for i in range(0,libnetvirt.getNepFromFNS(desc)):

        ep = libnetvirt.getEndpoint(desc,i)
        r_id = libnetvirt.getSwIdFromEp(ep)

        # Get router name
        #r_name = str(libnetvirt.getSwIdFromEp(ep))
        r_name = D.getRouterName(r_id)

        # Get the router user name
        r_uname = D.getRouterUserName(r_id)

        # Get the router interface
        r_interface = D.getRouterInterface(r_id)+str(libnetvirt.getPortFromEp(ep))

        #r_uname = "root"
        #r_interface = "eth3"
        r_d_net = '192.66.23.0'
        
        pe_address = libnetvirt.getAddressFromEp(ep)
        #ce_address = libnetvirt.getAddressCEFromEp(ep)
        
        #we need net address for CE
        tmp = commands.getoutput('ipcalc -n ' + str(pe_address))
        tmp = tmp.split()
        ce_net = tmp[16]
        
        vlan =  libnetvirt.getVlanFromEp(ep)
        vrf = 'vrf' +  str(fns_id)
        
        #get address from global configuration database
        r_d =  r_d_net + ':' + str(fns_id)
        
        #call script for PE configuration
        #Calling the scripts for configuration. Uncomment when the network is available
        NM = NetworkManager(r_name, r_uname)
        if NM != None:
            NM.start_configuration(r_interface, pe_address, ce_net, r_d, vlan, vrf)
            NM.close_ssh()
        else:
            print "Error in applying configuration"


    return 0
예제 #3
0
def dummy_create_fns(desc):
    print "create fns"
    libnetvirt.printFNS(desc)
    print "FNS uuid ", libnetvirt.getUuidFromFNS(desc)
    for i in range(0,libnetvirt.getNepFromFNS(desc)):

        ep = libnetvirt.getEndpoint(desc,i)
        print "ep uuid", libnetvirt.getUuidFromEp(ep)
        print "\t swid ", libnetvirt.getSwIdFromEp(ep)
        print "\t port", libnetvirt.getPortFromEp(ep)
        print "\t vlan", libnetvirt.getVlanFromEp(ep)
        print "\t PE: ", socket.inet_ntoa(struct.pack('I', libnetvirt.getAddressPEFromEp(ep)))
        print "\t CE:", socket.inet_ntoa(struct.pack('I', libnetvirt.getAddressCEFromEp(ep)))

    print "create"
    return 0
예제 #4
0
def dummy_create_fns(desc):
    print "create fns"
    libnetvirt.printFNS(desc)
    print "FNS uuid ", libnetvirt.getUuidFromFNS(desc)
    for i in range(0, libnetvirt.getNepFromFNS(desc)):

        ep = libnetvirt.getEndpoint(desc, i)
        print "ep uuid", libnetvirt.getUuidFromEp(ep)
        print "\t swid ", libnetvirt.getSwIdFromEp(ep)
        print "\t port", libnetvirt.getPortFromEp(ep)
        print "\t vlan", libnetvirt.getVlanFromEp(ep)
        print "\t PE: ", socket.inet_ntoa(
            struct.pack('I', libnetvirt.getAddressPEFromEp(ep)))
        print "\t CE:", socket.inet_ntoa(
            struct.pack('I', libnetvirt.getAddressCEFromEp(ep)))

    print "create"
    return 0