/** * Get zone role assignments * * @brief List zone role assignments * @return Role assignment details */ @GET @Path("/deactivated-systems") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @CheckPermission(roles = {Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN}) public DecommissionedResources getDecommissionedResources() { List<URI> resList = _dbClient.queryByType(DecommissionedResource.class, true); DecommissionedResources results = new DecommissionedResources(); for (URI res : resList) { DecommissionedResource resource = _dbClient.queryObject(DecommissionedResource.class, res); if ("StorageSystem".equals(resource.getType())) { results.addResource(map(resource)); } } return results; }
/** * Allows the user to remove a storage system from the list of decommisioned resources After that * corresponding provider should be able to be rescanned and add this system back to the list of * managed systems. * * @param id id the URN of a ViPR Storage provider * @param param The storage system details. * @brief removes the storage system from the list of decommissioned systems and rescans the * provider. * @return An asynchronous task corresponding to the scan job scheduled for the provider. * @throws BadRequestException When the system type is not valid or a storage system with the same * native guid already exists. * @throws com.emc.storageos.db.exceptions.DatabaseException When an error occurs querying the * database. * @throws ControllerException When an error occurs discovering the storage system. */ @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @CheckPermission(roles = {Role.SYSTEM_ADMIN}) @Path("/{id}/storage-systems") public TaskResourceRep addStorageSystem( @PathParam("id") URI id, StorageSystemProviderRequestParam param) throws ControllerException { TaskResourceRep taskRep; URIQueryResultList list = new URIQueryResultList(); ArgValidator.checkFieldNotEmpty(param.getSystemType(), "system_type"); if (!StorageSystem.Type.isProviderStorageSystem( DiscoveredDataObject.Type.valueOf(param.getSystemType()))) { throw APIException.badRequests.cannotAddStorageSystemTypeToStorageProvider( param.getSystemType()); } StorageProvider provider = _dbClient.queryObject(StorageProvider.class, id); ArgValidator.checkEntityNotNull(provider, id, isIdEmbeddedInURL(id)); ArgValidator.checkFieldNotEmpty(param.getSerialNumber(), "serialNumber"); String nativeGuid = NativeGUIDGenerator.generateNativeGuid(param.getSystemType(), param.getSerialNumber()); // check for duplicate StorageSystem. List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, nativeGuid); if (systems != null && !systems.isEmpty()) { throw APIException.badRequests.invalidParameterProviderStorageSystemAlreadyExists( "nativeGuid", nativeGuid); } int cleared = DecommissionedResource.removeDecommissionedFlag(_dbClient, nativeGuid, StorageSystem.class); if (cleared == 0) { log.info("Cleared {} decommissioned systems", cleared); } else { log.info("Did not find any decommissioned systems to clear. Continue to scan."); } ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1); String taskId = UUID.randomUUID().toString(); tasks.add(new AsyncTask(StorageProvider.class, provider.getId(), taskId)); BlockController controller = getController(BlockController.class, provider.getInterfaceType()); DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller)); TaskList taskList = scheduler.scheduleAsyncTasks(tasks); return taskList.getTaskList().listIterator().next(); }