use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class SMISProviderService method updateSMISProvider.
/**
* Update the SMISProvider. This is useful when we move arrays to some other
* provider.
* <p>
* The method is deprecated. Use /vdc/storage-providers/{id} instead.
*
* @param id the URN of a ViPR SMIS-Provider
* @brief Update SMI-S provider
* @return Updated SMIS-Provider information.
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public SMISProviderRestRep updateSMISProvider(@PathParam("id") URI id, SMISProviderUpdateParam param) {
StorageProvider smisProvider = _dbClient.queryObject(StorageProvider.class, id);
if (null == smisProvider) {
throw APIException.notFound.unableToFindEntityInURL(id);
} else if (!smisProvider.getInactive()) {
/*
* Usecase is not to remove the provider instead we can update the old smisprovider with
* new provider details.
*/
if (param.getName() != null && !param.getName().equals("") && !param.getName().equalsIgnoreCase(smisProvider.getLabel())) {
checkForDuplicateName(param.getName(), StorageProvider.class);
smisProvider.setLabel(param.getName());
}
// if the ip or port passed are different from the existing one
// check to ensure a provider does not exist with the new ip + port combo
String existingIPAddress = smisProvider.getIPAddress();
Integer existingPortNumber = smisProvider.getPortNumber();
if ((param.getIpAddress() != null && !param.getIpAddress().equals(existingIPAddress)) || (param.getPortNumber() != null && !param.getPortNumber().equals(existingPortNumber))) {
String ipAddress = (param.getIpAddress() != null) ? param.getIpAddress() : existingIPAddress;
Integer portNumber = (param.getPortNumber() != null) ? param.getPortNumber() : existingPortNumber;
ArgValidator.checkFieldRange(portNumber, 1, 65535, "port_number");
String providerKey = ipAddress + "-" + portNumber;
List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerKey);
if (providers != null && !providers.isEmpty()) {
throw APIException.badRequests.invalidParameterSMISProviderAlreadyRegistered(providerKey);
}
// if and only if the connection with old IP is not alive.
if (!existingIPAddress.equals(param.getIpAddress()) && isOldConnectionAlive(existingIPAddress, existingPortNumber, smisProvider.getInterfaceType())) {
throw APIException.badRequests.cannotUpdateProviderIP(existingIPAddress + "-" + existingPortNumber);
}
smisProvider.setIPAddress(ipAddress);
smisProvider.setPortNumber(portNumber);
}
if (param.getUserName() != null && !param.getUserName().equals("")) {
smisProvider.setUserName(param.getUserName());
}
if (param.getPassword() != null && !param.getPassword().equals("")) {
smisProvider.setPassword(param.getPassword());
}
if (param.getUseSSL() != null) {
smisProvider.setUseSSL(param.getUseSSL());
}
_dbClient.persistObject(smisProvider);
}
auditOp(OperationTypeEnum.UPDATE_SMISPROVIDER, true, null, smisProvider.getId().toString(), smisProvider.getLabel(), smisProvider.getIPAddress(), smisProvider.getPortNumber(), smisProvider.getUserName());
return mapStorageProviderToSMISRep(smisProvider);
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class SMISProviderService method getDecommissionedResources.
/**
* Get zone role assignments
* The method is deprecated. Use /vdc/storage-providers/deactivated-systems
*
* @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 })
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 SMISProviderService method getStorageSystem.
/**
* Allows the user to get data for the storage system with the passed system
* id that is associated with the SMI-S provider with the passed provider
* id.
* <p>
* The method is deprecated. Use /vdc/storage-providers/{id}/storage-systems/{systemId}
*
* @param id the URN of a ViPR SMI-S provider
* @param systemId The id of the storage system.
*
* @brief Show SMI-S provider storage system
* @return A StorageSystemRestRep reference specifying the data for the
* storage system.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-systems/{systemId}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemRestRep getStorageSystem(@PathParam("id") URI id, @PathParam("systemId") URI systemId) {
// Validate the provider.
ArgValidator.checkFieldUriType(id, StorageProvider.class, "id");
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, id);
ArgValidator.checkEntityNotNull(provider, id, isIdEmbeddedInURL(id));
// Return the storage system if found.
StringSet providerSystemURIStrs = provider.getStorageSystems();
if (providerSystemURIStrs != null) {
for (String providerSystemURIStr : providerSystemURIStrs) {
if (providerSystemURIStr.equals(systemId.toString())) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, URI.create(providerSystemURIStr));
if (storageSystem != null) {
return map(storageSystem);
}
break;
}
}
}
throw APIException.notFound.unableToFindEntityInURL(id);
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class SMISProviderService method scanSMISProviders.
/**
* Scan all SMI-S providers.
* <p>
* The method is deprecated. Use /vdc/storage-providers/scan instead.
*
* @brief Scan SMI-S 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 })
@Path("/scan")
public TaskList scanSMISProviders() {
TaskList taskList = new TaskList();
List<StorageProvider> providerList = CustomQueryUtility.getActiveStorageProvidersByInterfaceType(_dbClient, StorageProvider.InterfaceType.smis.name());
if (providerList == null || providerList.isEmpty()) {
return taskList;
}
BlockController controller = getController(BlockController.class, "vnxblock");
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ScanJobExec(controller));
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
for (StorageProvider smisProvider : providerList) {
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(StorageProvider.class, smisProvider.getId(), taskId));
}
taskList = scheduler.scheduleAsyncTasks(tasks);
return taskList;
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class SMISProviderService method getSmiSProviderList.
/**
* This function allows user to fetch list of all SMI-S Providers information.
* <p>
* The method is deprecated. Use /vdc/storage-providers instead.
*
* @brief List SMI-S providers
* @return List of SMIS-Providers.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public SMISProviderList getSmiSProviderList() {
List<StorageProvider> providerList = CustomQueryUtility.getActiveStorageProvidersByInterfaceType(_dbClient, StorageProvider.InterfaceType.smis.name());
/*
* List<URI> ids = _dbClient.queryByType(SMISProvider.class);
* List<SMISProvider> smisProviders = _dbClient.queryObject(SMISProvider.class, ids);
* if (smisProviders == null) {
* throw APIException.badRequests.unableToFindSMISProvidersForIds(ids);
* }
*/
SMISProviderList smisProviderList = new SMISProviderList();
for (StorageProvider provider : providerList) {
smisProviderList.getSmisProviders().add(toNamedRelatedResource(ResourceTypeEnum.SMIS_PROVIDER, provider.getId(), provider.getLabel()));
}
return smisProviderList;
}
Aggregations