Search in sources :

Example 26 with HDSApiClient

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

the class HDSExportMaskInitiatorsValidator method validate.

@Override
public boolean validate() throws Exception {
    log.info("Initiating initiators 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> discoveredVolumes = new HashSet<>();
                HostStorageDomain hsd = exportManager.getHostStorageDomain(systemObjectID, hsdObjectIdFromDb);
                if (null == hsd) {
                    continue;
                }
                maskName = (null == hsd.getName()) ? hsd.getNickname() : hsd.getName();
                // Get volumes and initiators from storage system
                discoveredVolumes.addAll(HDSUtils.getVolumesFromHSD(hsd, system).keySet());
                log.info("Volumes {} discovered from array for the HSD {}", discoveredVolumes, maskName);
                Set<String> additionalVolumesOnArray = Sets.difference(discoveredVolumes, volumesInExportMask);
                if (!CollectionUtils.isEmpty(additionalVolumesOnArray)) {
                    getValidatorLogger().logDiff(String.format("%s - %s", id, maskName), "volumes", ValidatorLogger.NO_MATCHING_ENTRY, Joiner.on("\t").join(additionalVolumesOnArray));
                }
            }
            checkForErrors();
        }
    } catch (Exception ex) {
        log.error("Unexpected exception validating ExportMask initiators: " + ex.getMessage(), ex);
        if (getValidatorConfig().isValidationEnabled()) {
            throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask initiators: " + 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 27 with HDSApiClient

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

the class HDSExportMaskValidator method validate.

@Override
public boolean validate() throws Exception {
    log.info("Initiating 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<>();
                Set<String> discoveredVolumes = new HashSet<>();
                HostStorageDomain hsd = exportManager.getHostStorageDomain(systemObjectID, hsdObjectIdFromDb);
                if (null == hsd) {
                    continue;
                }
                maskName = (null == hsd.getName()) ? hsd.getNickname() : hsd.getName();
                // Get volumes and initiators from storage system
                discoveredVolumes.addAll(HDSUtils.getVolumesFromHSD(hsd, system).keySet());
                discoveredInitiators.addAll(HDSUtils.getInitiatorsFromHSD(hsd));
                log.info("Volumes {} discovered from array for the HSD {}", discoveredVolumes, maskName);
                log.info("Initiators {} discovered from array for the HSD {}", discoveredInitiators, maskName);
                Set<String> additionalVolumesOnArray = Sets.difference(discoveredVolumes, volumesInExportMask);
                Set<String> additionalInitiatorsOnArray = Sets.difference(discoveredInitiators, initiatorsInExportMask);
                if (!CollectionUtils.isEmpty(additionalVolumesOnArray)) {
                    getValidatorLogger().logDiff(String.format("%s - %s", id, maskName), "volumes", ValidatorLogger.NO_MATCHING_ENTRY, Joiner.on("\t").join(additionalVolumesOnArray));
                }
                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 initiators: " + ex.getMessage(), ex);
        if (getValidatorConfig().isValidationEnabled()) {
            throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask initiators: " + 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 28 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient 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 29 with HDSApiClient

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

the class HDSMetaVolumeOperations method expandVolumeAsMetaVolume.

@Override
public void expandVolumeAsMetaVolume(StorageSystem storageSystem, StoragePool storagePool, Volume metaHead, List<String> newMetaMembers, String metaType, MetaVolumeTaskCompleter metaVolumeTaskCompleter) throws Exception {
    HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    LogicalUnit metaHeadVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(metaHead.getNativeId(), storageSystem));
    String metaHeadLdevId = null;
    List<String> metaMembersLdevObjectIds = new ArrayList<String>();
    // Step 1: Get LDEV id's of the meta members and format them
    if (null != newMetaMembers && !newMetaMembers.isEmpty()) {
        for (String metaMember : newMetaMembers) {
            if (null != metaMember) {
                String asyncTaskMessageId = hdsApiClient.formatLogicalUnit(systemObjectID, metaMember);
                if (asyncTaskMessageId == null) {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the expand volume call");
                }
                HDSJob formatLUJob = new HDSJob(asyncTaskMessageId, storageSystem.getId(), metaVolumeTaskCompleter.getVolumeTaskCompleter(), "formatLogicalUnit");
                invokeMethodSynchronously(hdsApiFactory, asyncTaskMessageId, formatLUJob);
            }
            LogicalUnit metaMemberVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, metaMember);
            if (null != metaMemberVolume && !metaMemberVolume.getLdevList().isEmpty()) {
                for (LDEV ldev : metaMemberVolume.getLdevList()) {
                    // Format the logical unit. This is synchronous operation
                    // should wait it the operation completes.
                    metaMembersLdevObjectIds.add(ldev.getObjectID());
                }
            }
        }
    }
    log.info("New Meta member LDEV ids: {}", metaMembersLdevObjectIds);
    // Step 2: Get LDEV id of the meta volume head.
    if (null != metaHeadVolume && null != metaHeadVolume.getLdevList()) {
        for (LDEV ldev : metaHeadVolume.getLdevList()) {
            // will be created during expansion of volume.
            if (getLDEVID(ldev.getObjectID()).equalsIgnoreCase(metaHead.getNativeId())) {
                metaHeadLdevId = ldev.getObjectID();
                break;
            }
        }
    }
    // Step 3: Create LUSE Volume using metaHead LDEV & meta
    // members LDEV Ids.
    LogicalUnit logicalUnit = hdsApiClient.createLUSEVolume(systemObjectID, metaHeadLdevId, metaMembersLdevObjectIds);
    if (null != logicalUnit) {
        long capacityInBytes = Long.valueOf(logicalUnit.getCapacityInKB()) * 1024L;
        metaHead.setProvisionedCapacity(capacityInBytes);
        metaHead.setAllocatedCapacity(capacityInBytes);
        dbClient.persistObject(metaHead);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) LDEV(com.emc.storageos.hds.model.LDEV)

Example 30 with HDSApiClient

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

the class HDSMetaVolumeOperations method createMetaVolumeMembers.

/**
 * Create meta volume member devices. These devices provide capacity to meta volume.
 *
 * @param storageSystem
 * @param storagePool
 * @param metaHead
 * @param memberCount
 * @param memberCapacity
 * @param metaVolumeTaskCompleter
 * @return list of native ids of meta member devices
 * @throws Exception
 */
@Override
public List<String> createMetaVolumeMembers(StorageSystem storageSystem, StoragePool storagePool, Volume metaHead, int memberCount, long memberCapacity, MetaVolumeTaskCompleter metaVolumeTaskCompleter) throws Exception {
    log.info(String.format("Create Meta Volume Members Start - Array: %s, Pool: %s, %n Volume: %s, Count:%s, Member capacity: %s", storageSystem.getSerialNumber(), storagePool.getNativeId(), metaHead.getLabel(), memberCount, memberCapacity));
    try {
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        String poolObjectID = HDSUtils.getPoolObjectID(storagePool);
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        // commenting this to rever the fix.
        // Integer ldevIdToUse = getLDEVNumberToCreateMetaMembers(hdsApiClient, systemObjectID);
        String asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, memberCapacity, memberCount, "", VOLUME_FORMAT_TYPE, storageSystem.getModel(), null);
        if (asyncTaskMessageId == null) {
            throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
        }
        HDSCreateMetaVolumeMembersJob metaVolumeMembersJob = new HDSCreateMetaVolumeMembersJob(asyncTaskMessageId, storageSystem.getId(), metaHead, memberCount, metaVolumeTaskCompleter);
        invokeMethodSynchronously(hdsApiFactory, asyncTaskMessageId, metaVolumeMembersJob);
        return metaVolumeMembersJob.getMetaMembers();
    } catch (Exception e) {
        log.error("Problem in createMetaVolumeMembers: ", e);
        ServiceError error = DeviceControllerErrors.hds.methodFailed("createMetaVolumeMemebers", e.getMessage());
        metaVolumeTaskCompleter.getVolumeTaskCompleter().error(dbClient, error);
        throw e;
    } finally {
        log.info(String.format("Create Meta Volume Members End - Array: %s, Pool: %s, %n Volume: %s", storageSystem.getSerialNumber(), storagePool.getNativeId(), metaHead.getLabel()));
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSCreateMetaVolumeMembersJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateMetaVolumeMembersJob) 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