use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class StorageProviderService method scanStorageProviders.
/**
* Scan all Storage providers.
*
* @brief Scan Storage providers
* @return TasList of all created asynchronous tasks
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/scan")
public TaskList scanStorageProviders() {
TaskList taskList = new TaskList();
List<URI> providerURIList = _dbClient.queryByType(StorageProvider.class, true);
/**
* TODO needs to remove hard code device type to fetch the controller instance
*/
BlockController controller = getController(BlockController.class, "vnxblock");
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
if (providerURIList != null) {
for (URI providerURI : providerURIList) {
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageProvider.class, providerURI, taskId));
}
taskList = scheduler.scheduleAsyncTasks(tasks);
}
return taskList;
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class StorageProviderService method addStorageSystem.
/**
* Allows the user to add a storage system and rescans the provider.
* 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 Add a new storage system and rescan 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(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();
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class StorageProviderService method getDecommissionedResources.
/**
* 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;
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class StorageProviderService method getStorageProvider.
/**
* @brief Show Storage provider
* This call allows user to fetch Storage Provider details such as provider
* host access credential details.
*
* @param id Storage Provider Identifier
* @return Storage Provider details.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageProviderRestRep getStorageProvider(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageProvider.class, "id");
StorageProvider mgmtProvider = queryResource(id);
return map(mgmtProvider);
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class StorageProviderService method getStorageProviderList.
/**
* @brief List Storage providers
* This function allows user to fetch list of all Storage Providers information.
*
* @return List of Storage Providers.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageProviderList getStorageProviderList() {
List<URI> ids = _dbClient.queryByType(StorageProvider.class, true);
List<StorageProvider> mgmtProviders = _dbClient.queryObject(StorageProvider.class, ids);
if (mgmtProviders == null) {
throw APIException.badRequests.unableToFindStorageProvidersForIds(ids);
}
StorageProviderList providerList = new StorageProviderList();
for (StorageProvider provider : mgmtProviders) {
providerList.getStorageProviders().add(toNamedRelatedResource(provider));
}
return providerList;
}
Aggregations