private void validateState(NetworkInterfaceDescription state) { if (state.assignment == null) { state.assignment = IpAssignment.DYNAMIC; } Utils.validateState(getStateDescription(), state); if (state.address != null) { if (state.assignment != IpAssignment.STATIC) { throw new IllegalArgumentException( "IP can be reserved only when assignment is STATIC"); } if (!InetAddressValidator.getInstance().isValidInet4Address( state.address)) { throw new IllegalArgumentException("IP address is invalid"); } } }
private void validateState(NetworkInterfaceDescription state) { if (state.assignment == null) { state.assignment = IpAssignment.DYNAMIC; } Utils.validateState(getStateDescription(), state); if (state.address != null) { if (state.assignment != IpAssignment.STATIC) { throw new IllegalArgumentException( "IP can be reserved only when assignment is STATIC"); } if (!InetAddressValidator.getInstance().isValidInet4Address( state.address)) { throw new IllegalArgumentException("IP address is invalid"); } } }
@Override public void handlePatch(Operation patch) { NetworkInterfaceDescription currentState = getState(patch); ResourceUtils.handlePatch(patch, currentState, getStateDescription(), NetworkInterfaceDescription.class, t -> { NetworkInterfaceDescription patchBody = patch.getBody(NetworkInterfaceDescription.class); boolean hasStateChanged = false; if (patchBody.endpointLink != null && currentState.endpointLink == null) { currentState.endpointLink = patchBody.endpointLink; hasStateChanged = true; } if (patchBody.securityGroupLinks != null) { if (currentState.securityGroupLinks == null) { currentState.securityGroupLinks = patchBody.securityGroupLinks; hasStateChanged = true; } else { for (String link : patchBody.securityGroupLinks) { if (!currentState.securityGroupLinks.contains(link)) { currentState.securityGroupLinks.add(link); hasStateChanged = true; } } } } return hasStateChanged; }); }
@Override public void handlePatch(Operation patch) { NetworkInterfaceDescription currentState = getState(patch); ResourceUtils.handlePatch(this, patch, currentState, getStateDescription(), NetworkInterfaceDescription.class, t -> { NetworkInterfaceDescription patchBody = patch.getBody(NetworkInterfaceDescription.class); boolean hasStateChanged = false; if (patchBody.endpointLink != null && currentState.endpointLink == null) { currentState.endpointLink = patchBody.endpointLink; hasStateChanged = true; } if (patchBody.securityGroupLinks != null) { if (currentState.securityGroupLinks == null) { currentState.securityGroupLinks = patchBody.securityGroupLinks; hasStateChanged = true; } else { for (String link : patchBody.securityGroupLinks) { if (!currentState.securityGroupLinks.contains(link)) { currentState.securityGroupLinks.add(link); hasStateChanged = true; } } } } return hasStateChanged; }); }