private static List<OpenDoveServiceAppliance> getAssignableDGWs( IfOpenDoveServiceApplianceCRUD serviceApplianceDB) { List<OpenDoveServiceAppliance> answer = new ArrayList<OpenDoveServiceAppliance>(); for (OpenDoveServiceAppliance oDSA: serviceApplianceDB.getAppliances()) { if (oDSA.get_isDGW() && oDSA.getDoveTunnel() != null) { answer.add(oDSA); } } return answer; }
public boolean dsaIPConflict(String ip, String uuid) { Iterator<OpenDoveServiceAppliance> i = doveServiceApplianceDB.values().iterator(); while (i.hasNext()) { OpenDoveServiceAppliance d = i.next(); if (d.getIP().compareTo(ip) == 0) { if (d.getUUID().compareTo(uuid) == 0) { // No Conflict return false; } else { // IP Address Conflict return true; } } } // IP Address Conflict return false; }
public List<OpenDoveServiceAppliance> getRoleAssignedDcsAppliances() { List<OpenDoveServiceAppliance> answer = new ArrayList<OpenDoveServiceAppliance>(); Iterator<OpenDoveServiceAppliance> i = doveServiceApplianceDB.values().iterator(); while (i.hasNext()) { OpenDoveServiceAppliance d = i.next(); if (d.get_isDCS () == true ) { answer.add(d); } } return answer; }
boolean purge = true; for (OpenDoveServiceAppliance oDSA: oDSAs) { if (oDSA.get_isDCS()) { if (oDSA.get_dcs_config_version() < o.getLastChangeVersion()) { purge = false; if (oDSA.get_isDGW()) { if (oDSA.get_dgw_config_version() < o.getLastChangeVersion()) { purge = false;
if (!dgwAppliance.get_canBeDGW()) { throw new BadRequestException("can't apply action to specified appliance"); if (!dgwAppliance.get_isDGW()) { throw new BadRequestException("appliance must be an active oDGW"); } else { OpenDoveGwIpv4 newGWIP = new OpenDoveGwIpv4(gwIpv4.getIP(), gwIpv4.getMask(), gwIpv4.getNexthop(), gwIpv4.getType(), odgwUUID, 0); gatewayIPDB.addGwIpv4(newGWIP.getUUID(), newGWIP); dgwAppliance.setDoveTunnel(newGWIP); ipv4UUID = newGWIP.getUUID();
if (delta.get_isDGW() == null) { throw new BadRequestException("Missing necessary part of JSON object"); if (!dgwAppliance.get_canBeDGW())
while (ipIterator.hasNext()) { OpenDoveGwIpv4 gwIP = ipIterator.next(); if (gwIP.getGWUUID().equalsIgnoreCase(target.getUUID()) && info.isInRange(gwIP.getIP())) { found = true; neutronSubnet.allocateIP(gwAddress); OpenDoveGwIpv4 newGWIP = new OpenDoveGwIpv4(gwAddress, OpenDoveSubnet.getIPMask(neutronSubnet.getCidr()), neutronSubnet.getGatewayIP(), "external", target.getUUID(), 0); newGWIP.setNeutronSubnet(neutronSubnet); gatewayIPDB.addGwIpv4(newGWIP.getUUID(), newGWIP); target.setEGWExtIP(newGWIP);
OpenDoveNetwork extMCastNet = d.getExtMCastNetwork(); Integer domainID = d.getDomainId(); OpenDoveGwIpv4 egwExternalIP = oDSA.getEGWExtIP(); OpenDoveEGWSNATPool snatPool = new OpenDoveEGWSNATPool(oDSA.getUUID(), ip_low, ip_high, oldODN.getDomain_uuid(), domainID, extMCastNet.getVnid(), oldODN.getVnid(), egwExternalIP,
public int canAttachInterface(NeutronRouter router, NeutronRouter_Interface routerInterface) { //See if a EGW will need to be configured //If so, and there aren't GWs available, return BADREQUEST with a message INeutronSubnetCRUD neutronSubnetIf = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this); NeutronSubnet neutronSubnet = neutronSubnetIf.getSubnet(routerInterface.getSubnetUUID()); INeutronNetworkCRUD neutronNetworkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this); NeutronNetwork neutronNetwork = neutronNetworkIf.getNetwork(neutronSubnet.getNetworkUUID()); if (neutronNetwork.isRouterExternal()) { IfOpenDoveServiceApplianceCRUD serviceApplianceDB = OpenDoveCRUDInterfaces.getIfDoveServiceApplianceCRUD(this); List<OpenDoveServiceAppliance> oDSAs = serviceApplianceDB.getAppliances(); Iterator<OpenDoveServiceAppliance> iterator = oDSAs.iterator(); while (iterator.hasNext()) { if (iterator.next().get_isDGW()) { return 200; } } return 400; } return 200; }
if (delta.get_isDCS() == null) throw new BadRequestException("request missing required field"); if (!dcsAppliance.get_canBeDCS()) throw new BadRequestException("target can not meet request"); if (delta.get_isDCS()) {
public boolean networkUsesEGW(String gatewayUUID) { Iterator<OpenDoveServiceAppliance> iterator = gateways.iterator(); while (iterator.hasNext()) { OpenDoveServiceAppliance testDSA = iterator.next(); if (testDSA.getUUID().equalsIgnoreCase(gatewayUUID)) { return true; } } return false; }
public boolean dsaIPExists(String ip) { Iterator<OpenDoveServiceAppliance> i = doveServiceApplianceDB.values().iterator(); while (i.hasNext()) { OpenDoveServiceAppliance d = i.next(); if (d.getIP().compareTo(ip) == 0) { return true; } } return false; }
OpenDoveEGWFwdRule egwFwdRule = new OpenDoveEGWFwdRule(floatingIP, egw.getUUID(), "0.0.0.0", "0.0.0.0", vnid); egwFwdRuleCRUDif.addEgwFwdRule(egwFwdRule.getUUID(), egwFwdRule);
private int canAllocateEGW(String uuid, boolean negate) { /* if object is shared and domains are not separated, * then we need to configure an external gateway at this point. If we don't have one * don't create the port */ IfNBSystemRU systemDB = OpenDoveCRUDInterfaces.getIfSystemRU(this); INeutronNetworkCRUD neutronNetworkIf = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this); NeutronNetwork neutronNetwork = neutronNetworkIf.getNetwork(uuid); if (!neutronNetwork.isRouterExternal()) { if (neutronNetwork.isShared()) { OpenDoveNeutronControlBlock controlBlock = systemDB.getSystemBlock(); //get system block if ((!negate && controlBlock.getDomainSeparation()) || (negate && !controlBlock.getDomainSeparation())) { IfOpenDoveServiceApplianceCRUD serviceApplianceDB = OpenDoveCRUDInterfaces.getIfDoveServiceApplianceCRUD(this); for (OpenDoveServiceAppliance oDSA : serviceApplianceDB.getAppliances()) { if (oDSA.get_isDGW() && oDSA.getDoveTunnel() != null){ return 200; } } return 400; } } } return 200; } }
public OpenDoveServiceAppliance getDCSSeed() { List<OpenDoveServiceAppliance> candidates = new ArrayList<OpenDoveServiceAppliance>(); for (OpenDoveServiceAppliance appliance: doveServiceApplianceDB.values()) { if (appliance.get_isDCS()) { candidates.add(appliance); } } if (candidates.size() < 1) { return null; } return candidates.get(Math.abs(OpenDoveUtils.getNextInt()) % candidates.size()); }