Search in sources :

Example 1 with SmisCreateMultiVolumeJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob in project coprhd-controller by CoprHD.

the class SmisStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(final StorageSystem storageSystem, final StoragePool storagePool, final String opId, final List<Volume> volumes, final VirtualPoolCapabilityValuesWrapper capabilities, final TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    Long thinVolumePreAllocationSize = null;
    CIMInstance poolSetting = null;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    StorageSystem forProvider = _helper.getStorageSystemForProvider(storageSystem, volumes.get(0));
    // volumeGroupObjectPath is required for VMAX3
    CIMObjectPath volumeGroupObjectPath = _helper.getVolumeGroupPath(forProvider, storageSystem, volumes.get(0), storagePool);
    List<String> volumeLabels = new ArrayList<>();
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
        String tenantName = "";
        try {
            TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
            tenantName = tenant.getLabel();
        } catch (DatabaseException e) {
            _log.error("Error lookup TenantOrb object", e);
        }
        label = _nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
        volumeLabels.add(label);
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
        if (thinVolumePreAllocationSize == null && volume.getThinVolumePreAllocationSize() > 0) {
            thinVolumePreAllocationSize = volume.getThinVolumePreAllocationSize();
        }
    }
    _log.info(logMsgBuilder.toString());
    boolean isThinlyProvisioned = volumes.get(0).getThinlyProvisioned();
    try {
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        CIMArgument[] inArgs = null;
        // I didn't find any ways to add this branching logic based on device Types.
        if (DiscoveredDataObject.Type.vnxblock.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
            String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volumes.get(0).getId(), _dbClient);
            if (autoTierPolicyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            }
            inArgs = _helper.getCreateVolumesInputArgumentsOnFastEnabledPool(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, autoTierPolicyName);
        } else {
            if (!storageSystem.checkIfVmax3() && isThinlyProvisioned && null != thinVolumePreAllocationSize) {
                poolSetting = _smisStorageDevicePreProcessor.createStoragePoolSetting(storageSystem, storagePool, thinVolumePreAllocationSize);
            }
            if (storageSystem.checkIfVmax3()) {
                inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, true, volumeGroupObjectPath, (null != thinVolumePreAllocationSize));
            } else {
                inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, poolSetting, true);
            }
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(forProvider, configSvcPath, _helper.createVolumesMethodName(forProvider), inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            SmisJob createSmisJob = volumes.size() > 1 ? new SmisCreateMultiVolumeJob(job, forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter) : new SmisCreateVolumeJob(job, forProvider.getId(), storagePool.getId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(createSmisJob));
        }
    } catch (final InternalException e) {
        _log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(_dbClient, e);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            _dbClient.updateObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) SmisCreateVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateVolumeJob) Volume(com.emc.storageos.db.client.model.Volume) SmisCreateMultiVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 2 with SmisCreateMultiVolumeJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob in project coprhd-controller by CoprHD.

the class SmisMetaVolumeOperations method createMetaVolumes.

/**
 * Create meta volumes.
 *
 * @param storageSystem storageSystem
 * @param metaHead meta head
 * @param metaMembers list of native ids of meta volume members (not including meta head)
 * @param metaType meta volume type to create, concatenate or stripe
 * @param capabilities capabilities
 * @param metaVolumeTaskCompleter task completer
 */
/**
 * Create meta volumes
 *
 * @param storageSystem
 * @param storagePool
 * @param volumes
 * @param capabilities
 * @param taskCompleter
 * @throws Exception
 */
@Override
public void createMetaVolumes(StorageSystem storageSystem, StoragePool storagePool, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws Exception {
    String label = null;
    Volume volume = volumes.get(0);
    // We don't need a label when we are to create more than
    // one volume. In fact we can't set the label in this
    // case for VMAX, else the request will fail.
    // TODO there is a bug in smis --- the request to element composition service fails when name is set even for a single volume.
    // todo: the opt 450103 was opened on 05/30
    Long capacity = volume.getTotalMetaMemberCapacity();
    Integer metaMemberCount = volume.getMetaMemberCount();
    String metaVolumeType = volume.getCompositionType();
    boolean opCreationFailed = false;
    try {
        CIMObjectPath elementCompositionServicePath = _cimPath.getElementCompositionSvcPath(storageSystem);
        boolean isThinlyProvisioned = volume.getThinlyProvisioned();
        _log.info(String.format("Create Meta Volumes Start - Array: %s, Count: %s, MetaType: %s", storageSystem.getSerialNumber(), volumes.size(), metaVolumeType));
        CIMArgument[] inArgs;
        CIMInstance poolSetting = null;
        // set preallocate size if needed
        if (isThinlyProvisioned && volume.getThinVolumePreAllocationSize() > 0) {
            poolSetting = _smisStorageDevicePreProcessor.createStoragePoolSetting(storageSystem, storagePool, volume.getThinVolumePreAllocationSize());
        }
        inArgs = _helper.getCreateMetaVolumesInputArguments(storageSystem, storagePool, label, capacity, volumes.size(), isThinlyProvisioned, metaVolumeType, metaMemberCount, poolSetting);
        CIMArgument[] outArgs = new CIMArgument[5];
        StorageSystem forProvider = _helper.getStorageSystemForProvider(storageSystem, volume);
        _log.info("Selected Provider : {}", forProvider.getNativeGuid());
        // can not invoke async --- cimPath is not serializable
        // todo: before opt 450103 is fixed always use multi-volume job
        SmisAbstractCreateVolumeJob smisJobCompleter = new SmisCreateMultiVolumeJob(null, forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter);
        // SmisAbstractCreateVolumeJob smisJobCompleter = volumes.size() > 1 ? new SmisCreateMultiVolumeJob(null,
        // forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter)
        // : new SmisCreateVolumeJob(null, forProvider.getId(), storagePool.getId(),
        // taskCompleter);
        smisJobCompleter.setCimPath(_cimPath);
        _helper.invokeMethodSynchronously(forProvider, elementCompositionServicePath, SmisConstants.CREATE_OR_MODIFY_COMPOSITE_ELEMENT, inArgs, outArgs, smisJobCompleter);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Problem in createMetaVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("createMetaVolumes", e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            _dbClient.persistObject(vol);
        }
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create meta volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume vol : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", vol.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) SmisCreateMultiVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob) SmisAbstractCreateVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisAbstractCreateVolumeJob) CIMArgument(javax.cim.CIMArgument) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 Volume (com.emc.storageos.db.client.model.Volume)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 SmisCreateMultiVolumeJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob)2 CIMArgument (javax.cim.CIMArgument)2 CIMInstance (javax.cim.CIMInstance)2 CIMObjectPath (javax.cim.CIMObjectPath)2 WBEMException (javax.wbem.WBEMException)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 SmisAbstractCreateVolumeJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisAbstractCreateVolumeJob)1 SmisCreateVolumeJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateVolumeJob)1 SmisJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisJob)1 ArrayList (java.util.ArrayList)1