Beispiel #1
0
    def delete(self, entity):
        '''

        Delete an Entity

        '''
        logger.debug('The delete operation of the libnetvirt_backend')
        # Check if the mixin is libnetvirt
        if entity == None:
            logger.error('Error. Entity is none')
            return
        if str(entity.mixins[0]['term']) != 'libnetvirt':
            logger.error('Entity is not libnetvirt mixin')
            return
        
        # Initialize and connect libnetvirt
        type = self.getType(entity.ocni_libnetvirt_service_type)
        info = self.init_libnetvirt(type, entity)
        if info < 0:
            return

        fns = libnetvirt.create_local_fns(int(entity.ocni_libnetvirt_uuid),
                                          len(entity.ocni_libnetvirt_endpoint),
                                          entity.occi_core_id,type)
        index = 0
        if type == libnetvirt.LIBNETVIRT_FORWARDING_L3VPN:
            for ep in entity.ocni_libnetvirt_endpoint:
                ep = self.ep_check(ep)
                libnetvirt.add_local_epoint_l3(fns, index,
                                                long(ep.ocni_libnetvirt_endpoint_uuid),
                                                int(ep.ocni_libnetvirt_endpoint_swid),
                                                int(ep.ocni_libnetvirt_endpoint_port),
                                                int(ep.ocni_libnetvirt_endpoint_vlan),
                                                ep.ocni_libnetvirt_endpoint_address+'/'+ep.ocni_libnetvirt_endpoint_mask)
                index = index + 1
             # Send command
        libnetvirt.libnetvirt_remove_fns(info,fns);
        logger.debug('Removing fns sent')
        # Stop communication        
        libnetvirt.libnetvirt_stop(info)
Beispiel #2
0
# 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)
#print ep1

libnetvirt.printFNS(fns1)
libnetvirt.libnetvirt_create_fns(info,fns1)
libnetvirt.libnetvirt_remove_fns(info,fns1)

libnetvirt.libnetvirt_disconnect(info)