use of com.emc.storageos.geomodel.VdcNatCheckResponse in project coprhd-controller by CoprHD.
the class VdcConfigService method checkIfBehindNat.
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/natcheck")
public VdcNatCheckResponse checkIfBehindNat(VdcNatCheckParam checkParam, @HeaderParam("X-Forwarded-For") String clientIp) {
if (checkParam == null) {
log.error("checkParam is null, X-Forwarded-For is {}", clientIp);
throw GeoException.fatals.invalidNatCheckCall("(null)", clientIp);
}
String ipv4Str = checkParam.getIPv4Address();
String ipv6Str = checkParam.getIPv6Address();
log.info(String.format("Performing NAT check, client address connecting to VIP: %s. Client reports its IPv4 = %s, IPv6 = %s", clientIp, ipv4Str, ipv6Str));
boolean isBehindNat = false;
try {
isBehindNat = sysUtils.checkIfBehindNat(ipv4Str, ipv6Str, clientIp);
} catch (Exception e) {
log.error("Fail to check NAT {}", e);
throw GeoException.fatals.invalidNatCheckCall(e.getMessage(), clientIp);
}
VdcNatCheckResponse resp = new VdcNatCheckResponse();
resp.setSeenIp(clientIp);
resp.setBehindNAT(isBehindNat);
return resp;
}
use of com.emc.storageos.geomodel.VdcNatCheckResponse in project coprhd-controller by CoprHD.
the class ConnectVdcTaskOp method checkNetworkTopology.
private String checkNetworkTopology(VdcPreCheckResponse vdcBeingAdded) {
SoftwareVersion remoteVer = new SoftwareVersion(vdcBeingAdded.getSoftwareVersion());
if (remoteVer.compareTo(netcheckMinVer) >= 0) {
String nodeId = this.dbClient.getCoordinatorClient().getPropertyInfo().getProperty("node_id");
log.info("Retrieving IP addresses of local node: {}, and let remote VDC {} check if we're behind a NAT", nodeId, vdcBeingAdded.getShortId());
DualInetAddress inetAddress = this.dbClient.getCoordinatorClient().getInetAddessLookupMap().getDualInetAddress();
String ipv4 = inetAddress.getInet4();
String ipv6 = inetAddress.getInet6();
log.info("Got local node's IP addresses, IPv4 = {}, IPv6 = {}", ipv4, ipv6);
VdcNatCheckParam checkParam = new VdcNatCheckParam();
checkParam.setIPv4Address(ipv4);
checkParam.setIPv6Address(ipv6);
VdcNatCheckResponse resp = geoClientCache.getGeoClient(vdcInfo).vdcNatCheck(checkParam);
if (resp.isBehindNAT()) {
return String.format("The remote VDC %s seen this node's IP is %s, which is different from what we think: %s or %s, we may behind a NAT", vdcBeingAdded.getShortId(), resp.getSeenIp(), ipv4, ipv6);
}
} else {
log.info("Remote VDC is of version {}, lower than {}, NAT check skipped.", remoteVer, netcheckMinVer);
}
return null;
}
Aggregations