Search in sources :

Example 1 with VNXeCreateVolumesJob

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

the class VNXeStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info("creating volumes, array: {}, pool : {}", storage.getSerialNumber(), storagePool.getNativeId());
    VNXeApiClient apiClient = getVnxeClient(storage);
    List<String> jobs = new ArrayList<String>();
    boolean opFailed = false;
    try {
        boolean isCG = false;
        Volume vol = volumes.get(0);
        if (vol.getConsistencyGroup() != null) {
            isCG = true;
        }
        List<String> volNames = new ArrayList<String>();
        String autoTierPolicyName = null;
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_022);
        for (Volume volume : volumes) {
            String tenantName = "";
            try {
                TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
                tenantName = tenant.getLabel();
            } catch (DatabaseException e) {
                _logger.error("Error lookup TenantOrb object", e);
            }
            String label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
            autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), _dbClient);
            if (autoTierPolicyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            }
            volume.setNativeGuid(label);
            _dbClient.persistObject(volume);
            if (!isCG) {
                VNXeCommandJob job = apiClient.createLun(label, storagePool.getNativeId(), volume.getCapacity(), volume.getThinlyProvisioned(), autoTierPolicyName);
                jobs.add(job.getId());
            } else {
                volNames.add(label);
            }
        }
        if (isCG) {
            URI cg = vol.getConsistencyGroup();
            BlockConsistencyGroup cgObj = _dbClient.queryObject(BlockConsistencyGroup.class, cg);
            String cgId = cgObj.getCgNameOnStorageSystem(storage.getId());
            VNXeCommandJob job = apiClient.createLunsInLunGroup(volNames, storagePool.getNativeId(), vol.getCapacity(), vol.getThinlyProvisioned(), autoTierPolicyName, cgId);
            jobs.add(job.getId());
        }
        VNXeCreateVolumesJob createVolumesJob = new VNXeCreateVolumesJob(jobs, storage.getId(), taskCompleter, storagePool.getId(), isCG);
        ControllerServiceImpl.enqueueJob(new QueueJob(createVolumesJob));
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_023);
    } catch (VNXeException e) {
        _logger.error("Create volumes got the exception", e);
        opFailed = true;
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _logger.error("Create volumes got the exception", ex);
        opFailed = true;
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    if (opFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            _dbClient.persistObject(vol);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ArrayList(java.util.ArrayList) VNXeCreateVolumesJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateVolumesJob) URI(java.net.URI) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Volume(com.emc.storageos.db.client.model.Volume) VNXeException(com.emc.storageos.vnxe.VNXeException) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)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 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)1 VNXeException (com.emc.storageos.vnxe.VNXeException)1 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 VNXeCreateVolumesJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateVolumesJob)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1