use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController in project coprhd-controller by CoprHD.
the class FilePolicyService method unassignFilePolicy.
/**
* Unassign File Policy
*
* @param id
* of the file policy.
* @param FilePolicyUnAssignParam
* @brief Unassign file policy from vpool, project, file system
* @return TaskResourceRep
*/
@POST
@Path("/{id}/unassign-policy")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.TENANT_ADMIN })
public TaskResourceRep unassignFilePolicy(@PathParam("id") URI id, FilePolicyUnAssignParam param) {
_log.info("Unassign File Policy :{} request received.", id);
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, FilePolicy.class, "id");
FilePolicy filepolicy = this._dbClient.queryObject(FilePolicy.class, id);
ArgValidator.checkEntity(filepolicy, id, true);
StringBuilder errorMsg = new StringBuilder();
Operation op = _dbClient.createTaskOpStatus(FilePolicy.class, filepolicy.getId(), task, ResourceOperationTypeEnum.UNASSIGN_FILE_POLICY);
op.setDescription("unassign File Policy from resources ");
// As the action done by tenant/system admin
// Set corresponding tenant uri as task's tenant!!!
Task taskObj = op.getTask(filepolicy.getId());
StorageOSUser user = getUserFromContext();
URI userTenantUri = URI.create(user.getTenantId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, filepolicy, "unassign", taskObj, userTenantUri);
if (filepolicy.getAssignedResources() == null || filepolicy.getAssignedResources().isEmpty()) {
_log.info("File Policy: " + id + " doesn't have any assigned resources.");
_dbClient.ready(FilePolicy.class, filepolicy.getId(), task);
return toTask(filepolicy, task, op);
}
ArgValidator.checkFieldNotNull(param.getUnassignfrom(), "unassign_from");
Set<URI> unassignFrom = param.getUnassignfrom();
if (unassignFrom != null) {
for (URI uri : unassignFrom) {
canUserUnAssignPolicyAtGivenLevel(filepolicy, uri);
if (!filepolicy.getAssignedResources().contains(uri.toString())) {
errorMsg.append("Provided resource URI is either being not assigned to the file policy:" + filepolicy.getId() + " or it is a invalid URI");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyUnAssignParam(filepolicy.getFilePolicyName(), errorMsg.toString());
}
}
}
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
controller.unassignFilePolicy(filepolicy.getId(), unassignFrom, task);
auditOp(OperationTypeEnum.UNASSIGN_FILE_POLICY, true, "BEGIN", filepolicy.getId().toString(), filepolicy.getLabel());
} catch (BadRequestException e) {
op = _dbClient.error(FilePolicy.class, filepolicy.getId(), task, e);
_log.error("Error Unassigning File policy {}, {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
_log.error("Error Unassigning Files Policy {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(filepolicy, task, op);
}
use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController in project coprhd-controller by CoprHD.
the class AbstractFileServiceApiImpl method expandFileShare.
/**
* Expand fileshare
*/
@Override
public void expandFileShare(FileShare fileshare, Long newSize, String taskId) throws InternalException {
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
final List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
if (fileshare.getParentFileShare() != null && fileshare.getPersonality().equals(FileShare.PersonalityTypes.TARGET.name())) {
throw APIException.badRequests.expandMirrorFileSupportedOnlyOnSource(fileshare.getId());
} else {
List<String> targetfileUris = new ArrayList<String>();
// if filesystem is target then throw exception
if (fileshare.getMirrorfsTargets() != null && !fileshare.getMirrorfsTargets().isEmpty()) {
targetfileUris.addAll(fileshare.getMirrorfsTargets());
}
FileDescriptor descriptor = new FileDescriptor(FileDescriptor.Type.FILE_DATA, fileshare.getStorageDevice(), fileshare.getId(), fileshare.getPool(), "", false, newSize);
fileDescriptors.add(descriptor);
// Prepare the descriptor for targets
for (String target : targetfileUris) {
FileShare targetFileShare = _dbClient.queryObject(FileShare.class, URI.create(target));
descriptor = new FileDescriptor(FileDescriptor.Type.FILE_DATA, targetFileShare.getStorageDevice(), targetFileShare.getId(), targetFileShare.getPool(), "", false, newSize);
fileDescriptors.add(descriptor);
}
}
// place the expand filesystem call in queue
controller.expandFileSystem(fileDescriptors, taskId);
}
use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController in project coprhd-controller by CoprHD.
the class AbstractFileServiceApiImpl method snapshotFS.
@Override
public void snapshotFS(URI storage, URI snapshot, URI fsURI, String opId) throws InternalException {
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
controller.snapshotFS(storage, snapshot, fsURI, opId);
}
use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController in project coprhd-controller by CoprHD.
the class AbstractFileServiceApiImpl method assignFileReplicationPolicyToVirtualPools.
@Override
public void assignFileReplicationPolicyToVirtualPools(List<FileStorageSystemAssociation> associations, List<URI> vpoolURIs, URI filePolicyToAssign, String taskId) {
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
controller.assignFileReplicationPolicyToVirtualPools(associations, vpoolURIs, filePolicyToAssign, taskId);
}
use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController in project coprhd-controller by CoprHD.
the class AbstractFileServiceApiImpl method failbackFileShare.
@Override
public void failbackFileShare(URI fsURI, StoragePort nfsPort, StoragePort cifsPort, boolean replicateConfiguration, String taskId) {
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
controller.failbackFileSystem(fsURI, nfsPort, cifsPort, replicateConfiguration, taskId);
}
Aggregations