// TODO Lower address test public void testAddresses() { SubnetUtils utils = new SubnetUtils("192.168.0.1/29"); SubnetInfo info = utils.getInfo(); assertTrue(info.isInRange("192.168.0.1")); // We don't count the broadcast address as usable assertFalse(info.isInRange("192.168.0.7")); assertFalse(info.isInRange("192.168.0.8")); assertFalse(info.isInRange("10.10.2.1")); assertFalse(info.isInRange("192.168.1.1")); assertFalse(info.isInRange("192.168.0.255")); }
public static OpenDoveGwIpv4 assignEGWs( Object o, OpenDoveServiceAppliance target, String subnetCIDR, String subnetGatewayIP, String gwAddress, NeutronRouter router) { IfSBDoveGwIpv4CRUD gatewayIPDB = OpenDoveCRUDInterfaces.getIfSBDoveGwIpv4CRUD(o); SubnetUtils util = new SubnetUtils(subnetCIDR); SubnetInfo info = util.getInfo(); OpenDoveGwIpv4 newGWIP = null; List<OpenDoveGwIpv4> gwIPs = gatewayIPDB.getGwIpv4Pool(); Iterator<OpenDoveGwIpv4> ipIterator = gwIPs.iterator(); boolean found = false; while (ipIterator.hasNext()) { OpenDoveGwIpv4 gwIP = ipIterator.next(); if (gwIP.getGWUUID().equalsIgnoreCase(target.getUUID()) && info.isInRange(gwIP.getIP()) && gwIP.getType().equalsIgnoreCase("external")) { found = true; } } if (!found) { newGWIP = new OpenDoveGwIpv4( gwAddress, OpenDoveSubnet.getIPMask(subnetCIDR), subnetGatewayIP, "external", target.getUUID(), 0, router); // TODO: this needs to be outside // newGWIP.setNeutronSubnet(neutronSubnet); gatewayIPDB.addGwIpv4(newGWIP.getUUID(), newGWIP); // Set the External IP for EGW, will be used by SNAT Pool Configuration target.setEGWExtIP(newGWIP); } return newGWIP; }