use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverAllTreeQuotas.
public void discoverAllTreeQuotas(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
log.info("discoverAllTreeQuotas for storage system {} - start", storageSystem.getId());
unManagedTreeQuotaInsert = new ArrayList<UnManagedFileQuotaDirectory>();
unManagedTreeQuotaUpdate = new ArrayList<UnManagedFileQuotaDirectory>();
List<VNXUnityTreeQuota> treeQuotas = apiClient.getAllTreeQuotas();
for (VNXUnityTreeQuota quota : treeQuotas) {
log.info("Discovered fS tree quota {}", quota.toString());
VNXeFileSystem fs = null;
if (quota.getFilesystem() != null) {
fs = apiClient.getFileSystemByFSId(quota.getFilesystem().getId());
String fsNativeGUID = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
try {
if (checkStorageFileSystemExistsInDB(fsNativeGUID, dbClient)) {
log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGUID);
continue;
}
String nativeUnmanagedGUID = NativeGUIDGenerator.generateNativeGuidForPreExistingQuotaDirectory(storageSystem.getSystemType(), storageSystem.getSerialNumber(), quota.getId());
VNXUnityQuotaConfig qc = apiClient.getQuotaConfigById(quota.getQuotaConfigId());
UnManagedFileQuotaDirectory unManagedFileQuotaDirectory = getExistingUnManagedQuotaDirectory(dbClient, nativeUnmanagedGUID);
boolean existingUnManagedQD = true;
if (unManagedFileQuotaDirectory == null) {
unManagedFileQuotaDirectory = new UnManagedFileQuotaDirectory();
existingUnManagedQD = false;
unManagedFileQuotaDirectory.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
}
unManagedFileQuotaDirectory.setLabel(quota.getPath().substring(1));
unManagedFileQuotaDirectory.setNativeGuid(nativeUnmanagedGUID);
unManagedFileQuotaDirectory.setParentFSNativeGuid(fsNativeGUID);
unManagedFileQuotaDirectory.setSize(quota.getHardLimit());
Long size = quota.getHardLimit() > 0 ? quota.getHardLimit() : fs.getSizeAllocated();
Long softLimit = 0L;
if (quota.getSoftLimit() > 0) {
softLimit = quota.getSoftLimit() * 100 / size;
int softGrace = qc.getGracePeriod() / (24 * 60 * 60);
unManagedFileQuotaDirectory.setSoftGrace(softGrace);
}
unManagedFileQuotaDirectory.setSoftLimit(softLimit.intValue());
unManagedFileQuotaDirectory.setNotificationLimit(0);
unManagedFileQuotaDirectory.setNativeId(quota.getId());
if (!existingUnManagedQD) {
unManagedTreeQuotaInsert.add(unManagedFileQuotaDirectory);
} else {
unManagedTreeQuotaUpdate.add(unManagedFileQuotaDirectory);
}
} catch (IOException e) {
log.error("IOException occured in discoverAllTreeQuotas()", e);
}
}
}
if (!unManagedTreeQuotaInsert.isEmpty()) {
// Add UnManagedFileSystem
partitionManager.insertInBatches(unManagedTreeQuotaInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILEQUOTADIR);
unManagedTreeQuotaInsert.clear();
}
if (!unManagedTreeQuotaUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateInBatches(unManagedTreeQuotaUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILEQUOTADIR);
unManagedTreeQuotaUpdate.clear();
}
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doCheckFSExists.
@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
_logger.info("checking file system existence on array: ", fileInOut.getFsName());
boolean isFSExists = true;
try {
String name = fileInOut.getFsName();
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeFileSystem fs = apiClient.getFileSystemByFSName(name);
if (fs != null && (fs.getName().equals(name))) {
isFSExists = true;
} else {
isFSExists = false;
}
} catch (Exception e) {
_logger.error("Querying File System failed with exception:", e);
}
return isFSExists;
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doCheckFSExists.
@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
_logger.info("checking file system existence on array: ", fileInOut.getFsName());
boolean isFSExists = true;
try {
String fsId = fileInOut.getFsNativeId();
VNXeApiClient apiClient = getVnxUnityClient(storage);
VNXeFileSystem fs = apiClient.getFileSystemByFSId(fsId);
if (fs != null && (fs.getId().equals(fsId))) {
isFSExists = true;
} else {
isFSExists = false;
}
} catch (Exception e) {
_logger.error("Querying File System failed with exception:", e);
}
return isFSExists;
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXeApiClient method getStorageResourceId.
/**
* get storage resource Id using file system Id
*
* @param fsId
* file system Id
* @return storage resource Id
*/
private String getStorageResourceId(String fsId) throws VNXeException {
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.info("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
return fs.getStorageResource().getId();
}
use of com.emc.storageos.vnxe.models.VNXeFileSystem in project coprhd-controller by CoprHD.
the class VNXeApiClient method removeCifsShare.
/**
* Delete cifsShare
*
* @param cifsShareId
* cifsShare Id
* @param fsId
* file system Id
* @return VNXeCommandJob
*/
public VNXeCommandJob removeCifsShare(String cifsShareId, String fsId) {
VNXeCommandJob job = null;
_logger.info("deleting cifs share" + cifsShareId);
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.info("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
String resourceId = fs.getStorageResource().getId();
ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
// set cifsShare delete parm
CifsShareDeleteParam deleteParam = new CifsShareDeleteParam();
VNXeBase share = new VNXeBase();
share.setId(cifsShareId);
deleteParam.setCifsShare(share);
List<CifsShareDeleteParam> deleteList = new ArrayList<CifsShareDeleteParam>();
deleteList.add(deleteParam);
modifyFSParm.setCifsShareDelete(deleteList);
FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
return job;
}
Aggregations