use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileSystems method deleteFileSystemExport.
@FlashException(referrer = { "fileSystem" })
public static void deleteFileSystemExport(String fileSystemId, String security, String exportPath) {
ViPRCoreClient client = BourneUtil.getViprClient();
ExportRule rule = new ExportRule();
rule.setSecFlavor(security);
List<ExportRule> list = Lists.newArrayList();
list.add(rule);
ExportRules exportRules = new ExportRules();
exportRules.setExportRules(list);
FileShareExportUpdateParams params = new FileShareExportUpdateParams();
params.setExportRulesToDelete(exportRules);
FileShareRestRep fileSystem = client.fileSystems().get(uri(fileSystemId));
String subDir = FileUtils.findSubDirectory(fileSystem.getMountPath(), exportPath);
client.fileSystems().updateExport(uri(fileSystemId), subDir, params);
flash.put("info", MessagesUtils.get("resources.filesystem.export.deactivate"));
fileSystem(fileSystemId);
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method verifyAddExportRule.
/**
* Verify each export rule that can be added
*
* @param listExportRule
*/
private void verifyAddExportRule(List<ExportRule> listExportRule) throws Exception {
if (listExportRule == null) {
return;
}
_log.info("Checking if file system is exported before adding export rule");
if (!isFileSystemExported()) {
String msg = "File system is not exported. To add export rule, file system must be exported first.";
_log.error(msg);
String urn = fs != null ? fs.getId().toString() : snapshot.getId().toString();
throw APIException.badRequests.fileSystemNotExported(ExportOperationType.ADD.name(), urn);
}
_log.info("Number of Export Rule(s) Requested to Add {} - Iterating ..", listExportRule.size());
for (ExportRule exportRule : listExportRule) {
exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
_log.info("Verifying Export Rule {}", exportRule.toString());
// is same security flavor found in several exports - report the error
scanForDuplicateSecFlavor(exportRule);
if (exportRule.getErrorTypeIfNotToProceed() != null && !(exportRule.getErrorTypeIfNotToProceed().name().equals(ExportOperationErrorType.NO_ERROR.name()))) {
_log.info("Same Security Flavor found across the exports {}", exportRule.toString());
break;
}
// Now validate hosts
FileExportRule rule = validateHosts(exportRule);
// If same export already found -- Don't allow to add again.
if (rule != null) {
_log.info("Duplicate Export to Add {} Requested : {}", rule, exportRule);
exportRule.setIsToProceed(false, ExportOperationErrorType.EXPORT_EXISTS);
break;
} else // If not found proceed for further verifications.
{
if (exportRule.isToProceed()) {
_log.info("No Existing Export found in DB {}", exportRule);
verifyExportAnon(exportRule);
}
}
}
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method verifyModifyExportRule.
/**
* Verify each export rule that can be added
*
* @param fs
* @param listExportRule
*/
private void verifyModifyExportRule(List<ExportRule> listExportRule) throws Exception {
if (listExportRule == null) {
return;
}
_log.info("{} Export Rule(s) Requested to Modify {} - Iterating ..", listExportRule.size());
for (ExportRule exportRule : listExportRule) {
exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
_log.info("Verifying Export Rule {}", exportRule.toString());
// is same security flavor found in several exports - report the error
scanForDuplicateSecFlavor(exportRule);
if (!exportRule.isToProceed()) {
_log.info("Same Security Flavor found across the exports {}", exportRule.toString());
break;
}
FileExportRule rule = validateHosts(exportRule);
// If found -- allow to modify.
if (rule != null) {
verifyExportAnon(exportRule);
} else // If not, stop proceed further.
{
if (exportRule.isToProceed()) {
_log.info("Export not found to modify");
exportRule.setIsToProceed(false, ExportOperationErrorType.EXPORT_NOT_FOUND);
}
}
}
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method reportAddErrors.
private void reportAddErrors(FileExportUpdateParams param) throws Exception {
String opName = ExportOperationType.ADD.name();
// Report Add Export Errors
ExportRules listExportRules = param.getExportRulesToAdd();
if (listExportRules == null || listExportRules.getExportRules().isEmpty()) {
return;
}
List<ExportRule> listExportRule = listExportRules.getExportRules();
for (ExportRule exportRule : listExportRule) {
if (!exportRule.isToProceed()) {
ExportOperationErrorType error = exportRule.getErrorTypeIfNotToProceed();
switch(error) {
case SNAPSHOT_EXPORT_SHOULD_BE_READ_ONLY:
{
throw APIException.badRequests.snapshotExportPermissionReadOnly();
}
case INVALID_SECURITY_TYPE:
{
if (exportRule.getSecFlavor() != null) {
throw APIException.badRequests.invalidSecurityType(exportRule.getSecFlavor());
} else {
throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
}
}
case MULTIPLE_EXPORTS_WITH_SAME_SEC_FLAVOR:
{
if (exportRule.getSecFlavor() != null) {
throw APIException.badRequests.sameSecurityFlavorInMultipleExportsFound(exportRule.getSecFlavor(), opName);
} else {
throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
}
}
case INVALID_ANON:
{
if (exportRule.getAnon() != null) {
throw APIException.badRequests.invalidAnon(exportRule.getAnon());
} else {
throw APIException.badRequests.missingInputTypeFound(ANON_TYPE, opName);
}
}
case NO_HOSTS_FOUND:
{
throw APIException.badRequests.missingInputTypeFound(NO_HOSTS_FOUND, opName);
}
case EXPORT_EXISTS:
{
throw APIException.badRequests.exportExists(opName, exportRule.toString());
}
case STORAGE_SYSTEM_NOT_SUPPORT_MUL_SECS:
{
StorageSystem system = null;
String systemName = "";
if (fs != null) {
system = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
} else if (snapshot != null) {
FileShare fileSystem = _dbClient.queryObject(FileShare.class, snapshot.getParent());
system = _dbClient.queryObject(StorageSystem.class, fileSystem.getStorageDevice());
}
if (system != null) {
systemName = system.getSystemType();
}
throw APIException.badRequests.storageDoesNotSupportMulSecRule(opName, systemName, exportRule.toString());
}
case EXPORT_NOT_FOUND:
case NO_ERROR:
default:
break;
}
}
}
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileDeviceController method checkIfMountExistsOnHost.
public void checkIfMountExistsOnHost(URI fsId, String opId) {
try {
WorkflowStepCompleter.stepExecuting(opId);
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
FileShare fs = _dbClient.queryObject(FileShare.class, fsId);
for (FileMountInfo fsMount : fsDBMounts) {
LinuxMountUtils mountUtils = new LinuxMountUtils(_dbClient.queryObject(Host.class, fsMount.getHostId()));
ExportRule export = FileOperationUtils.findExport(fs, fsMount.getSubDirectory(), fsMount.getSecurityType(), _dbClient);
if (mountUtils.verifyMountPoints(export.getMountPoint(), fsMount.getMountPath())) {
String errMsg = new String("delete file system from ViPR database failed because mounts exist for file system " + fs.getLabel() + " and once deleted the mounts cannot be ingested into ViPR");
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.DELETE_FILE_SYSTEM.toString(), errMsg);
WorkflowStepCompleter.stepFailed(opId, serviceCoded);
}
}
for (FileMountInfo fsMount : fsDBMounts) {
fsMount.setInactive(true);
}
_dbClient.updateObject(fsDBMounts);
WorkflowStepCompleter.stepSucceded(opId);
} catch (ControllerException ex) {
WorkflowStepCompleter.stepFailed(opId, ex);
_log.error("Couldn't verify dependencies: ", fsId);
throw ex;
}
}
Aggregations