Search in sources :

Example 1 with SmisCreateVolumeJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateVolumeJob 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)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 SmisCreateMultiVolumeJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob)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 CIMArgument (javax.cim.CIMArgument)1 CIMInstance (javax.cim.CIMInstance)1 CIMObjectPath (javax.cim.CIMObjectPath)1 WBEMException (javax.wbem.WBEMException)1