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);
}
}
}
Aggregations