Search in sources :

Example 11 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider 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;
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) 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 12 with StorageProvider

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

Example 13 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class ExternalBlockStorageDevice method validateStorageProviderConnection.

public boolean validateStorageProviderConnection(StorageProvider storageProvider) {
    boolean isConnectionValid = false;
    try {
        // call driver to validate provider connection
        // get driver for the provider
        BlockStorageDriver driver = getDriver(storageProvider.getInterfaceType());
        String username = storageProvider.getUserName();
        String password = storageProvider.getPassword();
        String hostName = storageProvider.getIPAddress();
        Integer providerPortNumber = storageProvider.getPortNumber();
        String providerType = storageProvider.getInterfaceType();
        Boolean useSsl = storageProvider.getUseSSL();
        String msg = String.format("Storage provider info: type: %s, host: %s, port: %s, user: %s, useSsl: %s", providerType, hostName, providerPortNumber, username, useSsl);
        _log.info(msg);
        com.emc.storageos.storagedriver.model.StorageProvider driverProvider = new com.emc.storageos.storagedriver.model.StorageProvider();
        // initialize driver provider
        driverProvider.setProviderHost(hostName);
        driverProvider.setPortNumber(providerPortNumber);
        driverProvider.setUsername(username);
        driverProvider.setPassword(password);
        driverProvider.setUseSSL(useSsl);
        driverProvider.setProviderType(providerType);
        isConnectionValid = driver.validateStorageProviderConnection(driverProvider);
    } catch (Exception ex) {
        _log.error("Problem in checking connection of provider {} due to: ", storageProvider.getLabel(), ex);
    }
    return isConnectionValid;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 14 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class HDSUtils method refreshHDSConnections.

/**
 * makes simple rest call to device manager to validate the provider reachable state for passed hds providers
 *
 * @param hicommandProviderList List of HiCommandDevice Manager provider URIs
 * @param dbClient
 * @param hdsApiFactory
 * @return List of Active Storage Providers
 */
public static List<URI> refreshHDSConnections(final List<StorageProvider> hicommandProviderList, DbClient dbClient, HDSApiFactory hdsApiFactory) {
    List<URI> activeProviders = new ArrayList<URI>();
    for (StorageProvider storageProvider : hicommandProviderList) {
        try {
            HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageProvider), storageProvider.getUserName(), storageProvider.getPassword());
            // Makes sure "Hi Command Device manager" is reachable
            hdsApiClient.getStorageSystemsInfo();
            storageProvider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
            activeProviders.add(storageProvider.getId());
            log.info("Storage Provider {} is reachable", storageProvider.getIPAddress());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            storageProvider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
            log.error("Storage Provider {} is not reachable", storageProvider.getIPAddress());
        } finally {
            dbClient.persistObject(storageProvider);
        }
    }
    return activeProviders;
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) HDSException(com.emc.storageos.hds.HDSException)

Example 15 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class CephUtils method refreshCephConnections.

public static List<URI> refreshCephConnections(final List<StorageProvider> cephProviderList, DbClient dbClient) {
    List<URI> activeProviders = new ArrayList<URI>();
    for (StorageProvider storageProvider : cephProviderList) {
        try {
            ensureConnectToCeph(storageProvider);
            storageProvider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
            activeProviders.add(storageProvider.getId());
        } catch (Exception e) {
            _log.error(String.format("Failed to connect to Ceph %s: %s", storageProvider.getIPAddress(), storageProvider.getId()), e);
            storageProvider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
        } finally {
            dbClient.updateObject(storageProvider);
        }
    }
    return activeProviders;
}
Also used : ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI)

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