Search in sources :

Example 71 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigService method isDisconnectedEachOther.

private boolean isDisconnectedEachOther(List<String> blackList, List<String> whiteList) {
    VirtualDataCenter myVdc = getLocalVdc();
    Collection<String> addresses = dbClient.queryHostIPAddressesMap(myVdc).values();
    log.info("local vdc IP addresses:{}", addresses);
    boolean found = false;
    for (String addr : addresses) {
        if (blackList.contains(addr)) {
            log.info("The addr {} is in the blackList {}", addr, blackList);
            found = true;
            break;
        }
    }
    if (found == false) {
        // not disconnected each other
        return false;
    }
    Collection<List<String>> localBlackLists = dbClient.getBlacklist().values();
    log.info("The localBackLists={}", localBlackLists);
    List<String> localBlackList = new ArrayList();
    for (List<String> list : localBlackLists) {
        localBlackList = list;
    }
    return localBlackList.containsAll(whiteList);
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 72 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigHelper method connectVdcPostCheck.

private void connectVdcPostCheck(VdcPostCheckParam checkParam) {
    URI root = getVdcRootTenantId();
    if (root != null) {
        if (!root.equals(checkParam.getRootTenantId())) {
            throw new IllegalStateException("root tenant id is different, sync vdc config must failed");
        }
    } else {
        throw new IllegalStateException("root tenant not exist, sync vdc config must failed");
    }
    log.info("Post check: Vdc root tenant id {} check passed", root);
    // Verify if sync vdc config apply successfully
    List<URI> serverVdcList = checkParam.getVdcList();
    List<URI> vdcIdList = dbClient.queryByType(VirtualDataCenter.class, true);
    List<VirtualDataCenter> connectedVdc = new ArrayList<>();
    for (URI vdcId : vdcIdList) {
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
        if (!serverVdcList.contains(vdcId)) {
            // Some records not exist in server side, something must be wrong
            if ((vdc.getConnectionStatus() != null) && (vdc.getConnectionStatus() == ConnectionStatus.ISOLATED || vdc.getConnectionStatus() == ConnectionStatus.CONNECTED)) {
                throw new IllegalStateException("some connected vdc status is not correct, sync vdc config must failed");
            }
        } else {
            serverVdcList.remove(vdcId);
            connectedVdc.add(vdc);
        }
    }
    if (!serverVdcList.isEmpty()) {
        // Some records not exist in this site, something must be wrong
        throw new IllegalStateException("some connected vdc not exist, sync vdc config must failed");
    }
    log.info("Post check: number of connected vdc {} ", connectedVdc.size());
    // Update the status
    for (VirtualDataCenter vdc : connectedVdc) {
        // mark as CONNECTED if currently not
        if ((vdc.getConnectionStatus() == null) || (vdc.getConnectionStatus() != ConnectionStatus.CONNECTED)) {
            vdc.setConnectionStatus(ConnectionStatus.CONNECTED);
            vdc.setRepStatus(GeoReplicationStatus.REP_ALL);
            dbClient.updateAndReindexObject(vdc);
            log.info("Post check: update vdc status to connected {} ", vdc.getShortId());
        }
    }
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 73 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigHelper method isCompatibleVersion.

public boolean isCompatibleVersion(SoftwareVersion remoteVer) {
    log.info("Remote version is {}", remoteVer);
    VirtualDataCenter localVdc = VdcUtil.getLocalVdc();
    String viprVersion = getViPRVersion(localVdc.getShortId());
    log.info("My vipr version is {}", viprVersion);
    SoftwareVersion myViprVersion = new SoftwareVersion(viprVersion);
    if (myViprVersion.compareTo(remoteVer) >= 0) {
        log.info("version compatible");
        return true;
    }
    log.info("version not compatible");
    return false;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 74 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigHelper method fromConfigParam.

private VirtualDataCenter fromConfigParam(VdcConfig config) {
    VirtualDataCenter vdc = new VirtualDataCenter();
    vdc.setId(config.getId());
    if (config.getConnectionStatus() != null) {
        vdc.setConnectionStatus(Enum.valueOf(ConnectionStatus.class, config.getConnectionStatus()));
    }
    if (config.getRepStatus() != null) {
        vdc.setRepStatus(Enum.valueOf(GeoReplicationStatus.class, config.getRepStatus()));
    }
    vdc.setVersion(config.getVersion());
    vdc.setShortId(config.getShortId());
    vdc.setLabel(config.getName());
    vdc.setDescription(config.getDescription());
    vdc.setApiEndpoint(config.getApiEndpoint());
    vdc.setSecretKey(config.getSecretKey());
    vdc.setLocal(false);
    vdc.setGeoCommandEndpoint(config.getGeoCommandEndpoint());
    vdc.setGeoDataEndpoint(config.getGeoDataEndpoint());
    return vdc;
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) GeoReplicationStatus(com.emc.storageos.db.client.model.VirtualDataCenter.GeoReplicationStatus) ConnectionStatus(com.emc.storageos.db.client.model.VirtualDataCenter.ConnectionStatus)

Example 75 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigHelper method sendVdcNodeCheckRequest.

/**
 * Send node check request to target vdc.
 *
 * @param sendToVdc vdc to send msg to
 * @param vdcsToCheck list of vdc's with nodes to check
 * @return
 * @throws Exception
 */
public VdcNodeCheckResponse sendVdcNodeCheckRequest(VirtualDataCenter sendToVdc, Collection<VirtualDataCenter> vdcsToCheck) {
    List<VdcConfig> virtualDataCenters = new ArrayList<VdcConfig>();
    for (VirtualDataCenter vdc : vdcsToCheck) {
        VdcConfig vdcConfig = new VdcConfig();
        vdcConfig.setId(vdc.getId());
        vdcConfig.setShortId(vdc.getShortId());
        Site activeSite = drUtil.getActiveSite(vdc.getShortId());
        if (activeSite.getHostIPv4AddressMap() != null && !activeSite.getHostIPv4AddressMap().isEmpty() && activeSite.isUsingIpv4()) {
            HashMap<String, String> addressMap = new HashMap<String, String>(activeSite.getHostIPv4AddressMap());
            vdcConfig.setHostIPv4AddressesMap(addressMap);
        } else if (activeSite.getHostIPv6AddressMap() != null && !activeSite.getHostIPv6AddressMap().isEmpty()) {
            HashMap<String, String> addressMap = new HashMap<String, String>(activeSite.getHostIPv6AddressMap());
            vdcConfig.setHostIPv6AddressesMap(addressMap);
        } else {
            throw new IllegalStateException("Cannot perform node reachable check on vdc " + vdc.getShortId() + " no nodes were found on VirtualDataCenter object");
        }
        virtualDataCenters.add(vdcConfig);
    }
    return sendVdcNodeCheckRequest(sendToVdc, virtualDataCenters);
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) HashMap(java.util.HashMap) VdcConfig(com.emc.storageos.geomodel.VdcConfig) ArrayList(java.util.ArrayList) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Aggregations

VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)80 URI (java.net.URI)47 ArrayList (java.util.ArrayList)20 VdcConfig (com.emc.storageos.geomodel.VdcConfig)14 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)13 Test (org.junit.Test)10 Site (com.emc.storageos.coordinator.client.model.Site)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 VdcConfigSyncParam (com.emc.storageos.geomodel.VdcConfigSyncParam)7 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 Produces (javax.ws.rs.Produces)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 DataObject (com.emc.storageos.db.client.model.DataObject)4 TestGeoObject (com.emc.storageos.db.client.model.TestGeoObject)4 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)4 KeyStoreException (java.security.KeyStoreException)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4