Search in sources :

Example 31 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class AbstractManager method areAllDbsvcActive.

/**
 * Check if all dbsvc instances are active in the cluster
 * currently it's only being used before adjusting db token number but it might as well be used elsewhere.
 *
 * @return true if all dbsvc are active, false otherwise
 */
protected boolean areAllDbsvcActive() {
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    List<Service> activeDbsvcs = coordinatorClient.locateAllSvcsAllVers(Constants.DBSVC_NAME);
    List<String> activeDbsvcIds = new ArrayList<>(activeDbsvcs.size());
    for (Service activeDbsvc : activeDbsvcs) {
        activeDbsvcIds.add(activeDbsvc.getId());
    }
    log.info("List of active dbsvc instances in the cluster: {}, expect {} instances", activeDbsvcIds, nodeCount);
    boolean allActive = activeDbsvcs.size() == nodeCount;
    if (!allActive) {
        log.info("not all dbsvc instances are active. Retrying...");
    }
    return allActive;
}
Also used : ArrayList(java.util.ArrayList) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) Service(com.emc.storageos.coordinator.common.Service)

Example 32 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class SchedulerConfig method initRetainedAndUploadedBackups.

private void initRetainedAndUploadedBackups() {
    this.retainedBackups.clear();
    this.uploadedBackups.clear();
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    Configuration cfg = coordinatorClient.queryConfiguration(coordinatorClient.getSiteId(), Constants.BACKUP_SCHEDULER_CONFIG, Constants.GLOBAL_ID);
    if (cfg != null) {
        String succBackupStr = cfg.getConfig(BackupConstants.BACKUP_TAGS_RETAINED);
        if (succBackupStr != null && succBackupStr.length() > 0) {
            splitAndRemoveEmpty(succBackupStr, ",", this.retainedBackups);
        }
        String completedTagsStr = cfg.getConfig(BackupConstants.BACKUP_TAGS_UPLOADED);
        if (completedTagsStr != null && completedTagsStr.length() > 0) {
            splitAndRemoveEmpty(completedTagsStr, ",", this.uploadedBackups);
        }
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 33 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class SchedulerConfig method queryBackupUploadStatus.

/**
 * Query upload status from ZK
 */
public BackupUploadStatus queryBackupUploadStatus() {
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    Configuration cfg = coordinatorClient.queryConfiguration(coordinatorClient.getSiteId(), BackupConstants.BACKUP_UPLOAD_STATUS, Constants.GLOBAL_ID);
    Map<String, String> allItems = (cfg == null) ? new HashMap<String, String>() : cfg.getAllConfigs(false);
    BackupUploadStatus uploadStatus = new BackupUploadStatus(allItems);
    log.info("Upload status is: {}", uploadStatus);
    return uploadStatus;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) BackupUploadStatus(com.emc.vipr.model.sys.backup.BackupUploadStatus) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 34 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class StoragePortProcessor method processResult.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Set<String> protocols = (Set<String>) keyMap.get(Constants.PROTOCOLS);
        _newPortList = new ArrayList<StoragePort>();
        _updatePortList = new ArrayList<StoragePort>();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CoordinatorClient coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
        Set<URI> systemsToRunRPConnectivity = (HashSet<URI>) keyMap.get(Constants.SYSTEMS_RUN_RP_CONNECTIVITY);
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        CIMObjectPath storageAdapterPath = getObjectPathfromCIMArgument(args);
        Iterable<String> adapterItr = Splitter.on(Constants.PATH_DELIMITER_PATTERN).limit(3).split(storageAdapterPath.getKey(Constants.NAME).getValue().toString());
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(device, Iterables.getLast(adapterItr), NativeGUIDGenerator.ADAPTER);
        StorageHADomain haDomain = getStorageAdapter(_dbClient, adapterNativeGuid);
        if (null == haDomain) {
            _logger.info("Adapter Not found");
            return;
        }
        while (it.hasNext()) {
            CIMInstance portInstance = null;
            StoragePort port = null;
            try {
                portInstance = it.next();
                // skip back end ports other than RDF Ports
                if (!HADomainType.REMOTE.name().equalsIgnoreCase(haDomain.getAdapterType()) && BACKEND_PORT.equalsIgnoreCase(getCIMPropertyValue(portInstance, USAGERESTRICTION))) {
                    continue;
                }
                // 2 - Ethernet Port 4 - FC Port
                if (LINKTECHNOLOGY_ETHERNET.equalsIgnoreCase(getCIMPropertyValue(portInstance, LINKTECHNOLOGY))) {
                    port = createStoragePort(null, portInstance, profile, haDomain, false, IP, device);
                    checkProtocolAlreadyExists(protocols, ISCSI);
                    String deviceId = getCIMPropertyValue(portInstance, DEVICEID);
                    /*
                         * For SMI-S 8.x, While getting the iSCSI Port details, we use SystemName property
                         * (Ex. SYMMETRIX-+-<<SERIAL>>-+-SE-1G-+-0)
                         * Where this call just add the deviceId to the KeyMap (i.e SE-1G-+-0).
                         * Hence manually constructing the key.
                         */
                    if (device.getUsingSmis80()) {
                        String systemName = getCIMPropertyValue(portInstance, SYSTEM_NAME);
                        StringBuffer deviceIdStrBuf = new StringBuffer(systemName);
                        deviceIdStrBuf.append(Constants.SMIS80_DELIMITER).append(deviceId);
                        deviceId = deviceIdStrBuf.toString();
                    }
                    _logger.debug("Adding iSCSI Port instance {} to keyMap", deviceId);
                    keyMap.put(deviceId, port);
                    addPath(keyMap, operation.getResult(), portInstance.getObjectPath());
                } else if (LINKTECHNOLOGY_FC.equalsIgnoreCase(getCIMPropertyValue(portInstance, LINKTECHNOLOGY))) {
                    port = checkStoragePortExistsInDB(portInstance, device, _dbClient);
                    checkProtocolAlreadyExists(protocols, FC);
                    createStoragePort(port, portInstance, profile, haDomain, true, FC, device);
                } else {
                    _logger.debug("Unsupported Port : {}", getCIMPropertyValue(portInstance, DEVICEID));
                }
            } catch (Exception e) {
                _logger.warn("Port Discovery failed for {}", getCIMPropertyValue(portInstance, DEVICEID), e);
            }
        }
        _dbClient.createObject(_newPortList);
        _dbClient.persistObject(_updatePortList);
        // ports used later to run Transport Zone connectivity
        List<List<StoragePort>> portsUsedToRunTZoneConnectivity = (List<List<StoragePort>>) keyMap.get(Constants.STORAGE_PORTS);
        portsUsedToRunTZoneConnectivity.add(_newPortList);
        portsUsedToRunTZoneConnectivity.add(_updatePortList);
        List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, _newPortList, _updatePortList);
        for (StoragePool pool : modifiedPools) {
            // pool matcher will be invoked on this pool
            if (!poolsToMatchWithVpool.containsKey(pool.getId())) {
                poolsToMatchWithVpool.put(pool.getId(), pool);
            }
        }
        // Systems used to run RP connectivity later after runing pool matcher
        systemsToRunRPConnectivity.addAll(StoragePoolAssociationHelper.getStorageSytemsFromPorts(_newPortList, null));
        systemsToRunRPConnectivity.addAll(StoragePoolAssociationHelper.getStorageSytemsFromPorts(_updatePortList, null));
        // discovered ports used later to check for not visible ports
        List<StoragePort> discoveredPorts = (List<StoragePort>) keyMap.get(Constants.DISCOVERED_PORTS);
        discoveredPorts.addAll(_newPortList);
        discoveredPorts.addAll(_updatePortList);
        _logger.debug("# Pools used in invoking PoolMatcher during StoragePortProcessor {}", Joiner.on("\t").join(poolsToMatchWithVpool.keySet()));
    } catch (Exception e) {
        _logger.error("Port Discovery failed -->{}", getMessage(e));
    } finally {
        _newPortList = null;
        _updatePortList = null;
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) Iterator(java.util.Iterator) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) CIMObjectPath(javax.cim.CIMObjectPath) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Map(java.util.Map)

