use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class CIMConnectionFactory method addConnection.
/**
* If connection is null, create a new Connection
*
* @param smisIPAddress
*/
private synchronized CimConnection addConnection(String smisIPAddress, String port) {
CimConnection connection = null;
try {
connection = _connectionManager.getConnection(smisIPAddress, Integer.parseInt(port));
if (null == connection) {
String smisAltId = smisIPAddress + "-" + port;
List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, smisAltId);
if (providers.isEmpty()) {
_log.error("No SMISProvider found with id {}", smisAltId);
return connection;
}
StorageProvider smisProvider = providers.get(0);
final CimConnectionInfo connInfo = new CimConnectionInfo();
connInfo.setHost(smisProvider.getIPAddress());
connInfo.setPort(smisProvider.getPortNumber());
connInfo.setUser(smisProvider.getUserName());
connInfo.setPassword(smisProvider.getPassword());
connInfo.setUseSSL(smisProvider.getUseSSL());
if (smisProvider.getInterfaceType().equals(StorageProvider.InterfaceType.ibmxiv.name()) || "IBM".equals(smisProvider.getManufacturer())) {
connInfo.setType(CimConstants.CIM_CONNECTION_TYPE);
connInfo.setImplNS(CimConstants.DFLT_IBM_CIM_CONNECTION_IMPL_NS);
} else {
connInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
connInfo.setImplNS(CimConstants.DFLT_CIM_CONNECTION_IMPL_NS);
}
connInfo.setInteropNS(CimConstants.DFLT_CIM_CONNECTION_INTEROP_NS);
_connectionManager.addConnection(connInfo);
connection = _connectionManager.getConnection(smisIPAddress, Integer.parseInt(port));
_log.info("Connection Added to Cache {}", ConnectionManager.generateConnectionCacheKey(smisProvider.getIPAddress(), smisProvider.getPortNumber()));
}
} catch (ConnectionManagerException ex) {
_log.error("Exception occurred while adding connections due to ", ex);
} catch (Exception ex) {
_log.error("Exception occurred while adding connections due to ", ex);
}
return connection;
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class SMISProviderService method queryResource.
@Override
protected StorageProvider queryResource(URI id) {
ArgValidator.checkUri(id);
StorageProvider smisProvider = _dbClient.queryObject(StorageProvider.class, id);
ArgValidator.checkEntityNotNull(smisProvider, id, isIdEmbeddedInURL(id));
return smisProvider;
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class SMISProviderService method updateStorageSystem.
/**
* Allows the user to update credentials for a storage system that
* is not connected to any SMIS Provider.
* This update call is applicable to systems that cannot be discovered
* via an SMI-S provider.
* This API call creates an asynchronous operation to add providers to the SMI-S provider,
* verifies that the storage system is visible through the provider, and performs discovery of
* the storage system
* Note: only vnxblock can be actively connected to the SMIS provider. VMAX skips this step,
* the system must be visible to the SMIS provider beforehand.
* <p>
* The method is deprecated. Use /vdc/storage-providers/storage-systems/{system_id} instead.
*
* @param id the URN of a ViPR SMI-S provider
* @param param The storage system details to update.
*
* @brief Update storage system credentials and the list of SMI-S providers
* @return A TaskResourceRep reference specifying the storage system
* data.
* @throws ControllerException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/storage-systems/{system_id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public TaskResourceRep updateStorageSystem(@PathParam("id") URI id, StorageSystemSMISUpdateParam param) throws ControllerException {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
if (system.getSystemType().equals(StorageSystem.Type.vmax.name())) {
throw APIException.badRequests.unableToUpdateStorageSystem(StorageSystem.Type.vmax.name());
}
String taskId = UUID.randomUUID().toString();
if (param.getSmisProviders() == null || param.getSmisProviders().isEmpty()) {
throw APIException.badRequests.invalidParameterSMISProviderListIsEmpty();
}
URI[] providers = new URI[param.getSmisProviders().size()];
int idx = 0;
for (URI provider : param.getSmisProviders()) {
StorageProvider providerObj = _dbClient.queryObject(StorageProvider.class, provider);
ArgValidator.checkEntity(providerObj, provider, isIdEmbeddedInURL(provider));
if (!providerObj.connected()) {
throw APIException.badRequests.invalidParameterSMISProviderNotConnected(providerObj.getIPAddress());
}
if (system.getProviders() != null && system.getProviders().contains(provider)) {
throw APIException.badRequests.invalidParameterSMISProviderAlreadyRegistered(providerObj.getIPAddress());
}
if (system.getProviders() != null && system.getProviders().contains(provider)) {
throw APIException.badRequests.invalidParameterSMISProviderAlreadyRegistered(providerObj.getIPAddress());
}
providers[idx++] = provider;
}
updateStorageObj(system, param);
// Update SMIS Providers for the storage
BlockController controller = getController(BlockController.class, system.getSystemType());
Operation op = _dbClient.createTaskOpStatus(StorageSystem.class, system.getId(), taskId, ResourceOperationTypeEnum.UPDATE_STORAGE_SYSTEM);
boolean activeProvider = (system.getProviders() == null) || (system.getProviders().isEmpty());
controller.addStorageSystem(system.getId(), providers, activeProvider, taskId);
return toTask(system, taskId, op);
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class SMISProviderService method addStorageSystem.
/**
* Allows the user to manually create a SMIS managed storage system. This call is
* applicable to systems that cannot be discovered via an SMI-S provider.
* Only VNX storage system can be mapped programatically into SMIS Provider.
* Otherwise this method should be used to reinstall previously decommissioned Arrays.
* <p>
* The method is deprecated. Use /vdc/storage-providers/storage-systems instead.
*
* @param param The storage system details.
*
* @brief Create a storage system and add it to the SMI-S providers.
* @return An asynchronous task corresponding to the discovery job scheduled for the new Storage System.
*
* @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.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
@Path("/storage-systems")
public TaskResourceRep addStorageSystem(StorageSystemSMISCreateParam 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());
}
if ((Type.valueOf(param.getSystemType()) == Type.vnxblock) && StringUtils.isNotBlank(param.getIpAddress())) {
// If IP address is not null, the user will need to provide all remaining info
// to add VNX to the SMIS
ArgValidator.checkFieldNotEmpty(param.getSecondaryIPs(), "secondary_ips");
ArgValidator.checkFieldNotEmpty(param.getSecondaryIPs().get(0), "secondary_ips");
ArgValidator.checkFieldNotEmpty(param.getPassword(), "password");
ArgValidator.checkFieldNotEmpty(param.getUserName(), "userName");
}
if (param.getSmisProviders() == null || param.getSmisProviders().isEmpty()) {
throw APIException.badRequests.invalidParameterSMISProviderListIsEmpty();
}
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);
}
String taskId = UUID.randomUUID().toString();
URI[] providers = new URI[param.getSmisProviders().size()];
int idx = 0;
for (URI provider : param.getSmisProviders()) {
StorageProvider providerObj = _dbClient.queryObject(StorageProvider.class, provider);
ArgValidator.checkEntity(providerObj, provider, isIdEmbeddedInURL(provider));
if (!providerObj.connected()) {
throw APIException.badRequests.invalidParameterSMISProviderNotConnected(providerObj.getIPAddress());
}
providers[idx++] = provider;
}
StorageSystem system = prepareStorageSystem(param);
BlockController controller = getController(BlockController.class, param.getSystemType());
Operation op = _dbClient.createTaskOpStatus(StorageSystem.class, system.getId(), taskId, ResourceOperationTypeEnum.CREATE_STORAGE_SYSTEM);
controller.addStorageSystem(system.getId(), providers, true, taskId);
return toTask(system, taskId, op);
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class SMISProviderService method getSMISProvider.
/**
* This call allows user to fetch SMI-S Provider details such as provider
* host access credential details.
* <p>
* The method is deprecated. Use /vdc/storage-providers/{id} instead.
*
* @param id the URN of a ViPR SMIS-Provider
* @brief Show SMI-S provider
* @return SMIS-Provider details.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public SMISProviderRestRep getSMISProvider(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, StorageProvider.class, "id");
StorageProvider smisProvider = queryResource(id);
return mapStorageProviderToSMISRep(smisProvider);
}
Aggregations