use of com.emc.storageos.vnxe.models.VNXeLun in project coprhd-controller by CoprHD.
the class VNXeApiClient method expandLun.
public VNXeCommandJob expandLun(String lunID, long newSize, String lunGroupID) {
VNXeCommandJob job = null;
_logger.info("expanding lun:" + lunID);
VNXeLun vnxeLun = getLun(lunID);
if (vnxeLun == null) {
_logger.info("Could not find lun in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun in the vnxe for: " + lunID);
}
LunModifyParam lunModifyParam = new LunModifyParam();
// set lunParam
LunParam lunParam = new LunParam();
lunParam.setSize(newSize);
lunModifyParam.setLunParameters(lunParam);
if (vnxeLun.getType() == GENERIC_STORAGE_LUN_TYPE) {
if (lunGroupID == null || lunGroupID.isEmpty()) {
_logger.error("Lun Group Id not found for lun: " + lunID);
throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun group for lun: " + lunID);
}
LunGroupModifyParam param = new LunGroupModifyParam();
List<LunModifyParam> lunModifyParamList = new ArrayList<LunModifyParam>();
lunModifyParam.setLun(new VNXeBase(lunID));
lunModifyParamList.add(lunModifyParam);
param.setLunModify(lunModifyParamList);
if (isUnityClient()) {
ConsistencyGroupRequests cgRequest = new ConsistencyGroupRequests(_khClient);
job = cgRequest.modifyConsistencyGroupAsync(lunGroupID, param);
} else {
LunGroupRequests lunGroupRequest = new LunGroupRequests(_khClient);
job = lunGroupRequest.modifyLunGroupAsync(lunGroupID, param);
}
} else if (vnxeLun.getType() == STANDALONE_LUN_TYPE) {
BlockLunRequests req = new BlockLunRequests(_khClient);
job = req.modifyLunAsync(lunModifyParam, lunID);
}
return job;
}
use of com.emc.storageos.vnxe.models.VNXeLun in project coprhd-controller by CoprHD.
the class DeleteStorageResourceRequest method deleteLunAsync.
/**
* Delete lun in async mode
*
* @param lunId
* @param isForceSnapDeletion
* @return
* @throws VNXeException
*/
public VNXeCommandJob deleteLunAsync(String lunId, boolean isForceSnapDeletion) throws VNXeException {
BlockLunRequests req = new BlockLunRequests(_client);
VNXeLun lun = req.getLun(lunId);
if (lun == null) {
String error = "Could not find lun: " + lunId;
_logger.error(error);
throw VNXeException.exceptions.vnxeCommandFailed(error);
}
return deleteResourceAsync(lunId, isForceSnapDeletion);
}
use of com.emc.storageos.vnxe.models.VNXeLun in project coprhd-controller by CoprHD.
the class DeleteStorageResourceRequest method deleteLunSync.
public VNXeCommandResult deleteLunSync(String id, boolean isForceSnapDeletion) throws VNXeException {
_logger.info("deleting lun : {}", id);
BlockLunRequests req = new BlockLunRequests(_client);
VNXeLun lun = req.getLun(id);
if (lun == null) {
String error = "Could not find lun: " + id;
_logger.error(error);
throw VNXeException.exceptions.vnxeCommandFailed(error);
}
return deleteResourceSync(id, isForceSnapDeletion);
}
use of com.emc.storageos.vnxe.models.VNXeLun in project coprhd-controller by CoprHD.
the class ApiClientTest method getLunByLunGroup.
// @Test
public void getLunByLunGroup() {
VNXeLun lun = apiClient.getLunByLunGroup("res_1", "vol9");
System.out.println(lun.getId());
}
use of com.emc.storageos.vnxe.models.VNXeLun in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverUnManagedVolumes.
public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
List<VNXeLun> luns = apiClient.getAllLuns();
if (luns != null && !luns.isEmpty()) {
Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
Map<String, List<UnManagedVolume>> hostVolumesMap = new HashMap<String, List<UnManagedVolume>>();
for (VNXeLun lun : luns) {
UnManagedVolume unManagedVolume = null;
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), lun.getId());
if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
}
StoragePool storagePool = getStoragePoolOfUnManagedObject(lun.getPool().getId(), storageSystem, pools);
if (null == storagePool) {
log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", lun.getId());
continue;
}
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), lun.getId());
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, lun, storageSystem, storagePool, dbClient, hostVolumesMap);
unManagedVolumesReturnedFromProvider.add(unManagedVolume.getId());
Boolean isVolumeInCG = lun.getType() == VNXeApiClient.GENERIC_STORAGE_LUN_TYPE ? true : false;
String cgId = null;
if (isVolumeInCG) {
cgId = lun.getStorageResource().getId();
addObjectToUnManagedConsistencyGroup(apiClient, unManagedVolume, cgId, storageSystem, dbClient);
} else {
// Make sure the unManagedVolume object does not contain CG information from previous discovery
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
// set the uri of the unmanaged CG in the unmanaged volume object to empty
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
}
// Discover snaps
Integer snapCount = lun.getSnapCount();
boolean hasSnap = false;
if (snapCount > 0) {
List<Snap> snaps = apiClient.getSnapshotsForLun(lun.getId());
if (snaps != null && !snaps.isEmpty()) {
StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, snaps, unManagedVolumeNatvieGuid, parentMatchedVPools, apiClient, dbClient, hostVolumesMap, lun, isVolumeInCG, cgId);
if (discoveredSnaps != null && !discoveredSnaps.isEmpty()) {
hasSnap = true;
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.TRUE.toString());
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
// replace with new StringSet
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
} else {
unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
}
}
}
}
if (!hasSnap) {
// no snap
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.FALSE.toString());
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
if (unManagedVolumeInformation != null && unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
// replace with empty string set doesn't work, hence added explicit code to remove all
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
}
}
}
if (!unManagedCGToUpdateMap.isEmpty()) {
unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
unManagedCGToUpdate.clear();
}
if (!unManagedVolumesInsert.isEmpty()) {
partitionManager.insertInBatches(unManagedVolumesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
}
if (!unManagedVolumesUpdate.isEmpty()) {
partitionManager.updateAndReIndexInBatches(unManagedVolumesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
}
// Process those active unmanaged volume objects available in database but not in newly discovered items, to
// mark them inactive.
DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, unManagedVolumesReturnedFromProvider, dbClient, partitionManager);
// Process those active unmanaged consistency group objects available in database but not in newly
// discovered items, to mark them
// inactive.
DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
// Next discover the unmanaged export masks
discoverUnmanagedExportMasks(storageSystem.getId(), hostVolumesMap, apiClient, dbClient, partitionManager);
} else {
log.info("There are no luns found on the system: {}", storageSystem.getId());
}
}
Aggregations