Search in sources :

Example 1 with IPVersion

use of com.vmware.photon.controller.model.support.IPVersion in project photon-model by vmware.

the class SubnetRangeService method validateIpsOutsideDefinedRanges.

/**
 * We don't want ip ranges to overlap. So we check the newly created ip range,
 * with the pre existing ip ranges and make sure there is no over lap.
 * If there is an overlap, raise exception.
 *
 * @param documentSelfLink  The self link of the subnetrange document being modified
 *                          This is empty if its a create.
 * @param startIp           The start ip provided for this subnet range
 * @param endIp             The end ip for this subnet range
 * @param subnetRangeStates This is a list of all the pre-existing subnet states. We check
 *                          for overlap against these.
 */
private void validateIpsOutsideDefinedRanges(String documentSelfLink, String startIp, String endIp, List<SubnetRangeState> subnetRangeStates) {
    String ipUnderTest;
    for (SubnetRangeState subnetRangeState : subnetRangeStates) {
        String selfLink = subnetRangeState.documentSelfLink;
        // For updates or patches, don't check against self
        if (selfLink == null || !selfLink.equals(documentSelfLink)) {
            String ipBegin = subnetRangeState.startIPAddress;
            String ipEnd = subnetRangeState.endIPAddress;
            IPVersion ipVersion = subnetRangeState.ipVersion;
            ipUnderTest = startIp;
            throwExceptionIfIpOverlap(ipBegin, ipEnd, ipVersion, ipUnderTest);
            ipUnderTest = endIp;
            throwExceptionIfIpOverlap(ipBegin, ipEnd, ipVersion, ipUnderTest);
        }
    }
}
Also used : IPVersion(com.vmware.photon.controller.model.support.IPVersion)

Aggregations

IPVersion (com.vmware.photon.controller.model.support.IPVersion)1