Search in sources :

Example 1 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSVolumeDiscoverer method discoverUnManagedVolumes.

public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
    List<UnManagedVolume> newUnManagedVolumeList = new ArrayList<UnManagedVolume>();
    List<UnManagedVolume> updateUnManagedVolumeList = new ArrayList<UnManagedVolume>();
    Set<URI> allDiscoveredUnManagedVolumes = new HashSet<URI>();
    HDSApiVolumeManager volumeManager = hdsApiClient.getHDSApiVolumeManager();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    List<LogicalUnit> luList = volumeManager.getAllLogicalUnits(systemObjectId);
    if (null != luList && !luList.isEmpty()) {
        log.info("Processing {} volumes received from HiCommand server.", luList.size());
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        HashMap<String, StoragePool> pools = new HashMap<String, StoragePool>();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
            pools.put(storagePool.getNativeGuid(), storagePool);
        }
        for (LogicalUnit logicalUnit : luList) {
            log.info("Processing LogicalUnit: {}", logicalUnit.getObjectID());
            UnManagedVolume unManagedVolume = null;
            String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
            if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
                log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
            }
            String unManagedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
            unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNativeGuid);
            boolean unManagedVolumeExists = (null != unManagedVolume) ? true : false;
            StoragePool storagePool = getStoragePoolOfUnManagedVolume(logicalUnit, storageSystem, pools, dbClient);
            if (null != storagePool) {
                if (!unManagedVolumeExists) {
                    unManagedVolume = createUnManagedVolume(unManagedVolumeNativeGuid, logicalUnit, storageSystem, storagePool, dbClient);
                    newUnManagedVolumeList.add(unManagedVolume);
                } else {
                    updateUnManagedVolumeInfo(logicalUnit, storageSystem, storagePool, unManagedVolume, dbClient);
                    updateUnManagedVolumeList.add(unManagedVolume);
                }
                allDiscoveredUnManagedVolumes.add(unManagedVolume.getId());
            } else {
                log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", logicalUnit.getObjectID());
            }
            performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, Constants.DEFAULT_PARTITION_SIZE);
        }
        performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, 0);
        // Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
        DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allDiscoveredUnManagedVolumes, dbClient, partitionManager);
    } else {
        log.info("No volumes retured by HiCommand Server for system {}", storageSystem.getId());
    }
}
Also used : HDSApiVolumeManager(com.emc.storageos.hds.api.HDSApiVolumeManager) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSCloneOperations method createSingleClone.

/**
 * 1. Find ReplicationGroup objId from Device Manager
 * 2. Check dummy Host Group available on Storage System. if not available create a dummy Host Group name.
 * 3. Create a secondary volume and add dummy host group on it.
 * 4. create a SI pair
 *
 * Note that if createInactive is false, then a subsequent step in the
 * full copy creation workflow will do a wait for synchronization. This
 * will split the pair, which makes the clone active.
 *
 * @param storageSystem {@link StorageSystem}
 * @param sourceVolumeURI {@link URI}
 * @param cloneVolumeURI {@link URI}
 * @param createInactive {@link Boolean}
 * @param taskCompleter {@link TaskCompleter}
 */
