Search in sources :

Example 6 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method getClusterInfo.

public ClusterInfo getClusterInfo(String siteIdParam) {
    try {
        String siteId = siteIdParam == null ? _coordinator.getSiteId() : siteIdParam;
        // get target repository and configVersion
        final RepositoryInfo targetRepository = _coordinator.getTargetInfo(RepositoryInfo.class);
        final PropertyInfoExt targetProperty = _coordinator.getTargetInfo(PropertyInfoExt.class);
        // get control nodes' repository and configVersion info
        final Map<Service, RepositoryInfo> controlNodesInfo = getAllNodeInfos(RepositoryInfo.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        final Map<Service, ConfigVersion> controlNodesConfigVersions = getAllNodeInfos(ConfigVersion.class, CONTROL_NODE_SYSSVC_ID_PATTERN, siteId);
        ClusterInfo.ClusterState controlNodesState = _coordinator.getControlNodesState(siteId);
        // rotating ipsec key. We should report upgrade in progress on UI
        if (backCompatPreYoda && ClusterInfo.ClusterState.STABLE.equals(controlNodesState)) {
            if (!drUtil.isMultivdc()) {
                _log.info("Back compat flag for preyoda is true. ");
                controlNodesState = ClusterInfo.ClusterState.UPDATING;
            }
        }
        // cluster state is determined both by control nodes' state and extra nodes
        return toClusterInfo(controlNodesState, controlNodesInfo, controlNodesConfigVersions, targetRepository, targetProperty);
    } catch (Exception e) {
        _log.info("Fail to get the cluster information ", e);
        return null;
    }
}
Also used : ClusterInfoMapper.toClusterInfo(com.emc.storageos.systemservices.mapper.ClusterInfoMapper.toClusterInfo) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ConfigVersion(com.emc.storageos.coordinator.client.model.ConfigVersion) Service(com.emc.storageos.coordinator.common.Service) ClusterState(com.emc.vipr.model.sys.ClusterInfo.ClusterState) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 7 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class CoordinatorClientExt method setTargetProperties.

/**
 * Update system properties to zookeeper
 *
 * @param currentProps
 * @throws CoordinatorClientException
 */
public void setTargetProperties(Map<String, String> currentProps) throws CoordinatorClientException {
    Map<String, PropertyMetadata> propsMetadata = PropertiesMetadata.getGlobalMetadata();
    // split properties as global, or site specific
    HashMap<String, String> globalProps = new HashMap<String, String>();
    HashMap<String, String> siteProps = new HashMap<String, String>();
    for (Map.Entry<String, String> prop : currentProps.entrySet()) {
        String key = prop.getKey();
        PropertyMetadata metadata = propsMetadata.get(key);
        if (metadata.getSiteSpecific()) {
            siteProps.put(key, prop.getValue());
        } else {
            globalProps.put(key, prop.getValue());
        }
    }
    // update properties to zk
    if (getTargetInfoLock()) {
        try {
            // check we are in stable state if checkState = true specified
            if (!isClusterUpgradable()) {
                throw APIException.serviceUnavailable.clusterStateNotStable();
            }
            ConfigurationImpl globalCfg = new ConfigurationImpl();
            globalCfg.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
            globalCfg.setKind(PropertyInfoExt.TARGET_PROPERTY);
            PropertyInfoExt globalPropInfo = new PropertyInfoExt(globalProps);
            globalCfg.setConfig(TARGET_INFO, globalPropInfo.encodeAsString());
            _coordinator.persistServiceConfiguration(globalCfg);
            _log.info("target properties changed successfully. target properties {}", globalPropInfo.toString());
            if (siteProps.size() > 0) {
                setSiteSpecificProperties(siteProps, _coordinator.getSiteId());
                _log.info("site scope target properties changed successfully. target properties {}", siteProps.toString());
            }
        } catch (Exception e) {
            throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target info. " + e.getMessage());
        } finally {
            releaseTargetVersionLock();
        }
    } else {
        throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. Unable to obtain target lock");
    }
}
Also used : HashMap(java.util.HashMap) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) PropertyMetadata(com.emc.storageos.model.property.PropertyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 8 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class IPSecMonitor method getVdcShortIdByIp.

private String getVdcShortIdByIp(String nodeIp) {
    PropertyInfoExt vdcProps = LocalRepository.getInstance().getVdcPropertyInfo();
    String nodeKey = null;
    for (String key : vdcProps.getAllProperties().keySet()) {
        String value = vdcProps.getProperty(key);
        if (key.contains("ipaddr6")) {
            value = IpUtils.decompressIpv6Address(value);
        }
        if (value != null && value.toLowerCase().equals(nodeIp.toLowerCase())) {
            nodeKey = key;
            break;
        }
    }
    String vdcShortId = null;
    if (nodeKey != null && nodeKey.startsWith("vdc_vd")) {
        vdcShortId = nodeKey.split("_")[1];
    }
    return vdcShortId;
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Example 9 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class SecretsManager method innerRun.

@Override
protected void innerRun() {
    while (doRun) {
        log.debug("Main loop: Start");
        // Wait for target info initialized
        PropertyInfoExt targetInfo = coordinator.getTargetInfo(PropertyInfoExt.class);
        if (targetInfo == null) {
            log.info("The target info in ZK has not been initialized yet. Waiting...");
            retrySleep();
            continue;
        }
        // Step0: Configure ssh if needed. Probably only run once in first boot.
        try {
            sshConfig.run();
        } catch (Exception e) {
            log.info("Error during attempt to configure ssh will be retried: {}", e.getMessage());
            retrySleep();
            continue;
        }
        // Step1:
        log.info("Step1: Sync SSL key and certificate if needed");
        try {
            syncSslKeyAndCert();
        } catch (Exception e) {
            log.info("Step1 failed and will be retried: {}", e.getMessage());
            retrySleep();
            continue;
        }
        log.info("Step2: Generate DH Params if not yet");
        if (!dhInitDone) {
            dhInitDone = genDHParam();
        }
        // Step3: sleep
        log.info("Step3: sleep");
        longSleep();
    }
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Example 10 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class SecretsManager method updateLocalSslProps.

private void updateLocalSslProps() throws Exception {
    PropertyInfoExt sslProps = new SslPropertyInfo();
    sslProps.addProperty(NGINX_PRIV_KEY, escapeNewlines(key));
    sslProps.addProperty(NGINX_PUB_KEY, escapeNewlines(cert));
    log.info("updating local ssl properties");
    localRepository.setSslPropertyInfo(sslProps);
    log.info("Reconfiguring SSL related config files");
    localRepository.reconfigProperties(SSL_PROP_TAG);
    log.info("Invoking SSL notifier");
    Notifier.getInstance(SSL_PROP_TAG).doNotify();
    sslProps.addProperty(NGINX_KEY_HASH, keyHash);
    log.info("updating local ssl key hash property");
    localRepository.setSslPropertyInfo(sslProps);
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt)

Aggregations

PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)33 HashMap (java.util.HashMap)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)4 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)4 Test (org.junit.Test)4 Site (com.emc.storageos.coordinator.client.model.Site)3 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)3 IOException (java.io.IOException)3 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)2 SiteParam (com.emc.storageos.model.dr.SiteParam)2 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)2 PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)2 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)1