use of com.emc.storageos.api.service.impl.resource.utils.ExportVerificationUtility in project coprhd-controller by CoprHD.
the class FileService method updateFSExportRules.
/**
* Existing file system exports may have their list of export rules updated.
*
* @param id
* the URN of a ViPR fileSystem
* @param subDir
* sub-directory within a filesystem
* @param unmountExport
* Whether to unmount an export when deleting or modifying a rule
* @brief Update file system export
* @return Task resource representation
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/export")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateFSExportRules(@PathParam("id") URI id, @QueryParam("subDir") String subDir, @QueryParam("unmountExport") boolean unmountExport, FileShareExportUpdateParams param) throws InternalException {
// log input received.
_log.info("Update FS Export Rules : request received for {} with {}", id, param);
String task = UUID.randomUUID().toString();
// Validate the FS id.
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
FileShare fs = queryResource(id);
ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
if (ArgValidator.checkSubDirName("subDir", subDir)) {
// Set Sub Directory
_log.info("Sub Dir Provided {}", subDir);
param.setSubDir(subDir);
}
// check for bypassDnsCheck flag. If null then set to false
if (param.getBypassDnsCheck() == null) {
param.setBypassDnsCheck(false);
}
// Check for VirtualPool whether it has NFS enabled
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
if (!vpool.getProtocols().contains(StorageProtocol.File.NFS.name()) && !vpool.getProtocols().contains(StorageProtocol.File.NFSv4.name())) {
// Throw an error
throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool Doesnt support " + StorageProtocol.File.NFS.name() + " or " + StorageProtocol.File.NFSv4 + " protocol");
}
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
String path = fs.getPath();
_log.info("Export path found {} ", path);
Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SYSTEM);
op.setDescription("Filesystem export rules update");
try {
// Validate the input
ExportVerificationUtility exportVerificationUtility = new ExportVerificationUtility(_dbClient, getUserFromContext());
exportVerificationUtility.verifyExports(fs, null, param);
_log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, param });
FileServiceApi fileServiceApi = getFileShareServiceImpl(fs, _dbClient);
fileServiceApi.updateExportRules(device.getId(), fs.getId(), param, unmountExport, task);
auditOp(OperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), param);
} catch (URISyntaxException e) {
_log.error("Error Processing Export Updates {}, {}", e.getMessage(), e);
} catch (BadRequestException e) {
op = _dbClient.error(FileShare.class, fs.getId(), task, e);
_log.error("Error Processing Export Updates {}, {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
// _log.error("Error Processing Export Updates {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(fs, task, op);
}
use of com.emc.storageos.api.service.impl.resource.utils.ExportVerificationUtility in project coprhd-controller by CoprHD.
the class FileSnapshotService method updateSnapshotExportRules.
/**
* Existing file system exports may have their list of export rules updated.
*
* @param id
* the URN of a ViPR fileSystem
* @param subDir
* sub-directory within a filesystem
* @brief Update file system export
* @return Task resource representation
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/export")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateSnapshotExportRules(@PathParam("id") URI id, SnapshotExportUpdateParams param) throws InternalException {
// log input received.
_log.info("Update Snapshot Export Rules : request received for {} with {}", id, param);
String task = UUID.randomUUID().toString();
// Validate the FS id.
ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
Snapshot snap = queryResource(id);
ArgValidator.checkEntity(snap, id, true);
FileShare fs = _permissionsHelper.getObjectById(snap.getParent(), FileShare.class);
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
String path = snap.getPath();
_log.info("Snapshot Export path found {} ", path);
Operation op = _dbClient.createTaskOpStatus(Snapshot.class, snap.getId(), task, ResourceOperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SNAPSHOT);
try {
// Validate the input
ExportVerificationUtility exportVerificationUtility = new ExportVerificationUtility(_dbClient, getUserFromContext());
exportVerificationUtility.verifyExports(fs, snap, param);
_log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, param });
FileServiceApi fileServiceApi = FileService.getFileShareServiceImpl(fs, _dbClient);
fileServiceApi.updateExportRules(device.getId(), snap.getId(), param, false, task);
auditOp(OperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SNAPSHOT, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), param);
} catch (URISyntaxException e) {
op.setStatus(Operation.Status.error.name());
_log.error("Error Processing Export Updates {}, {}", e.getMessage(), e);
return toTask(snap, task, op);
} catch (BadRequestException e) {
op = _dbClient.error(Snapshot.class, snap.getId(), task, e);
_log.error("Error Processing Export Updates {}, {}", e.getMessage(), e);
// throw e;
} catch (Exception e) {
op.setStatus(Operation.Status.error.name());
toTask(snap, task, op);
// _log.error("Error Processing Export Updates {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(snap, task, op);
}
Aggregations