use of com.emc.storageos.vnxe.models.StorageResource in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice method doDeleteVolumes.
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter completer) throws DeviceControllerException {
logger.info("deleting volumes, array: {}", storageSystem.getSerialNumber());
VNXeApiClient apiClient = getVnxUnityClient(storageSystem);
Map<String, List<String>> cgNameMap = new HashMap<String, List<String>>();
try {
Set<URI> updateStoragePools = new HashSet<URI>();
// Invoke a test failure if testing
for (Volume volume : volumes) {
String lunId = volume.getNativeId();
if (NullColumnValueGetter.isNullValue(lunId)) {
logger.info(String.format("The volume %s does not have native id, do nothing", volume.getLabel()));
continue;
}
updateStoragePools.add(volume.getPool());
if (!apiClient.checkLunExists(lunId)) {
logger.info(String.format("The volume %s does not exist in the array, do nothing", volume.getLabel()));
continue;
}
String cgName = volume.getReplicationGroupInstance();
if (NullColumnValueGetter.isNotNullValue(cgName)) {
List<String> lunIds = cgNameMap.get(cgName);
if (lunIds == null) {
lunIds = new ArrayList<String>();
cgNameMap.put(cgName, lunIds);
}
lunIds.add(volume.getNativeId());
} else {
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_035);
apiClient.deleteLunSync(volume.getNativeId(), false);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_036);
}
}
for (Map.Entry<String, List<String>> entry : cgNameMap.entrySet()) {
String cgName = entry.getKey();
List<String> lunIDs = entry.getValue();
String cgId = apiClient.getConsistencyGroupIdByName(cgName);
boolean isRP = false;
if (cgId != null && !cgId.isEmpty()) {
// Check if the CG has blockHostAccess to a RP host. if the CG is exported to a RP, we could not delete the lun
// directly, we have to remove the volume from the CG first, then delete it.
StorageResource cg = apiClient.getStorageResource(cgId);
List<BlockHostAccess> hosts = cg.getBlockHostAccess();
if (hosts != null && !hosts.isEmpty()) {
for (BlockHostAccess hostAccess : hosts) {
VNXeBase hostId = hostAccess.getHost();
if (hostId != null) {
VNXeHost host = apiClient.getHostById(hostId.getId());
if (host != null) {
if (host.getType() == HostTypeEnum.RPA.getValue()) {
// Remove the luns from the CG
isRP = true;
logger.info(String.format("Removing volumes from CG because the CG %sis exported to RP", cgName));
VNXeUtils.getCGLock(workflowService, storageSystem, cgName, opId);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_034);
apiClient.removeLunsFromConsistencyGroup(cgId, lunIDs);
for (String lunId : lunIDs) {
logger.info(String.format("Deleting the volume %s", lunId));
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_035);
apiClient.deleteLunSync(lunId, false);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_036);
}
break;
}
}
}
}
}
}
if (!isRP) {
VNXeUtils.getCGLock(workflowService, storageSystem, cgName, opId);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_034);
apiClient.deleteLunsFromConsistencyGroup(cgId, lunIDs);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_037);
}
}
for (URI pool : updateStoragePools) {
VNXeJob.updateStoragePoolCapacity(dbClient, apiClient, pool, null);
}
completer.ready(dbClient);
} catch (VNXeException e) {
logger.error("Delete volumes got the exception", e);
completer.error(dbClient, e);
} catch (Exception ex) {
logger.error("Delete volumes got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteVolumes", ex.getMessage());
completer.error(dbClient, error);
}
}
use of com.emc.storageos.vnxe.models.StorageResource in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method addObjectToUnManagedConsistencyGroup.
/**
* Adds the passed in unmanaged volume to an unmanaged consistency group object
*
* @param apiClient
* - connection to Unity REST interface
* @param unManagedVolume
* - unmanaged volume associated with a consistency group
* @param cgNameToProcess
* - consistency group being processed
* @param storageSystem
* - storage system the objects are on
* @param dbClient
* - dbclient
* @throws Exception
*/
private void addObjectToUnManagedConsistencyGroup(VNXeApiClient apiClient, UnManagedVolume unManagedVolume, String cgNameToProcess, StorageSystem storageSystem, DbClient dbClient) throws Exception {
log.info("Unmanaged volume {} belongs to consistency group {} on the array", unManagedVolume.getLabel(), cgNameToProcess);
// Update the unManagedVolume object with CG information
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.TRUE.toString());
String unManagedCGNativeGuid = NativeGUIDGenerator.generateNativeGuidForCG(storageSystem.getNativeGuid(), cgNameToProcess);
// determine if the unmanaged CG already exists in the unManagedCGToUpdateMap or in the database
// if the the unmanaged CG is not in either create a new one
UnManagedConsistencyGroup unManagedCG = null;
if (unManagedCGToUpdateMap.containsKey(unManagedCGNativeGuid)) {
unManagedCG = unManagedCGToUpdateMap.get(unManagedCGNativeGuid);
log.info("Unmanaged consistency group {} was previously added to the unManagedCGToUpdateMap", unManagedCG.getLabel());
} else {
unManagedCG = DiscoveryUtils.checkUnManagedCGExistsInDB(dbClient, unManagedCGNativeGuid);
if (null == unManagedCG) {
// unmanaged CG does not exist in the database, create it
StorageResource res = apiClient.getStorageResource(cgNameToProcess);
unManagedCG = createUnManagedCG(unManagedCGNativeGuid, res, storageSystem.getId(), dbClient);
log.info("Created unmanaged consistency group: {}", unManagedCG.getId().toString());
} else {
log.info("Unmanaged consistency group {} was previously added to the database", unManagedCG.getLabel());
// clean out the list of unmanaged volumes if this unmanaged cg was already
// in the database and its first time being used in this discovery operation
// the list should be re-populated by the current discovery operation
log.info("Cleaning out unmanaged volume map from unmanaged consistency group: {}", unManagedCG.getLabel());
unManagedCG.getUnManagedVolumesMap().clear();
}
}
log.info("Adding unmanaged volume {} to unmanaged consistency group {}", unManagedVolume.getLabel(), unManagedCG.getLabel());
// set the uri of the unmanaged CG in the unmanaged volume object
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), unManagedCG.getId().toString());
// add the unmanaged volume object to the unmanaged CG
unManagedCG.getUnManagedVolumesMap().put(unManagedVolume.getNativeGuid(), unManagedVolume.getId().toString());
// add the unmanaged CG to the map of unmanaged CGs to be updated in the database once all volumes have been
// processed
unManagedCGToUpdateMap.put(unManagedCGNativeGuid, unManagedCG);
// add the unmanaged CG to the current set of CGs being discovered on the array. This is for book keeping later.
allCurrentUnManagedCgURIs.add(unManagedCG.getId());
}
use of com.emc.storageos.vnxe.models.StorageResource 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 in project coprhd-controller by CoprHD.
the class DeleteStorageResourceRequest method deleteLunGroup.
/**
* Delete lun group
*
* @param groupId
* @param isForceSnapDeletion
* @return
* @throws VNXeException
*/
public VNXeCommandResult deleteLunGroup(String groupId, boolean isForceSnapDeletion) throws VNXeException {
StorageResourceRequest req = new StorageResourceRequest(_client);
StorageResource group = req.get(groupId);
if (group == null) {
String error = "Could not find lun group: " + groupId;
_logger.error(error);
throw VNXeException.exceptions.vnxeCommandFailed(error);
}
return deleteResourceSync(groupId, isForceSnapDeletion);
}
use of com.emc.storageos.vnxe.models.StorageResource in project coprhd-controller by CoprHD.
the class ApiClientTest method getCG.
// @Test
public void getCG() {
StorageResourceRequest req = new StorageResourceRequest(_client);
StorageResource res = req.get("res_1");
System.out.println(res.getName());
System.out.println(res.getLuns().size());
}
Aggregations