Search in sources :

Example 1 with VdcNatCheckResponse

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;
}
Also used : VdcNatCheckResponse(com.emc.storageos.geomodel.VdcNatCheckResponse) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 2 with VdcNatCheckResponse

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;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) VdcNatCheckParam(com.emc.storageos.geomodel.VdcNatCheckParam) VdcNatCheckResponse(com.emc.storageos.geomodel.VdcNatCheckResponse) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Aggregations

VdcNatCheckResponse (com.emc.storageos.geomodel.VdcNatCheckResponse)2 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)1 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)1 VdcNatCheckParam (com.emc.storageos.geomodel.VdcNatCheckParam)1 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1