Example 35 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class StorageProtocolEndPointProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CoordinatorClient coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        List<StoragePort> newPorts = new ArrayList<StoragePort>();
        List<StoragePort> existingPorts = new ArrayList<StoragePort>();
        while (it.hasNext()) {
            CIMInstance endPointInstance = null;
            StoragePort port = null;
            try {
                endPointInstance = it.next();
                String portInstanceID = endPointInstance.getObjectPath().getKey(SYSTEMNAME).getValue().toString();
                if (device.checkIfVmax3()) {
                    CIMObjectPath logicalPortPath = getObjectPathfromCIMArgument(args);
                    // We need the portInstanceID to not constitute the Virtual information.
                    // i.e Instead of SYMMETRIX-+-<<SERIAL>>-+-115-+-0 it should be SYMMETRIX-+-<<SERIAL>>-+-SE-1G-+-0
                    StringBuffer newPortInstanceID = new StringBuffer(logicalPortPath.getKey(SYSTEMNAME).getValue().toString());
                    newPortInstanceID.append(Constants._plusDelimiter).append(logicalPortPath.getKey(DEVICEID).getValue().toString());
                    portInstanceID = (newPortInstanceID.toString()).replaceAll(Constants.SMIS_PLUS_REGEX, Constants.SMIS80_DELIMITER_REGEX);
                }
                String iScsiPortName = getCIMPropertyValue(endPointInstance, NAME);
                // Skip the iSCSI ports without name or without a valid name.
                if (null == iScsiPortName || iScsiPortName.split(COMMA_STR)[0].length() <= 0) {
                    _logger.warn("Invalid port Name found for {} Skipping", portInstanceID);
                    continue;
                }
                port = checkEthernetStoragePortExistsInDB(iScsiPortName.split(COMMA_STR)[0].toLowerCase(), _dbClient, device);
                createEthernetStoragePort(keyMap, port, endPointInstance, portInstanceID, coordinator, newPorts, existingPorts);
                addPath(keyMap, operation.getResult(), endPointInstance.getObjectPath());
            } catch (Exception e) {
                _logger.warn("SCSI End Point Discovery failed for {}-->{}", "", getMessage(e));
            }
        }
        @SuppressWarnings("unchecked") List<List<StoragePort>> portsUsedToRunNetworkConnectivity = (List<List<StoragePort>>) keyMap.get(Constants.STORAGE_PORTS);
        portsUsedToRunNetworkConnectivity.add(newPorts);
        // discovered ports used later to check for not visible ports
        List<StoragePort> discoveredPorts = (List<StoragePort>) keyMap.get(Constants.DISCOVERED_PORTS);
        discoveredPorts.addAll(newPorts);
        discoveredPorts.addAll(existingPorts);
        List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, newPorts, null);
        for (StoragePool pool : modifiedPools) {
            // pool matcher will be invoked on this pool
            if (!poolsToMatchWithVpool.containsKey(pool.getId())) {
                poolsToMatchWithVpool.put(pool.getId(), pool);
            }
        }
        _logger.debug("# Pools used in invoking PoolMatcher during StorageProtoclEndPoint {}", Joiner.on("\t").join(poolsToMatchWithVpool.keySet()));
    } catch (Exception e) {
        _logger.error("SCSI End Point Discovery failed -->{}", getMessage(e));
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)49 Test (org.junit.Test)11 Base64TokenEncoder (com.emc.storageos.security.authentication.Base64TokenEncoder)8 TokenKeyGenerator (com.emc.storageos.security.authentication.TokenKeyGenerator)8 TokenMaxLifeValuesHolder (com.emc.storageos.security.authentication.TokenMaxLifeValuesHolder)8 Configuration (com.emc.storageos.coordinator.common.Configuration)7 DbClient (com.emc.storageos.db.client.DbClient)7 CassandraTokenManager (com.emc.storageos.auth.impl.CassandraTokenManager)6 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 StorageOSUserDAO (com.emc.storageos.db.client.model.StorageOSUserDAO)6 TokenOnWire (com.emc.storageos.security.authentication.TokenOnWire)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 URI (java.net.URI)5 Service (com.emc.storageos.coordinator.common.Service)4 InterVDCTokenCacheHelper (com.emc.storageos.security.geo.InterVDCTokenCacheHelper)4 ArrayList (java.util.ArrayList)4 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)3 BaseToken (com.emc.storageos.db.client.model.BaseToken)3 ProxyToken (com.emc.storageos.db.client.model.ProxyToken)3 Token (com.emc.storageos.db.client.model.Token)3