@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceVolumeURI, URI cloneVolumeURI, Boolean createInactive, TaskCompleter taskCompleter) {
    log.info("START createSingleClone operation");
    Volume cloneVolume = null;
    try {
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
        String replicationGroupObjectID = hdsApiClient.getHdsApiProtectionManager().getReplicationGroupObjectId();
        if (replicationGroupObjectID == null) {
            log.error("Unable to find replication group information/pair management server for pair configuration");
            throw HDSException.exceptions.replicationGroupNotAvailable();
        }
        cloneVolume = dbClient.queryObject(Volume.class, cloneVolumeURI);
        hdsProtectionOperations.createSecondaryVolumeForClone(storageSystem, sourceVolumeURI, cloneVolume);
        // Need to fetch clone volume from db to get volume's nativeId
        cloneVolume = dbClient.queryObject(Volume.class, cloneVolumeURI);
        hdsProtectionOperations.addDummyLunPath(hdsApiClient, cloneVolume);
        BlockObject source = BlockObject.fetch(dbClient, sourceVolumeURI);
        String pairName = hdsProtectionOperations.generatePairName(source, cloneVolume);
        log.info("Pair Name :{}", pairName);
        ReplicationInfo replicationInfo = hdsApiProtectionManager.createShadowImagePair(replicationGroupObjectID, pairName, HDSUtils.getSystemArrayType(storageSystem), HDSUtils.getSystemSerialNumber(storageSystem), source.getNativeId(), cloneVolume.getNativeId(), storageSystem.getModel());
        log.info("Replication Info object :{}", replicationInfo.toXMLString());
        log.info("createInactive :{}", createInactive);
        cloneVolume.setSyncActive(false);
        cloneVolume.setReplicaState(ReplicationState.INACTIVE.name());
        dbClient.persistObject(cloneVolume);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceVolumeURI, cloneVolumeURI);
        log.error(errorMsg, e);
        Volume clone = dbClient.queryObject(Volume.class, cloneVolumeURI);
        if (clone != null) {
            clone.setInactive(true);
            dbClient.persistObject(clone);
        }
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 3 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSExportOperations method removeInitiators.

@Override
public void removeInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<Initiator> initiators, List<URI> targets, TaskCompleter taskCompleter) throws DeviceControllerException {
    long startTime = System.currentTimeMillis();
    log.info("{} removeInitiator START...", storage.getSerialNumber());
    try {
        log.info("removeInitiator: Export mask id: {}", exportMaskURI);
        if (volumeURIList != null) {
            log.info("removeInitiator: volumes : {}", Joiner.on(',').join(volumeURIList));
        }
        log.info("removeInitiator: initiators : {}", Joiner.on(',').join(initiators));
        log.info("removeInitiator: targets : {}", Joiner.on(',').join(targets));
        if (null == initiators || initiators.isEmpty()) {
            log.info("No initiators found to remove {}", exportMaskURI);
            taskCompleter.ready(dbClient);
            return;
        }
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        // Get the context from the task completer, in case this is a rollback.
        boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
        ExportMaskValidationContext ctx = new ExportMaskValidationContext();
        ctx.setStorage(storage);
        ctx.setExportMask(exportMask);
        ctx.setBlockObjects(volumeURIList, dbClient);
        ctx.setInitiators(initiators);
        // Allow exceptions to be thrown when not rolling back
        ctx.setAllowExceptions(!isRollback);
        AbstractHDSValidator removeInitiatorFromMaskValidator = (AbstractHDSValidator) validator.removeInitiators(ctx);
        removeInitiatorFromMaskValidator.validate();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
        String systemObjectID = HDSUtils.getSystemObjectID(storage);
        StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
        if (null != deviceDataMap && !deviceDataMap.isEmpty()) {
            Set<String> hsdObjectIDSet = deviceDataMap.keySet();
            for (String hsdObjectID : hsdObjectIDSet) {
                HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectID);
                if (null == hsd) {
                    log.warn("Not able to remove initiators as HSD {} couldn't find on array.", hsdObjectID);
                    continue;
                }
                List<String> fcInitiators = getFCInitiatorsExistOnHSD(hsd, initiators);
                List<String> iSCSIInitiators = getISCSIInitiatorsExistOnHSD(hsd, initiators);
                boolean isLastFCInitiator = (fcInitiators.size() == 1 && null != hsd.getWwnList() && hsd.getWwnList().size() == fcInitiators.size());
                boolean isLastISCSIInitiator = (iSCSIInitiators.size() == 1 && null != hsd.getIscsiList() && hsd.getIscsiList().size() == iSCSIInitiators.size());
                // If Initiator is last one, remove the HSD
                if (isLastFCInitiator || isLastISCSIInitiator) {
                    exportMgr.deleteHostStorageDomain(systemObjectID, hsd.getObjectID(), storage.getModel());
                    exportMask.getDeviceDataMap().remove(hsd.getObjectID());
                } else {
                    if (null != fcInitiators && !fcInitiators.isEmpty()) {
                        // remove FC initiators from HSD.
                        exportMgr.deleteWWNsFromHostStorageDomain(systemObjectID, hsd.getObjectID(), fcInitiators, storage.getModel());
                    }
                    if (null != iSCSIInitiators && !iSCSIInitiators.isEmpty()) {
                        // remove ISCSInames from HSD.
                        exportMgr.deleteISCSIsFromHostStorageDomain(systemObjectID, hsd.getObjectID(), iSCSIInitiators, storage.getModel());
                    }
                }
            }
            dbClient.updateObject(exportMask);
            // update the task status after processing all HSD's.
            taskCompleter.ready(dbClient);
        } else {
            log.info("No Host groups found on exportMask {}", exportMaskURI);
            // No HSD's found in exportMask.
            taskCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error(String.format("removeInitiator failed - maskURI: %s", exportMaskURI.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailedOpMsg(ResourceOperationTypeEnum.DELETE_EXPORT_INITIATOR.getName(), e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        long totalTime = System.currentTimeMillis() - startTime;
        log.info(String.format("findExportMasks took %f seconds", (double) totalTime / (double) 1000));
    }
    log.info("{} removeInitiator END...", storage.getSerialNumber());
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) AbstractHDSValidator(com.emc.storageos.volumecontroller.impl.validators.hds.AbstractHDSValidator) ExportMask(com.emc.storageos.db.client.model.ExportMask) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain)

Example 4 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSExportOperations method removeVolumes.

@Override
public void removeVolumes(StorageSystem storage, URI exportMaskURI, List<URI> volumes, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("{} removeVolumes START...", storage.getSerialNumber());
    try {
        log.info("removeVolumes: Export mask id: {}", exportMaskURI);
        log.info("removeVolumes: volumes: {}", Joiner.on(',').join(volumes));
        if (initiatorList != null) {
            log.info("removeVolumes: impacted initiators: {}", Joiner.on(",").join(initiatorList));
        }
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
        String systemObjectID = HDSUtils.getSystemObjectID(storage);
        ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        if (CollectionUtils.isEmpty(exportMask.getDeviceDataMap())) {
            log.info("HSD's are not found in the exportMask {} device DataMap.", exportMask.getId());
            taskCompleter.ready(dbClient);
        }
        // Get the context from the task completer, in case this is a rollback.
        boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(taskCompleter.getOpId());
        ExportMaskValidationContext ctx = new ExportMaskValidationContext();
        ctx.setStorage(storage);
        ctx.setExportMask(exportMask);
        ctx.setBlockObjects(volumes, dbClient);
        ctx.setInitiators(initiatorList);
        // Allow exceptions to be thrown when not rolling back
        ctx.setAllowExceptions(!isRollback);
        AbstractHDSValidator removeVolumeFromMaskValidator = (AbstractHDSValidator) validator.removeVolumes(ctx);
        removeVolumeFromMaskValidator.validate();
        StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
        Set<String> hsdList = deviceDataMap.keySet();
        List<Path> pathObjectIdList = new ArrayList<Path>();
        if (null == hsdList || hsdList.isEmpty()) {
            throw HDSException.exceptions.notAbleToFindHostStorageDomain(systemObjectID);
        }
        if (null != exportMask && !exportMask.getInactive()) {
            for (String hsdObjectId : hsdList) {
                HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectId);
                if (null == hsd) {
                    log.warn("Couldn't find the HSD {} to remove volume from ExportMask", hsdObjectId);
                    continue;
                }
                if (null != hsd.getPathList() && !hsd.getPathList().isEmpty()) {
                    pathObjectIdList.addAll(getPathObjectIdsFromHsd(hsd, volumes));
                }
            }
            if (!pathObjectIdList.isEmpty()) {
                hdsApiClient.getHDSBatchApiExportManager().deleteLUNPathsFromStorageSystem(systemObjectID, pathObjectIdList, storage.getModel());
            } else {
                log.info("No volumes found on system: {}", systemObjectID);
            }
        }
        // Update the status after deleting the volume from all HSD's.
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        log.error(String.format("removeVolume failed - maskURI: %s", exportMaskURI.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} removeVolumes END...", storage.getSerialNumber());
}
Also used : Path(com.emc.storageos.hds.model.Path) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) AbstractHDSValidator(com.emc.storageos.volumecontroller.impl.validators.hds.AbstractHDSValidator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain)

Example 5 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSExportOperations method findExportMasks.

@Override
public Map<String, Set<URI>> findExportMasks(StorageSystem storage, List<String> initiatorNames, boolean mustHaveAllPorts) throws DeviceControllerException {
    Map<String, Set<URI>> matchingMasks = new HashMap<String, Set<URI>>();
    log.info("finding export masks for storage {}", storage.getId());
    String systemObjectID = HDSUtils.getSystemObjectID(storage);
    Map<URI, Set<HostStorageDomain>> matchedHostHSDsMap = new HashMap<URI, Set<HostStorageDomain>>();
    Map<URI, Set<URI>> hostToInitiatorMap = new HashMap<URI, Set<URI>>();
    Map<URI, Set<String>> matchedHostInitiators = new HashMap<URI, Set<String>>();
    try {
        HDSApiClient client = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        HDSApiExportManager exportManager = client.getHDSApiExportManager();
        List<HostStorageDomain> hsdList = exportManager.getHostStorageDomains(systemObjectID);
        for (HostStorageDomain hsd : hsdList) {
            List<String> initiatorsExistsOnHSD = getInitiatorsExistsOnHSD(hsd.getWwnList(), hsd.getIscsiList());
            // Find out if the port is in this masking container
            for (String initiatorName : initiatorNames) {
                String normalizedName = initiatorName.replace(HDSConstants.COLON, HDSConstants.DOT_OPERATOR);
                if (initiatorsExistsOnHSD.contains(normalizedName)) {
                    log.info("Found a matching HSD for {}", initiatorName);
                    Initiator initiator = fetchInitiatorByName(initiatorName);
                    Set<HostStorageDomain> matchedHSDs = matchedHostHSDsMap.get(initiator.getHost());
                    if (matchedHSDs == null) {
                        matchedHSDs = new HashSet<HostStorageDomain>();
                        matchedHostHSDsMap.put(initiator.getHost(), matchedHSDs);
                    }
                    matchedHSDs.add(hsd);
                    Set<String> matchedInitiators = matchedHostInitiators.get(initiator.getHost());
                    if (null == matchedInitiators) {
                        matchedInitiators = new HashSet<String>();
                        matchedHostInitiators.put(initiator.getHost(), matchedInitiators);
                    }
                    matchedInitiators.add(initiatorName);
                }
            }
        }
        hsdList.clear();
        log.info("matchedHSDs: {}", matchedHostHSDsMap);
        log.info("initiatorURIToNameMap: {}", matchedHostInitiators);
        processInitiators(initiatorNames, hostToInitiatorMap);
        List<URI> activeMaskIdsInDb = dbClient.queryByType(ExportMask.class, true);
        List<ExportMask> activeMasks = dbClient.queryObject(ExportMask.class, activeMaskIdsInDb);
        if (null != matchedHostHSDsMap && !matchedHostHSDsMap.isEmpty()) {
            // Iterate through each host
            for (URI hostURI : hostToInitiatorMap.keySet()) {
                Set<URI> hostInitiators = hostToInitiatorMap.get(hostURI);
                boolean isNewExportMask = false;
                // Create single ExportMask for each host-varray combination
                List<ExportMask> exportMaskWithHostInitiators = fetchExportMasksFromDB(activeMasks, hostInitiators, storage);
                Set<HostStorageDomain> hsds = matchedHostHSDsMap.get(hostURI);
                if (!CollectionUtils.isEmpty(hsds)) {
                    for (HostStorageDomain hsd : hsds) {
                        String storagePortOFHDSURI = getStoragePortURIs(Arrays.asList(hsd.getPortID()), storage).get(0);
                        ExportMask maskForHSD = null;
                        for (ExportMask exportMaskhavingInitiators : exportMaskWithHostInitiators) {
                            if (exportMaskhavingInitiators.getStoragePorts().contains(storagePortOFHDSURI)) {
                                maskForHSD = exportMaskhavingInitiators;
                                break;
                            }
                        }
                        if (null == maskForHSD) {
                            // first get the varrays associated with the storage port of the HSD and then check if
                            // any of the export masks have storage ports, which have virtual arrays overlapping with the virtual
                            // arrays of the HSD storage port
                            // NOTE: If the storageport is assigned to multiple varrays, then maintaining one
                            // export mask per varray is not possible. Proper seggregation has to be done.
                            StringSet varraysAssociatedWithHSDStoragePort = getTaggedVarrays(storagePortOFHDSURI);
                            if (!varraysAssociatedWithHSDStoragePort.isEmpty()) {
                                boolean bMaskFound = false;
                                for (ExportMask exportMaskhavingInitiators : exportMaskWithHostInitiators) {
                                    for (String storagePortUriIter : exportMaskhavingInitiators.getStoragePorts()) {
                                        // get the storage port entity
                                        StringSet varraysOfStoragePort = getTaggedVarrays(storagePortUriIter);
                                        if (StringSetUtil.hasIntersection(varraysOfStoragePort, varraysAssociatedWithHSDStoragePort)) {
                                            maskForHSD = exportMaskhavingInitiators;
                                            // Ingest the foreign HSD into a matching export mask with same host and varray combination
                                            bMaskFound = true;
                                            break;
                                        }
                                    }
                                    if (bMaskFound) {
                                        break;
                                    }
                                }
                            } else {
                                // Since this HSD port is not tagged to any varray, we will not ingest it
                                continue;
                            }
                            if (null == maskForHSD) {
                                // No matching export mask found for the same host and varray combination. Creating a new export mask.
                                isNewExportMask = true;
                                maskForHSD = new ExportMask();
                                maskForHSD.setId(URIUtil.createId(ExportMask.class));
                                maskForHSD.setStorageDevice(storage.getId());
                                maskForHSD.setCreatedBySystem(false);
                            }
                        }
                        Set<HostStorageDomain> hsdSet = new HashSet<>();
                        hsdSet.add(hsd);
                        updateHSDInfoInExportMask(maskForHSD, hostInitiators, hsdSet, storage, matchingMasks);
                        if (isNewExportMask) {
                            dbClient.createObject(maskForHSD);
                            exportMaskWithHostInitiators.add(maskForHSD);
                        } else {
                            ExportMaskUtils.sanitizeExportMaskContainers(dbClient, maskForHSD);
                            dbClient.updateObject(maskForHSD);
                        }
                        updateMatchingMasksForHost(matchedHostInitiators.get(hostURI), maskForHSD, matchingMasks);
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error("Error when attempting to query LUN masking information", e);
        throw HDSException.exceptions.queryExistingMasksFailure(e.getMessage());
    }
    log.info("Found matching masks: {}", matchingMasks);
    return matchingMasks;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) URI(java.net.URI) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) HashSet(java.util.HashSet) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Aggregations

HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)45 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)26 HDSException (com.emc.storageos.hds.HDSException)26 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)21 Volume (com.emc.storageos.db.client.model.Volume)14 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)13 HDSApiExportManager (com.emc.storageos.hds.api.HDSApiExportManager)12 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)12 ArrayList (java.util.ArrayList)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 HashSet (java.util.HashSet)11 ExportMask (com.emc.storageos.db.client.model.ExportMask)10 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)10 URI (java.net.URI)10 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)9 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)8 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)6