def init_libnetvirt(self, type, entity):
     '''
     
     Initialize libnetvirt driver according to type
     
     '''
     if type == libnetvirt.LIBNETVIRT_FORWARDING_L2:
         info = libnetvirt.libnetvirt_init(libnetvirt.DRIVER_OF_NOX)
         con = libnetvirt.libnetvirt_connect(info, 
                                   entity.ocni_libnetvirt_of_controller, 
                                   int(entity.ocni_libnetvirt_of_controller_port))
     
         if con < 0:
             logger.error('Error while connecting to libnetvirt driver at : ' + entity.ocni_libnetvirt_of_controller)
             return -1
         
     elif type == libnetvirt.LIBNETVIRT_FORWARDING_L3VPN:
         info = libnetvirt.libnetvirt_init(libnetvirt.DRIVER_MPLS)
    
     else:
         logger.error('Unknown type')
         return -1
     
     return info
Exemple #2
0
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <http://www.gnu.org/licenses/>.


import libnetvirt
info = libnetvirt.libnetvirt_init(libnetvirt.DRIVER_OF_NOX)
for num in range(1,10000):
	libnetvirt.libnetvirt_connect(info, "127.0.0.1",2000) 
fns_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
	<description xmlns=\"http://www.sail-project.eu/fns\">\
	<fns name=\"two-fns\" uuid=\"1\">\
		<endpoint uuid=\"3\"> <swId>3</swId> <port>2</port> </endpoint>\
		<endpoint uuid=\"2\"> <swId>2</swId><port>2</port> </endpoint>\
		<endpoint uuid=\"4\"> <swId>4</swId><port>1</port> </endpoint>\
	</fns>\
	</description>"
fns = libnetvirt.parse_fns_Mem(fns_xml,len(fns_xml))
#fns = libnetvirt.parse_fns("fns.xml")
libnetvirt.libnetvirt_create_fns(info,fns)

fns1 = libnetvirt.create_local_fns(20,2,"fns_api")
ep1 = libnetvirt.add_local_epoint(fns1,0,10,3,2,10,0)
ep2 = libnetvirt.add_local_epoint(fns1,1,20,2,2,20,0)
Exemple #3
0
info = libnetvirt.libnetvirt_init(libnetvirt.DRIVER_OF_NOX)
errors = 0
address="127.0.0.1"
if (len(sys.argv) == 2):
	n = int(sys.argv[1])
elif (len(sys.argv) == 3):
	n = int(sys.argv[1])
	address = sys.argv[2]
else:
	print "use %s [n] [ip]" % ( sys.argv[0],)
	exit(0)
	
start = datetime.now()
for num in range(1,n):
	libnetvirt.libnetvirt_connect(info, address,2000) 
	fns_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
	<description xmlns=\"http://www.sail-project.eu/fns\">\
	<fns name=\"testing\" uuid=\"%d\">\
		<endpoint uuid=\"%d \"> <swId>%d</swId> <port>1</port> </endpoint>\
		<endpoint uuid=\"%d \"> <swId>%d</swId><port>2</port> </endpoint>\
		<forward>L2</forward>\
	</fns>\
	</description>" % (num, num, num, num, num,)
	
	fns = libnetvirt.parse_fns_Mem(fns_xml,len(fns_xml))
	#fns = libnetvirt.parse_fns("fns.xml")
	if (libnetvirt.libnetvirt_create_fns(info,fns) < 0):
		errors = errors +1
	libnetvirt.libnetvirt_disconnect(info)
Exemple #4
0
info = libnetvirt.libnetvirt_init(libnetvirt.DRIVER_OF_NOX)
errors = 0
address = "127.0.0.1"
if (len(sys.argv) == 2):
    n = int(sys.argv[1])
elif (len(sys.argv) == 3):
    n = int(sys.argv[1])
    address = sys.argv[2]
else:
    print "use %s [n] [ip]" % (sys.argv[0], )
    exit(0)

start = datetime.now()
for num in range(1, n):
    libnetvirt.libnetvirt_connect(info, address, 2000)
    fns_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
	<description xmlns=\"http://www.sail-project.eu/fns\">\
	<fns name=\"testing\" uuid=\"%d\">\
		<endpoint uuid=\"%d \"> <swId>%d</swId> <port>1</port> </endpoint>\
		<endpoint uuid=\"%d \"> <swId>%d</swId><port>2</port> </endpoint>\
		<forward>L2</forward>\
	</fns>\
	</description>" % (
        num,
        num,
        num,
        num,
        num,
    )