Пример #1
0
 public static void tombstoneEGWs(
     IfOpenDoveServiceApplianceCRUD serviceApplianceDB,
     IfSBDoveGwIpv4CRUD gatewayIPDB,
     NeutronSubnet subnet,
     OpenDoveNetwork network) {
   for (OpenDoveGwIpv4 gwIP : gatewayIPDB.getGwIpv4Pool()) {
     if (subnet.isValidIP(gwIP.getIP())) {
       subnet.releaseIP(gwIP.getIP());
       gwIP.setTombstoneFlag(true);
       gatewayIPDB.updateGwIpv4(gwIP);
       network.removeEGW(serviceApplianceDB.getDoveServiceAppliance(gwIP.getGWUUID()));
     }
   }
 }
Пример #2
0
  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;
  }