use of com.emc.nas.vnxfile.xmlapi.TreeQuota in project coprhd-controller by CoprHD.
the class VNXFileCommApi method deleteAllQuotaDirs.
private XMLApiResult deleteAllQuotaDirs(StorageSystem system, StorageHADomain dataMover, FileShare fs) {
XMLApiResult result = new XMLApiResult();
result.setCommandSuccess();
_log.info("deleteAllQuotaDirs for {}", fs.getName());
try {
// Process for quota dir delete on this file share.
List<TreeQuota> quotaDirs = (List<TreeQuota>) _provExecutor.getKeyMap().get(VNXFileConstants.QUOTA_DIR_LIST);
if (quotaDirs != null && !quotaDirs.isEmpty() && dataMover != null) {
_log.info("Number of quota dirs found {} for a file system {}", quotaDirs.size(), fs.getName());
// In the process of delete file system, we are unmounting the FileSystem.
// In order to delete Quota Directory, file system should be mounted.
// we just mount the file system temporarily. if it was un-mounted.
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
Map<String, String> existingMounts = sshApi.getFsMountpathMap(dataMover.getAdapterName());
if (existingMounts.get(fs.getName()) == null) {
String mountCmdArgs = sshApi.formatMountCmd(dataMover.getAdapterName(), fs.getName(), fs.getMountPath());
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_MOUNT_CMD, mountCmdArgs);
}
for (TreeQuota quota : quotaDirs) {
if (quota != null) {
// exclude the "/" in the beginning of the
String quotaDirName = quota.getPath().substring(1);
// path.
XMLApiResult status = deleteQuotaDirectory(system, fs.getName(), quotaDirName, true, false);
if (!status.isCommandSuccess()) {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
}
}
}
}
return result;
} catch (Exception e) {
throw new VNXException("File system quota directory delete exception: ", e);
}
}
Aggregations