Search in sources :

Example 81 with StorageProvider

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;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) IOException(java.io.IOException) CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)

Example 82 with StorageProvider

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;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider)

Example 83 with StorageProvider

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);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) Operation(com.emc.storageos.db.client.model.Operation) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 84 with StorageProvider

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);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 85 with StorageProvider

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);
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

StorageProvider (com.emc.storageos.db.client.model.StorageProvider)97 URI (java.net.URI)44 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)26 ArrayList (java.util.ArrayList)24 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)23 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 Produces (javax.ws.rs.Produces)19 IOException (java.io.IOException)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)15 Path (javax.ws.rs.Path)15 Consumes (javax.ws.rs.Consumes)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 MapStorageProvider (com.emc.storageos.api.mapper.functions.MapStorageProvider)8 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)7 BlockController (com.emc.storageos.volumecontroller.BlockController)7