Search in sources :

Example 16 with VdcConfig

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

the class VdcConfigHelper method toConfigParam.

/**
 * Build VdcConfig for a vdc for SyncVdcConfig call
 *
 * @param vdc
 * @return
 */
public VdcConfig toConfigParam(VirtualDataCenter vdc) {
    log.info("copy {} to the sync config param", vdc.getShortId());
    VdcConfig vdcConfig = new VdcConfig();
    Site activeSite = drUtil.getActiveSite(vdc.getShortId());
    vdcConfig.setId(vdc.getId());
    vdcConfig.setShortId(vdc.getShortId());
    vdcConfig.setSecretKey(vdc.getSecretKey());
    if ((vdc.getLabel() != null) && (!vdc.getLabel().isEmpty())) {
        vdcConfig.setName(vdc.getLabel());
    }
    if ((vdc.getDescription() != null) && (!vdc.getDescription().isEmpty())) {
        vdcConfig.setDescription(vdc.getDescription());
    }
    if (activeSite.getVipEndPoint() != null) {
        vdcConfig.setApiEndpoint(activeSite.getVipEndPoint());
    }
    vdcConfig.setHostCount(activeSite.getNodeCount());
    HashMap<String, String> ipv4AddrMap = new HashMap<String, String>(activeSite.getHostIPv4AddressMap());
    vdcConfig.setHostIPv4AddressesMap(ipv4AddrMap);
    HashMap<String, String> ipv6AddrMap = new HashMap<String, String>(activeSite.getHostIPv6AddressMap());
    vdcConfig.setHostIPv6AddressesMap(ipv6AddrMap);
    vdcConfig.setVersion(vdc.getVersion());
    vdcConfig.setConnectionStatus(vdc.getConnectionStatus().toString());
    vdcConfig.setRepStatus(vdc.getRepStatus().toString());
    vdcConfig.setGeoCommandEndpoint(vdc.getGeoCommandEndpoint());
    vdcConfig.setGeoDataEndpoint(vdc.getGeoDataEndpoint());
    vdcConfig.setActiveSiteId(activeSite.getUuid());
    return vdcConfig;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) HashMap(java.util.HashMap) VdcConfig(com.emc.storageos.geomodel.VdcConfig)

Example 17 with VdcConfig

use of com.emc.storageos.geomodel.VdcConfig 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)

Example 18 with VdcConfig

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

the class VdcConfigHelper method syncVdcConfig.

public void syncVdcConfig(List<VdcConfig> newVdcConfigList, String assignedVdcId, boolean isRecover, Long vdcConfigVersion, String ipsecKey) {
    boolean vdcConfigChanged = false;
    // query existing vdc list from db
    // The new queryByType method returns an iterative list, convert it to a "real"
    // list first
    List<URI> vdcIdList = new ArrayList<URI>();
    for (URI vdcId : dbClient.queryByType(VirtualDataCenter.class, true)) {
        vdcIdList.add(vdcId);
    }
    // vdc that are going to be removed from local db
    for (VdcConfig config : newVdcConfigList) {
        if (vdcIdList.contains(config.getId())) {
            vdcIdList.remove(config.getId());
            mergeVdcConfig(config, isRecover);
        } else {
            // not contains in vdcIdList - it is a new vdc and we should insert to db
            VirtualDataCenter newVdc = fromConfigParam(config);
            if (config.getId().toString().equals(assignedVdcId)) {
                newVdc.setLocal(true);
            }
            dbClient.createObject(newVdc);
            if (newVdc.getLocal()) {
                VdcUtil.invalidateVdcUrnCache();
            }
            createVdcConfigInZk(config, ipsecKey);
            vdcConfigChanged = true;
            if (newVdc.getLocal()) {
                drUtil.setLocalVdcShortId(newVdc.getShortId());
            }
        }
    }
    // check vdc that are going to be removed
    ArrayList<String> obsoletePeers = new ArrayList<String>();
    for (URI removeVdcId : vdcIdList) {
        log.warn("vdc config {} is being removed", removeVdcId);
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, removeVdcId);
        ConnectionStatus connStatus = vdc.getConnectionStatus();
        if (!isRecover && connStatus.equals(ConnectionStatus.CONNECT_FAILED)) {
            log.info("Ignore vdc record {} with status {}", removeVdcId, connStatus);
            continue;
        }
        dbClient.markForDeletion(vdc);
        Map<String, String> addressesMap = dbClient.queryHostIPAddressesMap(vdc);
        if (!addressesMap.isEmpty()) {
            // obsolete peers ip in cassandra system table
            obsoletePeers.addAll(addressesMap.values());
            log.info("add {} peers to obsolete list", addressesMap.size());
        }
        dbClient.removeVdcNodesFromBlacklist(vdc);
        deleteVdcConfigFromZk(vdc);
        vdcConfigChanged = true;
    }
    if (!obsoletePeers.isEmpty()) {
        // update peer ip to ZK so that geodbsvc could get it
        notifyDbSvcWithObsoleteCassandraPeers(Constants.GEODBSVC_NAME, obsoletePeers);
        log.info("notify geodbsvc with {} obsolete cassandra peers", obsoletePeers.size());
    }
    if (assignedVdcId != null) {
        // Persist a flag to notify geodbsvc on all the nodes in the current vdc
        log.info("reset db needed, set the flag for all db to look it up");
        updateDbSvcConfig(Constants.GEODBSVC_NAME, Constants.REINIT_DB, String.valueOf(true));
    }
    if (vdcConfigChanged) {
        String action = SiteInfo.GEO_OP_CONFIG_CHANGE;
        // loses connection with other nodes
        if (assignedVdcId != null) {
            action = SiteInfo.IPSEC_OP_ROTATE_KEY;
        }
        triggerVdcConfigUpdate(vdcConfigVersion, action);
    }
}
Also used : VdcConfig(com.emc.storageos.geomodel.VdcConfig) ArrayList(java.util.ArrayList) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ConnectionStatus(com.emc.storageos.db.client.model.VirtualDataCenter.ConnectionStatus) URI(java.net.URI)

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