Search in sources :

Example 11 with VdcConfig

use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.

the class ConnectVdcTaskOp method mergeVdcInfo.

private VdcConfig mergeVdcInfo(VdcPreCheckResponse vdcResp) {
    log.info("add to be added vdc {} to the merged vdc config", vdcInfo.getProperty(GeoServiceJob.VDC_SHORT_ID));
    VdcConfig vdcConfig = helper.toConfigParam(vdcInfo);
    // Following items should be set according to remote site
    log.info("get from remote {} {}", vdcResp.getHostCount(), vdcResp.getShortId());
    vdcConfig.setHostCount(vdcResp.getHostCount());
    vdcConfig.setHostIPv4AddressesMap(vdcResp.getHostIPv4AddressesMap());
    vdcConfig.setHostIPv6AddressesMap(vdcResp.getHostIPv6AddressesMap());
    if (operatedVdc == null) {
        vdcConfig.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTING.toString());
        vdcConfig.setRepStatus(VirtualDataCenter.GeoReplicationStatus.REP_NONE.toString());
    } else {
        vdcConfig.setConnectionStatus(operatedVdc.getConnectionStatus().toString());
        vdcConfig.setRepStatus(operatedVdc.getRepStatus().toString());
    }
    Date addDate = new Date();
    // notify the vdc to pick up the latest info
    vdcConfig.setVersion(addDate.getTime());
    vdcConfig.setActiveSiteId(vdcResp.getActiveSiteId());
    return vdcConfig;
}
Also used : VdcConfig(com.emc.storageos.geomodel.VdcConfig) Date(java.util.Date)

Example 12 with VdcConfig

use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.

the class ConnectVdcTaskOp method checkNodeConnectivity.

private boolean checkNodeConnectivity(VdcPreCheckResponse vdcBeingAdded) {
    // check to make sure the current vdc can connect to all nodes on the vdc being added
    if (!helper.areNodesReachable(vdcBeingAdded.getShortId(), vdcBeingAdded.getHostIPv4AddressesMap(), vdcBeingAdded.getHostIPv6AddressesMap(), false)) {
        errMsg = String.format("Current vdc, %s, cannot reach all nodes of vdc being added", myVdc.getLabel());
        log.error(errMsg);
        return false;
    }
    // check to make sure the vdc being added can connect to the current and all other vdc's
    log.info("sending node check request to vdc: {}", vdcInfo.getProperty(GeoServiceJob.OPERATED_VDC_ID));
    VdcNodeCheckResponse vdcResp = sendVdcNodeCheckRequest(vdcInfo, connectedVdc);
    if (!vdcResp.isNodesReachable()) {
        errMsg = "vdc to be added cannot connect to all nodes of at least one of the vdcs in the federation";
        log.error(errMsg);
        return false;
    }
    // check to make sure the vdc being added can connect to the current and all other vdc's
    List<VdcConfig> vdcConfigs = new ArrayList<VdcConfig>();
    vdcConfigs.add(mergeVdcInfo(vdcBeingAdded));
    for (VirtualDataCenter other : connectedVdc) {
        if (other.getShortId().equals(myVdc.getShortId())) {
            continue;
        }
        log.info("sending node check request to vdc: {}", other.getShortId());
        vdcResp = sendVdcNodeCheckRequest(GeoServiceHelper.getVDCInfo(other), vdcConfigs);
        if (!vdcResp.isNodesReachable()) {
            errMsg = String.format("vdc, %s, cannot connect to all nodes of the vdc being added", other.getLabel());
            log.error(errMsg);
            return false;
        }
    }
    errMsg = checkNetworkTopology(vdcBeingAdded);
    if (errMsg != null && errMsg.length() > 0) {
        return false;
    }
    return true;
}
Also used : VdcNodeCheckResponse(com.emc.storageos.geomodel.VdcNodeCheckResponse) VdcConfig(com.emc.storageos.geomodel.VdcConfig) ArrayList(java.util.ArrayList) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 13 with VdcConfig

use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.

the class RemoveVdcTaskOp method updateConfigForConnectedVdc.

/**
 * Update new vdc config for all sites - exclude the site to be removed
 */
