def test_1(): ''' Construct and compile a policy for a forwarding switch. ''' # Build a netcore policy switch = 1 pol = PolicyUnion( PrimitivePolicy(Header({'loc': (switch, 2)}), [Action(1, [1], {'VLAN' : 1})]), PrimitivePolicy(Header(['loc': (switch, 1)}), [Action(1, [1], {'VLAN' : 0})])) networkConfig = netcore_compiler.compile(FakeNX([switch]), pol) send_signal("In main:\n%s\n" % networkConfig)
def test_3(Topology, flavor): ''' Verification over the routing example. ''' topo = topologies[flavor](1, Topology) netcorePolicy = netcore_shortest_path(topo) networkPolicy = netcore_compiler.compile(topo, netcorePolicy) # Verification: no loops model = verification.KripkeModel(topo, networkPolicy) result, msg = model.verify(verification.ISOLATE_HOSTS(topo.hosts())) if result: send_signal('SUCCESS - hosts isolated!\n') else: send_signal('FAILURE - hosts not isolated.\n%s\n' % msg)
def test_4(): logger.debug('Getting slices.') topo, slices = amaz.get_slices() logger.debug('Compiling slices.') netcorePolicy = compile.transform([(s, slice_sp(s)) for s in slices]) #logger.debug('NetCore policy:\n%s\n' % netcorePolicy) logger.debug('Compiling NetCore policy.') networkPolicy = netcore_compiler.compile(topo, netcorePolicy) #logger.debug('Network Policy:\n%s\n' % networkPolicy) logger.debug('Building model.') model = verification.KripkeModel(topo, networkPolicy) logger.debug('Verifying ISOLATE_HOSTS:') result, msg = model.verify(verification.ISOLATE_HOSTS(topo.hosts())) if result: logger.debug('... SUCCESS - hosts isolated!') else: logger.debug('... FAILURE - hosts not isolated.') logger.debug('%s' % msg) logger.debug('Done!') send_signal('Done!') return