use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doDeleteQuotaDirectory.
@Override
public BiosCommandResult doDeleteQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
BiosCommandResult result = new BiosCommandResult();
ApplicationContext context = null;
XMLApiResult apiResult = null;
try {
_log.info("VNXFileStorageDeviceXML doDeleteQuotaDirectory - start");
String fsName = args.getFsName();
String quotaTreetreeName = args.getQuotaDirectoryName();
QuotaDirectory quotaDir = args.getQuotaDirectory();
if (null == fsName) {
_log.error("VNXFileStorageDeviceXML::doDeleteQuotaDirectory failed: Filesystem name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.vnx.unableToDeleteQuotaDir();
serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
if (null == quotaTreetreeName) {
_log.error("VNXFileStorageDeviceXML::doDeleteQuotaDirectory failed: Quota Tree name is either missing or empty");
ServiceError serviceError = DeviceControllerErrors.vnx.unableToDeleteQuotaDir();
serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
result = BiosCommandResult.createErrorResult(serviceError);
return result;
}
_log.info("FSName: {}", args.getFsName());
_log.info("Quota tree name: {}", args.getQuotaDirectoryName());
boolean isMountRequired = !(args.isFileShareMounted());
_log.info("Mount required or not, to delete quota dir requested {}", isMountRequired);
// Load the context
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
// we can't delete quota, if the filsystem is not mount, We should changes quota cmd
apiResult = vnxComm.deleteQuotaDirectory(storage, args.getFsName(), quotaTreetreeName, true, isMountRequired);
if (apiResult.isCommandSuccess()) {
result = BiosCommandResult.createSuccessfulResult();
}
_log.info("doDeleteQuotaDirectory call result : {}", apiResult.isCommandSuccess());
} catch (VNXException e) {
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToDeleteQuotaDir());
}
return cmdResult;
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method isiDeleteQuotaDirs.
/**
* Deleting Quota dirs: - deletes quota dirs of a file system
*
* @param isi
* IsilonApi object
* @param args
* FileDeviceInputOutput
* @throws IsilonException
*/
private void isiDeleteQuotaDirs(IsilonApi isi, FileDeviceInputOutput args) throws IsilonException {
List<URI> quotaDirURIList = _dbClient.queryByConstraint(ContainmentConstraint.Factory.getQuotaDirectoryConstraint(args.getFsId()));
for (URI quotaDirURI : quotaDirURIList) {
QuotaDirectory quotaDir = _dbClient.queryObject(QuotaDirectory.class, quotaDirURI);
if (quotaDir != null && (!quotaDir.getInactive())) {
if (quotaDir.getExtensions() != null && quotaDir.getExtensions().containsKey(QUOTA)) {
String quotaDirPath = args.getFsMountPath() + "/" + quotaDir.getName();
// if the quota directory has some data in it.
if (isi.fsDirHasData(quotaDirPath)) {
// Fail to delete file system quota directory which has data in it!!!
_log.error("Quota directory deletion failed as it's directory path {} has content in it", quotaDirPath);
throw DeviceControllerException.exceptions.failToDeleteQuotaDirectory(quotaDirPath);
}
String quotaId = quotaDir.getExtensions().get(QUOTA);
_log.info("IsilonFileStorageDevice isiDeleteQuotaDirs , Delete Quota {}", quotaId);
isi.deleteQuota(quotaId);
// delete from quota extensions
quotaDir.getExtensions().remove(QUOTA);
// delete directory for the Quota Directory
isi.deleteDir(quotaDirPath);
}
}
}
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class VNXFileCommApi method getVNXFSDependencies.
/*
* Check the dependencies on file share or on snap shot.
* input :
* fs: File share object
* considerSnapshots: consider the snap shot dependencies.
* return: this function will check and return the number of dependencies like
* exports, shares, snapshot and quota directories on the given file share.
*/
private int getVNXFSDependencies(FileShare fs, Boolean considerSnapshots) {
FSExportMap exports = null;
SMBShareMap shares = null;
int totalDependencies = 0;
// FileShare operation
if (fs.getFsExports() != null) {
exports = fs.getFsExports();
}
if (fs.getSMBFileShares() != null) {
shares = fs.getSMBFileShares();
}
if (exports != null) {
totalDependencies += exports.size();
}
if (shares != null) {
totalDependencies += shares.size();
}
List<Snapshot> snapshots = getFSSnapshots(fs);
if (snapshots != null && !snapshots.isEmpty()) {
totalDependencies += snapshots.size();
}
List<QuotaDirectory> quotaDirs = getFSQuotaDirs(fs);
if (quotaDirs != null && !quotaDirs.isEmpty()) {
totalDependencies += quotaDirs.size();
}
if (considerSnapshots && snapshots != null) {
totalDependencies = snapshots.size();
for (Snapshot snap : snapshots) {
exports = snap.getFsExports();
shares = snap.getSMBFileShares();
if (exports != null) {
totalDependencies += exports.size();
}
if (shares != null) {
totalDependencies += shares.size();
}
}
}
_log.info("FileShare : total dependencies {} ", totalDependencies);
return totalDependencies;
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method ingestFileQuotaDirectories.
private void ingestFileQuotaDirectories(FileShare parentFS) throws IOException {
String parentFsNativeGUID = parentFS.getNativeGuid();
URIQueryResultList result = new URIQueryResultList();
List<QuotaDirectory> quotaDirectories = new ArrayList<>();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedFileQuotaDirectoryInfoParentNativeGUIdConstraint(parentFsNativeGUID), result);
List<UnManagedFileQuotaDirectory> unManagedFileQuotaDirectories = _dbClient.queryObject(UnManagedFileQuotaDirectory.class, result);
_logger.info("found {} quota directories for fs {}", unManagedFileQuotaDirectories.size(), parentFS.getId());
for (UnManagedFileQuotaDirectory unManagedFileQuotaDirectory : unManagedFileQuotaDirectories) {
QuotaDirectory quotaDirectory = new QuotaDirectory();
quotaDirectory.setId(URIUtil.createId(QuotaDirectory.class));
quotaDirectory.setParent(new NamedURI(parentFS.getId(), unManagedFileQuotaDirectory.getLabel()));
quotaDirectory.setNativeId(unManagedFileQuotaDirectory.getNativeId());
quotaDirectory.setLabel(unManagedFileQuotaDirectory.getLabel());
quotaDirectory.setOpStatus(new OpStatusMap());
quotaDirectory.setProject(new NamedURI(parentFS.getProject().getURI(), unManagedFileQuotaDirectory.getLabel()));
quotaDirectory.setTenant(new NamedURI(parentFS.getTenant().getURI(), unManagedFileQuotaDirectory.getLabel()));
quotaDirectory.setInactive(false);
quotaDirectory.setSoftLimit(unManagedFileQuotaDirectory.getSoftLimit() != null && unManagedFileQuotaDirectory.getSoftLimit() != 0 ? unManagedFileQuotaDirectory.getSoftLimit() : parentFS.getSoftLimit() != null ? parentFS.getSoftLimit().intValue() : 0);
quotaDirectory.setSoftGrace(unManagedFileQuotaDirectory.getSoftGrace() != null && unManagedFileQuotaDirectory.getSoftGrace() != 0 ? unManagedFileQuotaDirectory.getSoftGrace() : parentFS.getSoftGracePeriod() != null ? parentFS.getSoftGracePeriod() : 0);
quotaDirectory.setNotificationLimit(unManagedFileQuotaDirectory.getNotificationLimit() != null && unManagedFileQuotaDirectory.getNotificationLimit() != 0 ? unManagedFileQuotaDirectory.getNotificationLimit() : parentFS.getNotificationLimit() != null ? parentFS.getNotificationLimit().intValue() : 0);
String convertedName = unManagedFileQuotaDirectory.getLabel().replaceAll("[^\\dA-Za-z_]", "");
_logger.info("FileService::QuotaDirectory Original name {} and converted name {}", unManagedFileQuotaDirectory.getLabel(), convertedName);
quotaDirectory.setName(convertedName);
if (unManagedFileQuotaDirectory.getOpLock() != null) {
quotaDirectory.setOpLock(unManagedFileQuotaDirectory.getOpLock());
} else {
quotaDirectory.setOpLock(true);
}
quotaDirectory.setSize(unManagedFileQuotaDirectory.getSize());
quotaDirectory.setSecurityStyle(unManagedFileQuotaDirectory.getSecurityStyle());
quotaDirectory.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, quotaDirectory, parentFS.getName()));
// check for file extensions
if (null != unManagedFileQuotaDirectory.getExtensions() && !unManagedFileQuotaDirectory.getExtensions().isEmpty()) {
StringMap extensions = new StringMap();
if (null != unManagedFileQuotaDirectory.getExtensions().get(QUOTA)) {
extensions.put(QUOTA, unManagedFileQuotaDirectory.getExtensions().get(QUOTA));
quotaDirectory.setExtensions(extensions);
}
}
quotaDirectories.add(quotaDirectory);
}
if (!quotaDirectories.isEmpty()) {
_dbClient.updateObject(quotaDirectories);
}
if (!unManagedFileQuotaDirectories.isEmpty()) {
unManagedFileQuotaDirectories.forEach(unManagedFileQuotaDir -> unManagedFileQuotaDir.setInactive(true));
_dbClient.updateObject(unManagedFileQuotaDirectories);
_logger.info("ingested {} quota directories for fs {}", unManagedFileQuotaDirectories.size(), parentFS.getId());
}
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class FileService method queryDBQuotaDirectories.
private List<QuotaDirectory> queryDBQuotaDirectories(FileShare fs) {
_log.info("Querying all quota directories Using FsId {}", fs.getId());
try {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getQuotaDirectoryConstraint(fs.getId());
List<QuotaDirectory> fsQuotaDirs = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, QuotaDirectory.class, containmentConstraint);
return fsQuotaDirs;
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return null;
}
Aggregations