private void updateConfigForConnectedVdc() {
    // build new vdc config without operatedVdc
    List<VirtualDataCenter> newVdcList = new ArrayList<>();
    for (VirtualDataCenter vdc : getAllVdc()) {
        if (!vdc.getId().equals(operatedVdc.getId())) {
            // ignore the one to be removed
            newVdcList.add(vdc);
        }
    }
    log.info("number of vdc {} after removal", newVdcList.size());
    VdcConfigSyncParam syncParam = buildConfigParam(newVdcList);
    for (VirtualDataCenter vdc : connectedVdc) {
        if (vdc.getId().equals(myVdc.getId()) || vdc.getId().equals(operatedVdc.getId())) {
            // skip my current vdc and operated vdc
            continue;
        }
        geoClientCache.getGeoClient(vdc.getShortId()).syncVdcConfig(syncParam, vdc.getLabel());
    }
    dbClient.stopClusterGossiping();
    // set connection status to isolated if there is only one vdc in current geo system
    if (newVdcList.size() == 1) {
        if (!syncParam.getVirtualDataCenters().isEmpty()) {
            VdcConfig vdcConfig = syncParam.getVirtualDataCenters().get(0);
            vdcConfig.setConnectionStatus(ConnectionStatus.ISOLATED.toString());
            vdcConfig.setVersion(new Date().getTime());
        } else {
            log.error("Unexpected Vdc list size in sync config param");
        }
    }
    // update my local site with new config
    helper.syncVdcConfig(syncParam.getVirtualDataCenters(), null, syncParam.getVdcConfigVersion(), syncParam.getIpsecKey());
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VdcConfig(com.emc.storageos.geomodel.VdcConfig) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 14 with VdcConfig

use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.

the class UpdateVdcTaskOp method mergeConfig.

private VdcConfigSyncParam mergeConfig(VdcPreCheckResponse operatedVdcInfo) {
    // step 2: merge the vdc config info of all sites, as the initiator
    // we should have all current vdc config info
    VdcConfigSyncParam vdcConfigList = new VdcConfigSyncParam();
    List<VdcConfig> list = vdcConfigList.getVirtualDataCenters();
    for (VirtualDataCenter vdc : getAllVdc()) {
        log.info("add {} to the merged vdc config", vdc.getShortId());
        VdcConfig vdcConfig = helper.toConfigParam(vdc);
        list.add(vdcConfig);
    }
    mergeVdcInfo(list, operatedVdc);
    return vdcConfigList;
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VdcConfig(com.emc.storageos.geomodel.VdcConfig) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 15 with VdcConfig

use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.

the class UpdateVdcTaskOp method mergeVdcInfo.

private void mergeVdcInfo(List<VdcConfig> list, VirtualDataCenter vdc) {
    log.info("add to be updated vdc {} to the merged vdc config", vdc.getShortId());
    Iterator<VdcConfig> it = list.iterator();
    while (it.hasNext()) {
        VdcConfig vdcSyncParam = it.next();
        if (vdcSyncParam.getId().compareTo(vdc.getId()) == 0) {
            // update vdc
            // if this is a local,isolated vdc, update local vdc only, no other sites
            boolean isolated = isLocalIsolatedVdc();
            log.info("Checking if this is a local isolated vdc->{}", isolated);
            if (isolated) {
                vdcSyncParam.setConnectionStatus(ConnectionStatus.ISOLATED.toString());
            } else {
                vdcSyncParam.setConnectionStatus(ConnectionStatus.CONNECTED.toString());
            }
            Date updateDate = new Date();
            vdcSyncParam.setVersion(updateDate.getTime());
            if ((vdc.getLabel() != null) && (!vdc.getLabel().isEmpty())) {
                vdcSyncParam.setName(vdc.getLabel());
            }
            if ((vdc.getDescription() != null) && (!vdc.getDescription().isEmpty())) {
                vdcSyncParam.setDescription(vdc.getDescription());
            }
            if ((vdc.getGeoCommandEndpoint() != null) && (!vdc.getGeoCommandEndpoint().isEmpty())) {
                vdcSyncParam.setGeoCommandEndpoint(vdc.getGeoCommandEndpoint());
            }
            if ((vdc.getGeoDataEndpoint() != null) && (!vdc.getGeoDataEndpoint().isEmpty())) {
                vdcSyncParam.setGeoDataEndpoint(vdc.getGeoDataEndpoint());
            }
            // TODO: set apiendpoint and seckey
            return;
        }
    }
    return;
}
Also used : VdcConfig(com.emc.storageos.geomodel.VdcConfig) Date(java.util.Date)

Aggregations

VdcConfig (com.emc.storageos.geomodel.VdcConfig)18 VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)4 Site (com.emc.storageos.coordinator.client.model.Site)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 VdcConfigSyncParam (com.emc.storageos.geomodel.VdcConfigSyncParam)3 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)3 IntrospectionException (java.beans.IntrospectionException)3 IOException (java.io.IOException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 URI (java.net.URI)3 Date (java.util.Date)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 Method (java.lang.reflect.Method)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 NodeList (org.w3c.dom.NodeList)2 TimeSeriesQueryResult (com.emc.storageos.db.client.TimeSeriesQueryResult)1