@Test public void testModifyNetwork() { testCreateNetwork(); vns.createNetwork(guid2, net2, IPv4.toIPv4Address(gw1)); assertTrue(vns.nameToGuid.get(net2).equals(guid2)); assertTrue(vns.guidToGateway.get(guid2).equals(IPv4.toIPv4Address(gw1))); assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid1)); assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid2)); assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid3)); assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).size() == 3); vns.createNetwork(guid2, "newnet2", null); assertTrue(vns.gatewayToGuid.get(IPv4.toIPv4Address(gw1)).contains(guid2)); assertTrue(vns.vNetsByGuid.get(guid2).gateway.equals(gw1)); assertTrue(vns.nameToGuid.get("newnet2").equals(guid2)); assertTrue(vns.vNetsByGuid.get(guid2).name.equals("newnet2")); assertFalse(vns.nameToGuid.containsKey(net2)); }
@Override public void createNetwork(String guid, String network, Integer gateway) { if (log.isDebugEnabled()) { String gw = null; try { gw = IPv4.fromIPv4Address(gateway); } catch (Exception e) { } log.debug("Creating network {} with ID {} and gateway {}", new Object[] {network, guid, gw}); } if (!nameToGuid.isEmpty()) { for (Entry<String, String> entry : nameToGuid.entrySet()) { if (entry.getValue().equals(guid)) { nameToGuid.remove(entry.getKey()); break; } } } if(network != null) nameToGuid.put(network, guid); if (vNetsByGuid.containsKey(guid)) vNetsByGuid.get(guid).setName(network); else vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); if ((gateway != null) && (gateway != 0)) { addGateway(guid, gateway); if(vNetsByGuid.get(guid)!=null) vNetsByGuid.get(guid).setGateway(IPv4.fromIPv4Address(gateway)); } }
VirtualNetworkFilter implements IFloodlightModule, IVirtualNetworkService, IOFMessageListener { @Override public void createNetwork(String guid, String network, Integer gateway) { if (log.isDebugEnabled()) { String gw = null; try { gw = IPv4.fromIPv4Address(gateway); } catch (Exception e) { } log.debug("Creating network {} with ID {} and gateway {}", new Object[] {network, guid, gw}); } if (!nameToGuid.isEmpty()) { for (Entry<String, String> entry : nameToGuid.entrySet()) { if (entry.getValue().equals(guid)) { nameToGuid.remove(entry.getKey()); break; } } } if(network != null) nameToGuid.put(network, guid); if (vNetsByGuid.containsKey(guid)) vNetsByGuid.get(guid).setName(network); else vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); if ((gateway != null) && (gateway != 0)) { addGateway(guid, gateway); if(vNetsByGuid.get(guid)!=null) vNetsByGuid.get(guid).setGateway(IPv4.fromIPv4Address(gateway)); } } }
VirtualNetworkFilter implements IFloodlightModule, IVirtualNetworkService, IOFMessageListener { @Override public void createNetwork(String guid, String network, Integer gateway) { if (log.isDebugEnabled()) { String gw = null; try { gw = IPv4.fromIPv4Address(gateway); } catch (Exception e) { } log.debug("Creating network {} with ID {} and gateway {}", new Object[] {network, guid, gw}); } if (!nameToGuid.isEmpty()) { for (Entry<String, String> entry : nameToGuid.entrySet()) { if (entry.getValue().equals(guid)) { nameToGuid.remove(entry.getKey()); break; } } } if(network != null) nameToGuid.put(network, guid); if (vNetsByGuid.containsKey(guid)) vNetsByGuid.get(guid).setName(network); else vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); if ((gateway != null) && (gateway != 0)) { addGateway(guid, gateway); if(vNetsByGuid.get(guid)!=null) vNetsByGuid.get(guid).setGateway(IPv4.fromIPv4Address(gateway)); } }  }
VirtualNetworkFilter implements IFloodlightModule, IVirtualNetworkService, IOFMessageListener { @Override public void createNetwork(String guid, String network, Integer gateway) { if (log.isDebugEnabled()) { String gw = null; try { gw = IPv4.fromIPv4Address(gateway); } catch (Exception e) { } log.debug("Creating network {} with ID {} and gateway {}", new Object[] {network, guid, gw}); } if (!nameToGuid.isEmpty()) { for (Entry<String, String> entry : nameToGuid.entrySet()) { if (entry.getValue().equals(guid)) { nameToGuid.remove(entry.getKey()); break; } } } if(network != null) nameToGuid.put(network, guid); if (vNetsByGuid.containsKey(guid)) vNetsByGuid.get(guid).setName(network); else vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); if ((gateway != null) && (gateway != 0)) { addGateway(guid, gateway); if(vNetsByGuid.get(guid)!=null) vNetsByGuid.get(guid).setGateway(IPv4.fromIPv4Address(gateway)); } }  @Override void createNetwork(String guid, String network, Integer gateway); @Override void deleteNetwork(String guid); @Override void addHost(MACAddress mac, String guid, String port); @Override void deleteHost(MACAddress mac, String port); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override Collection <VirtualNetwork> listNetworks(); }
VirtualNetworkFilter implements IFloodlightModule, IVirtualNetworkService, IOFMessageListener { @Override public void createNetwork(String guid, String network, Integer gateway) { if (log.isDebugEnabled()) { String gw = null; try { gw = IPv4.fromIPv4Address(gateway); } catch (Exception e) { } log.debug("Creating network {} with ID {} and gateway {}", new Object[] {network, guid, gw}); } if (!nameToGuid.isEmpty()) { for (Entry<String, String> entry : nameToGuid.entrySet()) { if (entry.getValue().equals(guid)) { nameToGuid.remove(entry.getKey()); break; } } } if(network != null) nameToGuid.put(network, guid); if (vNetsByGuid.containsKey(guid)) vNetsByGuid.get(guid).setName(network); else vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); if ((gateway != null) && (gateway != 0)) { addGateway(guid, gateway); if(vNetsByGuid.get(guid)!=null) vNetsByGuid.get(guid).setGateway(IPv4.fromIPv4Address(gateway)); } }  @Override void createNetwork(String guid, String network, Integer gateway); @Override void deleteNetwork(String guid); @Override void addHost(MACAddress mac, String guid, String port); @Override void deleteHost(MACAddress mac, String port); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); @Override Collection <VirtualNetwork> listNetworks();  }