use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class FileSnapshotService method queryResource.
@Override
protected Snapshot queryResource(URI id) {
ArgValidator.checkUri(id);
Snapshot snap = _permissionsHelper.getObjectById(id, Snapshot.class);
ArgValidator.checkEntityNotNull(snap, id, isIdEmbeddedInURL(id));
return snap;
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class FileSnapshotService method updateSnapshotShareACL.
/**
* API to update ACLs of an existing share
*
* @param id
* the file system URI
* @param shareName
* name of the share
* @param param
* request payload object of type <code>com.emc.storageos.model.file.CifsShareACLUpdateParams</code>
* @brief Change a snapshot share ACL
* @return TaskResponse
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateSnapshotShareACL(@PathParam("id") URI id, @PathParam("shareName") String shareName, SnapshotCifsShareACLUpdateParams param) throws InternalException {
_log.info("Update snapshot share acl request received. Snapshot: {}, Share: {}", id.toString(), shareName);
_log.info("Request body: {}", param.toString());
ArgValidator.checkFieldNotNull(shareName, "shareName");
ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
Snapshot snapshot = queryResource(id);
ArgValidator.checkEntity(snapshot, id, isIdEmbeddedInURL(id));
if (!CifsShareUtility.doesShareExist(snapshot, shareName)) {
_log.error("CIFS share does not exist {}", shareName);
throw APIException.notFound.invalidParameterObjectHasNoSuchShare(snapshot.getId(), shareName);
}
FileShare fs = _permissionsHelper.getObjectById(snapshot.getParent(), FileShare.class);
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
CifsShareUtility.checkForUpdateShareACLOperationOnStorage(device.getSystemType(), OperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL.name());
String task = UUID.randomUUID().toString();
// Check for VirtualPool whether it has CIFS enabled
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
if (!vpool.getProtocols().contains(StorageProtocol.File.CIFS.name())) {
throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool doesn't support " + StorageProtocol.File.CIFS.name() + " protocol");
}
// Validate the input
CifsShareUtility util = new CifsShareUtility(_dbClient, null, snapshot, shareName);
util.verifyShareACLs(param);
_log.info("Request payload verified. No errors found.");
Operation op = _dbClient.createTaskOpStatus(Snapshot.class, snapshot.getId(), task, ResourceOperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL);
FileServiceApi fileServiceApi = FileService.getFileShareServiceImpl(fs, _dbClient);
fileServiceApi.updateShareACLs(device.getId(), snapshot.getId(), shareName, param, task);
auditOp(OperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL, true, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), device.getId().toString(), param);
return toTask(snapshot, task, op);
}
use of com.emc.storageos.db.client.model.Snapshot 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);
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class FileSnapshotService method deleteSnapshotExportRules.
/**
* Delete Snapshot Export Rules
*
* @param id
* the URN of a ViPR file system
* @brief Delete an export rule
* @return TaskResponse
*/
@DELETE
@Path("/{id}/export")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep deleteSnapshotExportRules(@PathParam("id") URI id) {
// log input received.
_log.info("Delete Snapshot Export Rules : request received for {}", new Object[] { id });
String task = UUID.randomUUID().toString();
// Validate the FS id.
ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
Snapshot snapshot = queryResource(id);
FileShare fileShare = _permissionsHelper.getObjectById(snapshot.getParent(), FileShare.class);
ArgValidator.checkEntity(snapshot, id, isIdEmbeddedInURL(id));
/* check if the Snapshot has any export rules on it */
List<FileExportRule> exports = queryDBSnapshotExports(snapshot);
if (exports == null || exports.isEmpty()) {
_log.error("Error Processing Export Updates for snapshot {} doesnot have exports", snapshot.getName());
throw APIException.badRequests.snapshotHasNoExport(snapshot.getId());
}
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fileShare.getStorageDevice());
String path = snapshot.getPath();
_log.info("Export path found {} ", path);
Operation op = _dbClient.createTaskOpStatus(Snapshot.class, snapshot.getId(), task, ResourceOperationTypeEnum.UNEXPORT_FILE_SNAPSHOT);
try {
FileServiceApi fileServiceApi = FileService.getFileShareServiceImpl(fileShare, _dbClient);
fileServiceApi.deleteExportRules(device.getId(), snapshot.getId(), false, null, false, task);
auditOp(OperationTypeEnum.UNEXPORT_FILE_SNAPSHOT, true, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), device.getId().toString(), false, null);
return toTask(snapshot, task, op);
} catch (BadRequestException 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());
}
}
use of com.emc.storageos.db.client.model.Snapshot in project coprhd-controller by CoprHD.
the class FileSnapshotService method deleteShare.
/**
* Deletes SMB share.
* <p>
* Note: This is an asynchronous operation.
*
* @param id
* the URN of a ViPR Snapshot
* @param shareName
* SMB share name
* @brief Delete file snapshot SMB share
* @return Task resource representation
* @throws InternalException
*/
@DELETE
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep deleteShare(@PathParam("id") URI id, @PathParam("shareName") String shareName) throws InternalException {
ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
Snapshot snap = queryResource(id);
FileShare fs = _permissionsHelper.getObjectById(snap.getParent(), FileShare.class);
ArgValidator.checkFieldNotNull(shareName, "shareName");
ArgValidator.checkEntity(snap, id, isIdEmbeddedInURL(id));
String task = UUID.randomUUID().toString();
if (!CifsShareUtility.doesShareExist(snap, shareName)) {
_log.error("CIFS share does not exist", shareName);
throw APIException.notFound.invalidParameterObjectHasNoSuchShare(id, shareName);
}
SMBFileShare smbShare = snap.getSMBFileShares().get(shareName);
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
Operation op = _dbClient.createTaskOpStatus(Snapshot.class, snap.getId(), task, ResourceOperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE);
FileSMBShare fileSMBShare = new FileSMBShare(shareName, smbShare.getDescription(), smbShare.getPermissionType(), smbShare.getPermission(), Integer.toString(smbShare.getMaxUsers()), smbShare.getNativeId(), smbShare.getPath());
FileServiceApi fileServiceApi = FileService.getFileShareServiceImpl(fs, _dbClient);
fileServiceApi.deleteShare(device.getId(), snap.getId(), fileSMBShare, task);
auditOp(OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, true, AuditLogManager.AUDITOP_BEGIN, smbShare.getName(), smbShare.getPermissionType(), smbShare.getPermission(), smbShare.getMaxUsers(), smbShare.getDescription(), snap.getId().toString());
return toTask(snap, task, op);
}
Aggregations