use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice 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 = getVnxUnityClient(storage);
List<String> jobs = new ArrayList<String>();
boolean opFailed = false;
try {
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_022);
Map<String, List<Volume>> cgVolumes = new HashMap<String, List<Volume>>();
Map<String, List<URI>> jobVolumesMap = new HashMap<String, List<URI>>();
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);
String cgName = volume.getReplicationGroupInstance();
volume.setNativeGuid(label);
dbClient.updateObject(volume);
if (NullColumnValueGetter.isNullValue(cgName)) {
String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
if (autoTierPolicyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
}
VNXeCommandJob job = apiClient.createLun(label, storagePool.getNativeId(), volume.getCapacity(), volume.getThinlyProvisioned(), autoTierPolicyName);
jobs.add(job.getId());
jobVolumesMap.put(job.getId(), Arrays.asList(volume.getId()));
} else {
logger.info(String.format("Creating the volume %s in CG %s", volume.getLabel(), cgName));
List<Volume> vols = cgVolumes.get(cgName);
if (vols == null) {
vols = new ArrayList<Volume>();
}
vols.add(volume);
cgVolumes.put(cgName, vols);
}
}
for (Map.Entry<String, List<Volume>> cgVol : cgVolumes.entrySet()) {
// Creating volumes in a CG
String cgName = cgVol.getKey();
String cgId = apiClient.getConsistencyGroupIdByName(cgName);
if (cgId == null) {
String errorMsg = String.format("The CG %s could not be found in the array", cgName);
logger.error(errorMsg);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", errorMsg);
taskCompleter.error(dbClient, error);
dbClient.markForDeletion(cgVol.getValue());
return;
}
List<Volume> vols = cgVol.getValue();
VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
List<LunCreateParam> lunCreates = new ArrayList<LunCreateParam>();
StorageResource cg = apiClient.getConsistencyGroup(cgId);
List<URI> volURIs = new ArrayList<URI>();
for (Volume volToCreate : vols) {
volURIs.add(volToCreate.getId());
boolean isPolicyOn = false;
String tierPolicy = ControllerUtils.getAutoTieringPolicyName(volToCreate.getId(), dbClient);
FastVPParam fastVP = new FastVPParam();
if (!tierPolicy.equals(Constants.NONE)) {
TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tierPolicy);
if (tierValue != null) {
fastVP.setTieringPolicy(tierValue.getValue());
isPolicyOn = true;
}
}
// Construct Unity API LunParam for each volume to be created.
LunParam lunParam = new LunParam();
lunParam.setIsThinEnabled(volToCreate.getThinlyProvisioned());
lunParam.setSize(volToCreate.getCapacity());
lunParam.setPool(new VNXeBase(storagePool.getNativeId()));
List<BlockHostAccess> hostAccesses = cg.getBlockHostAccess();
if (hostAccesses != null && !hostAccesses.isEmpty()) {
for (BlockHostAccess hostAccess : hostAccesses) {
hostAccess.setAccessMask(HostLUNAccessEnum.NOACCESS.getValue());
}
lunParam.setHostAccess(hostAccesses);
}
LunCreateParam createParam = new LunCreateParam();
createParam.setName(volToCreate.getLabel());
createParam.setLunParameters(lunParam);
if (isPolicyOn) {
lunParam.setFastVPParameters(fastVP);
}
lunCreates.add(createParam);
}
VNXeCommandJob result = apiClient.createLunsInConsistencyGroup(lunCreates, cgId);
jobs.add(result.getId());
jobVolumesMap.put(result.getId(), volURIs);
}
VNXUnityCreateVolumesJob createVolumesJob = new VNXUnityCreateVolumesJob(jobVolumesMap, jobs, storage.getId(), taskCompleter, storagePool.getId());
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.updateObject(vol);
}
}
}
use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.
the class VNXeApiClient method createLunsInLunGroup.
/**
* Create multiple volumes in a lun group
*
* @param names
* @param poolId
* @param size
* @param isThin
* @param tieringPolicy
* @param lunGroupId
* @return
*/
public VNXeCommandJob createLunsInLunGroup(List<String> names, String poolId, Long size, boolean isThin, String tieringPolicy, String lunGroupId) {
_logger.info("creating luns in the lun group: {}", lunGroupId);
LunGroupModifyParam param = new LunGroupModifyParam();
List<LunCreateParam> lunCreates = new ArrayList<LunCreateParam>();
boolean isPolicyOn = false;
FastVPParam fastVP = new FastVPParam();
if (tieringPolicy != null && !tieringPolicy.isEmpty()) {
TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tieringPolicy);
if (tierValue != null) {
fastVP.setTieringPolicy(tierValue.getValue());
isPolicyOn = true;
}
}
for (String lunName : names) {
LunParam lunParam = new LunParam();
lunParam.setIsThinEnabled(isThin);
lunParam.setSize(size);
lunParam.setPool(new VNXeBase(poolId));
LunCreateParam createParam = new LunCreateParam();
createParam.setName(lunName);
createParam.setLunParameters(lunParam);
if (isPolicyOn) {
lunParam.setFastVPParameters(fastVP);
}
lunCreates.add(createParam);
}
param.setLunCreate(lunCreates);
LunGroupRequests req = new LunGroupRequests(_khClient);
return req.modifyLunGroupAsync(lunGroupId, param);
}
use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.
the class VNXeApiClient method createLunsInConsistencyGroup.
/**
* Create multiple volumes in a lun group
*
* @param names
* @param poolId
* @param size
* @param isThin
* @param tieringPolicy
* @param cgId
* @return
*/
public VNXeCommandJob createLunsInConsistencyGroup(List<String> names, String poolId, Long size, boolean isThin, String tieringPolicy, String cgId) {
_logger.info("creating luns in the consistencyGroup group: {}", cgId);
LunGroupModifyParam param = new LunGroupModifyParam();
List<LunCreateParam> lunCreates = new ArrayList<LunCreateParam>();
boolean isPolicyOn = false;
FastVPParam fastVP = new FastVPParam();
if (tieringPolicy != null && !tieringPolicy.isEmpty()) {
TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tieringPolicy);
if (tierValue != null) {
fastVP.setTieringPolicy(tierValue.getValue());
isPolicyOn = true;
}
}
StorageResourceRequest cgRequest = new StorageResourceRequest(_khClient);
StorageResource cg = cgRequest.get(cgId);
for (String lunName : names) {
LunParam lunParam = new LunParam();
lunParam.setIsThinEnabled(isThin);
lunParam.setSize(size);
lunParam.setPool(new VNXeBase(poolId));
List<BlockHostAccess> hostAccesses = cg.getBlockHostAccess();
if (hostAccesses != null && !hostAccesses.isEmpty()) {
for (BlockHostAccess hostAccess : hostAccesses) {
hostAccess.setAccessMask(HostLUNAccessEnum.NOACCESS.getValue());
}
lunParam.setHostAccess(hostAccesses);
}
LunCreateParam createParam = new LunCreateParam();
createParam.setName(lunName);
createParam.setLunParameters(lunParam);
if (isPolicyOn) {
lunParam.setFastVPParameters(fastVP);
}
lunCreates.add(createParam);
}
param.setLunCreate(lunCreates);
ConsistencyGroupRequests req = new ConsistencyGroupRequests(_khClient);
return req.modifyConsistencyGroupAsync(cgId, param);
}
use of com.emc.storageos.vnxe.models.StorageResource.TieringPolicyEnum in project coprhd-controller by CoprHD.
the class VNXeApiClient method createLun.
/**
* Create standalone lun
*
* @param name
* @param poolId
* @param size
* @param isThin
* @param tieringPolicy
* @param lunGroupId
* @return
*/
public VNXeCommandJob createLun(String name, String poolId, Long size, boolean isThin, String tieringPolicy) {
LunParam lunParam = new LunParam();
lunParam.setIsThinEnabled(isThin);
lunParam.setSize(size);
lunParam.setPool(new VNXeBase(poolId));
FastVPParam fastVP = new FastVPParam();
if (tieringPolicy != null && !tieringPolicy.isEmpty()) {
TieringPolicyEnum tierValue = TieringPolicyEnum.valueOf(tieringPolicy);
if (tierValue != null) {
fastVP.setTieringPolicy(tierValue.getValue());
lunParam.setFastVPParameters(fastVP);
}
}
LunCreateParam createParam = new LunCreateParam();
createParam.setName(name);
createParam.setLunParameters(lunParam);
BlockLunRequests req = new BlockLunRequests(_khClient);
return req.createLun(createParam);
}
Aggregations