use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.
the class MaskingWorkflowEntryPoints method doExportGroupRemoveVolumes.
public void doExportGroupRemoveVolumes(URI storageURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumeURIs, List<URI> initiatorURIs, TaskCompleter taskCompleter, String token) throws ControllerException {
String call = String.format("doExportGroupRemoveVolumes(%s, %s, %s, [%s], [%s], %s)", storageURI.toString(), exportGroupURI.toString(), exportMaskURI.toString(), volumeURIs != null ? Joiner.on(',').join(volumeURIs) : "No Volumes", initiatorURIs != null ? Joiner.on(',').join(initiatorURIs) : "No Initiators", taskCompleter.getOpId());
try {
WorkflowStepCompleter.stepExecuting(token);
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
List<Initiator> initiators = new ArrayList<>();
if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
}
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_017);
getDevice(storage).doExportRemoveVolumes(storage, exportMask, volumeURIs, initiators, taskCompleter);
_log.info(String.format("%s end", call));
} catch (final InternalException e) {
_log.info(call + " Encountered an exception", e);
taskCompleter.error(_dbClient, e);
} catch (final Exception e) {
_log.info(call + " Encountered an exception", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.
the class MaskingWorkflowEntryPoints method doExportMaskAddPaths.
public void doExportMaskAddPaths(URI storageURI, URI exportGroupURI, URI exportMaskURI, Map<URI, List<URI>> newPaths, TaskCompleter taskCompleter, String token) throws ControllerException {
String call = String.format("doExporMaskAddPaths(%s, %s, %s, %s, %s)", storageURI.toString(), exportGroupURI.toString(), exportMaskURI.toString(), newPaths != null ? Joiner.on(',').withKeyValueSeparator("=").join(newPaths) : "No path", taskCompleter.getOpId());
try {
_log.info(call + " starts");
WorkflowStepCompleter.stepExecuting(token);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
getDevice(storage).doExportAddPaths(storage, exportMaskURI, newPaths, taskCompleter);
_log.info(String.format("%s end", call));
} catch (final InternalException e) {
_log.info(call + " Encountered an exception", e);
taskCompleter.error(_dbClient, e);
} catch (final Exception e) {
_log.info(call + " Encountered an exception", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.
the class MaskingWorkflowEntryPoints method doExportGroupAddVolumes.
public void doExportGroupAddVolumes(URI storageURI, URI exportGroupURI, URI exportMaskURI, Map<URI, Integer> volumeMap, List<URI> initiatorURIs, TaskCompleter taskCompleter, String token) throws ControllerException {
String call = String.format("doExportGroupAddVolumes(%s, %s, %s, [%s], [%s], %s)", storageURI.toString(), exportGroupURI.toString(), exportMaskURI.toString(), volumeMap != null ? Joiner.on(',').join(volumeMap.entrySet()) : "No Volumes", initiatorURIs != null ? Joiner.on(',').join(initiatorURIs) : "No Initiators", taskCompleter.getOpId());
try {
WorkflowStepCompleter.stepExecuting(token);
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
List<Initiator> initiators = new ArrayList<>();
if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
}
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_001);
getDevice(storage).doExportAddVolumes(storage, exportMask, initiators, volumeMap, taskCompleter);
_log.info(String.format("%s end", call));
} catch (final InternalException e) {
_log.info(call + " Encountered an exception", e);
taskCompleter.error(_dbClient, e);
} catch (final Exception e) {
_log.info(call + " Encountered an exception", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.
the class MaskingWorkflowEntryPoints method doExportChangePortGroupAddPaths.
/**
* Calls to underlying storage device to do the add paths operation for change port group
*
* @param storageURI
* - Storage system URI
* @param exportGroupURI
* - Export group URI
* @param newMaskURI
* - New export mask URI
* @param oldMaskURI
* - Old export mask URI
* @param portGroupURI
* - The new port group URI
* @param taskCompleter
* - Task completer
* @param token
* - Task token
*/
public void doExportChangePortGroupAddPaths(URI storageURI, URI exportGroupURI, URI newMaskURI, URI oldMaskURI, URI portGroupURI, TaskCompleter taskCompleter, String token) {
try {
WorkflowStepCompleter.stepExecuting(token);
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
getDevice(storage).doExportChangePortGroupAddPaths(storage, newMaskURI, oldMaskURI, portGroupURI, taskCompleter);
} catch (final InternalException e) {
_log.info("doExportChangePortGroup Encountered an exception", e);
taskCompleter.error(_dbClient, e);
} catch (final Exception e) {
_log.info("doExportChangePortGroup Encountered an exception", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.
the class FileService method unAssignFilePolicy.
/**
* Unassign existing file system to file policy.
*
* @param id
* the URN of a ViPR fileSystem
* @param filePolicyUri
* the URN of a Policy
* @brief Update file system with Policy detail
* @return Task resource representation
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/unassign-file-policy/{filePolicyUri}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep unAssignFilePolicy(@PathParam("id") URI id, @PathParam("filePolicyUri") URI filePolicyUri) throws InternalException {
// log input received.
_log.info("Unassign Policy on File System : request received for {} with {}", id, filePolicyUri);
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));
ArgValidator.checkFieldUriType(filePolicyUri, FilePolicy.class, "filePolicyUri");
ArgValidator.checkUri(filePolicyUri);
FilePolicy fp = _permissionsHelper.getObjectById(filePolicyUri, FilePolicy.class);
ArgValidator.checkEntityNotNull(fp, filePolicyUri, isIdEmbeddedInURL(filePolicyUri));
// verify the schedule policy is associated with file system or not.
if (!fs.getFilePolicies().isEmpty() && !fs.getFilePolicies().contains(filePolicyUri.toString())) {
throw APIException.badRequests.cannotFindAssociatedPolicy(filePolicyUri);
}
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
Operation op = _dbClient.createTaskOpStatus(FilePolicy.class, fp.getId(), task, ResourceOperationTypeEnum.UNASSIGN_FILE_POLICY);
op.setDescription("Filesystem unassign policy");
// As the action done by tenant admin
// Set current tenant as task's tenant!!!
Task taskObj = op.getTask(fp.getId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, fp, "unassign", taskObj, fs.getTenant().getURI());
try {
Set<URI> unassignFrom = new HashSet<URI>();
unassignFrom.add(id);
_log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, fp });
controller.unassignFilePolicy(filePolicyUri, unassignFrom, task);
auditOp(OperationTypeEnum.UNASSIGN_FILE_POLICY, true, "BEGIN", fp.getId().toString(), fp.getFilePolicyName());
} catch (BadRequestException e) {
op = _dbClient.error(FilePolicy.class, fp.getId(), task, e);
_log.error("Error Unassigning File policy {}, {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
_log.error("Error Unassigning Filesystem policy {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(fp, task, op);
}
Aggregations