Search in sources :

Example 11 with HDSApiExportManager

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

the class HDSExportMaskVolumesValidator method validate.

@Override
public boolean validate() throws Exception {
    log.info("Initiating volumes validation of HDS ExportMask: {}", id);
    try {
        ExportMask exportMask = getExportMask();
        StorageSystem system = getStorage();
        if (exportMask != null && !CollectionUtils.isEmpty(exportMask.getDeviceDataMap())) {
            Set<String> hsdList = exportMask.getDeviceDataMap().keySet();
            HDSApiClient client = getClientFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(system), system.getSmisUserName(), system.getSmisPassword());
            HDSApiExportManager exportManager = client.getHDSApiExportManager();
            String maskName = null;
            String systemObjectID = HDSUtils.getSystemObjectID(system);
            Set<String> volumesInExportMask = new HashSet<>();
            Set<String> initiatorsInExportMask = new HashSet<>();
            if (!CollectionUtils.isEmpty(exportMask.getUserAddedVolumes())) {
                volumesInExportMask.addAll(exportMask.getUserAddedVolumes().keySet());
            }
            if (!CollectionUtils.isEmpty(exportMask.getUserAddedInitiators())) {
                initiatorsInExportMask.addAll(exportMask.getUserAddedInitiators().keySet());
            }
            log.info("Volumes {} in Export Mask {}", volumesInExportMask, exportMask.forDisplay());
            log.info("Initiators {} in Export Mask {}", initiatorsInExportMask, exportMask.forDisplay());
            for (String hsdObjectIdFromDb : hsdList) {
                Set<String> discoveredInitiators = new HashSet<>();
                HostStorageDomain hsd = exportManager.getHostStorageDomain(systemObjectID, hsdObjectIdFromDb);
                if (null == hsd) {
                    continue;
                }
                maskName = (null == hsd.getName()) ? hsd.getNickname() : hsd.getName();
                // Get initiators from storage system
                discoveredInitiators.addAll(HDSUtils.getInitiatorsFromHSD(hsd));
                log.info("Initiators {} discovered from array for the HSD {}", discoveredInitiators, maskName);
                Set<String> additionalInitiatorsOnArray = Sets.difference(discoveredInitiators, initiatorsInExportMask);
                if (!CollectionUtils.isEmpty(additionalInitiatorsOnArray)) {
                    getValidatorLogger().logDiff(String.format("%s - %s", id, maskName), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, Joiner.on("\t").join(additionalInitiatorsOnArray));
                }
            }
            checkForErrors();
        }
    } catch (Exception ex) {
        log.error("Unexpected exception validating ExportMask volumes: " + ex.getMessage(), ex);
        if (getValidatorConfig().isValidationEnabled()) {
            throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask volumes: " + ex.getMessage());
        }
    }
    return true;
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ExportMask(com.emc.storageos.db.client.model.ExportMask) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 12 with HDSApiExportManager

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

the class HDSProtectionOperations method removeDummyLunPath.

/**
 * Removes Dummy Lun Path from Secondary Volume
 *
 * @param storageSystem
 * @param blockObjectURI
 * @throws Exception
 */
public void removeDummyLunPath(StorageSystem storageSystem, URI blockObjectURI) throws Exception {
    log.info("Started dummy lun path removal from secondary volume");
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    // Volume volume=dbClient.queryObject(Volume.class, volumeURI);
    BlockObject blockObj = BlockObject.fetch(dbClient, blockObjectURI);
    String dummyLunPathId = getDummyHSDPathId(storageSystem, blockObj);
    if (dummyLunPathId != null) {
        apiExportManager.deleteLunPathsFromSystem(systemObjectId, Arrays.asList(dummyLunPathId), storageSystem.getModel());
        log.info("Deleted Dummy Lun path from secondary volume");
    } else {
        log.info("Dummy lun path has been removed already");
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 13 with HDSApiExportManager

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

the class HDSProtectionOperations method getDummyHSDPathId.

/**
 * Get Dummy Lun Path's path objectID
 *
 * @param storageSystem
 * @param volume
 * @return
 * @throws Exception
 */
private String getDummyHSDPathId(StorageSystem storageSystem, BlockObject blockObj) throws Exception {
    String dummyLunPathId = null;
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    List<HostStorageDomain> hsdList = apiExportManager.getHostStorageDomains(systemObjectId);
    if (hsdList != null) {
        for (HostStorageDomain hsd : hsdList) {
            if (hsd != null && HDSConstants.DUMMY_HSD.equalsIgnoreCase(hsd.getNickname())) {
                if (hsd.getPathList() != null) {
                    for (Path path : hsd.getPathList()) {
                        if (path.getDevNum().equalsIgnoreCase(blockObj.getNativeId())) {
                            dummyLunPathId = path.getObjectID();
                            log.info("Found secondary volume's dummy lun path id :{}", dummyLunPathId);
                            return dummyLunPathId;
                        }
                    }
                }
            }
        }
    }
    log.info("Dummy lun path has been removed already for this secondary volume");
    return dummyLunPathId;
}
Also used : Path(com.emc.storageos.hds.model.Path) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager)

Aggregations

HDSApiExportManager (com.emc.storageos.hds.api.HDSApiExportManager)13 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)12 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 ExportMask (com.emc.storageos.db.client.model.ExportMask)9 HDSException (com.emc.storageos.hds.HDSException)7 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 Path (com.emc.storageos.hds.model.Path)4 HashMap (java.util.HashMap)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 Initiator (com.emc.storageos.db.client.model.Initiator)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 ExportMaskValidationContext (com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext)3 AbstractHDSValidator (com.emc.storageos.volumecontroller.impl.validators.hds.AbstractHDSValidator)3 URI (java.net.URI)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 List (java.util.List)2