Search in sources :

Example 56 with StorageProvider

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

the class XtremioStorageSystemToStorageProviderMigration method process.

/**
 * 1. Iterate each storage systems.
 * a) Create new StorageProvider instance per xtremio storage system instance available in db.
 * b) Update the newly created storage provider Id reference with the xtremio storage system using provider.setStorageSystems().
 * c) Need to change storageSystem.activeProviderURI and storageSystem.getProviders() with the newly created
 * StorageProvider id.
 */
@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    try {
        List<URI> storageSystemURIList = dbClient.queryByType(StorageSystem.class, true);
        List<StorageSystem> storageSystemsList = dbClient.queryObject(StorageSystem.class, storageSystemURIList);
        Iterator<StorageSystem> systemItr = storageSystemsList.iterator();
        List<StorageSystem> systemsToUpdate = new ArrayList<StorageSystem>();
        List<StorageProvider> storageProvidersToCreate = new ArrayList<StorageProvider>();
        while (systemItr.hasNext()) {
            StorageSystem storageSystem = systemItr.next();
            // perform storagesystem upgrade only for XtremIO storagesystems.
            if (DiscoveredDataObject.Type.xtremio.name().equalsIgnoreCase(storageSystem.getSystemType())) {
                storageProvidersToCreate.add(createNewStorageProviderInstance(storageSystem));
            }
        }
        dbClient.createObject(storageProvidersToCreate);
        // persist all systems here.
        dbClient.persistObject(systemsToUpdate);
    } catch (Exception e) {
        log.error("Exception occured while updating xtremio storagesystem to storage provider model");
        log.error(e.getMessage(), e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 57 with StorageProvider

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

the class XtremioStorageSystemToStorageProviderMigration method createNewStorageProviderInstance.

/**
 * Creates new StorageProvider instance for the given storage system while doing db upgrade.
 *
 * @param smisProvider
 * @return {@link StorageProvider} newly created StorageProvider instance
 */
private StorageProvider createNewStorageProviderInstance(StorageSystem xioSystem) {
    log.info("Creating a new storage provider for storage system {}", xioSystem.getLabel());
    StorageProvider storageProvider = new StorageProvider();
    storageProvider.setId(URIUtil.createId(StorageProvider.class));
    storageProvider.setCompatibilityStatus(xioSystem.getCompatibilityStatus());
    // Set connectionStatus as Connected always, Let scan validate the connection later.
    storageProvider.setConnectionStatus(StorageProvider.ConnectionStatus.CONNECTED.name());
    storageProvider.setCreationTime(xioSystem.getCreationTime());
    storageProvider.setInterfaceType(StorageProvider.InterfaceType.xtremio.name());
    storageProvider.setIPAddress(xioSystem.getIpAddress());
    storageProvider.setLabel(xioSystem.getLabel());
    storageProvider.setLastScanStatusMessage(xioSystem.getLastDiscoveryStatusMessage());
    storageProvider.setLastScanTime(xioSystem.getLastDiscoveryRunTime());
    storageProvider.setPassword(xioSystem.getPassword());
    storageProvider.setPortNumber(xioSystem.getPortNumber());
    storageProvider.setRegistrationStatus(xioSystem.getRegistrationStatus());
    storageProvider.setScanStatus(xioSystem.getDiscoveryStatus());
    storageProvider.setOpStatus(xioSystem.getOpStatus());
    storageProvider.setSuccessScanTime(xioSystem.getSuccessDiscoveryTime());
    storageProvider.setTag(xioSystem.getTag());
    storageProvider.setUserName(xioSystem.getUsername());
    storageProvider.setVersionString(xioSystem.getFirmwareVersion());
    log.info("Adding the storage system to the storage provider");
    storageProvider.addStorageSystem(dbClient, xioSystem, true);
    return storageProvider;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider)

Example 58 with StorageProvider

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

the class DataDomainFileStorageDevice method getDataDomainClient.

/**
 * Get DataDomain device represented by the StorageDevice
 *
 * @param device StorageDevice object
 * @return DataDomainClient object
 * @throws com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException
 */
private DataDomainClient getDataDomainClient(StorageSystem device) throws DataDomainApiException {
    URI providerId = device.getActiveProviderURI();
    StorageProvider provider = null;
    if (providerId != null) {
        provider = _dbClient.queryObject(StorageProvider.class, providerId);
    }
    DataDomainClient ddClient = null;
    if (provider != null) {
        ddClient = (DataDomainClient) _factory.getRESTClient(DataDomainApiConstants.newDataDomainBaseURI(device.getSmisProviderIP(), device.getSmisPortNumber()), provider.getUserName(), provider.getPassword());
    }
    return ddClient;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient)

Example 59 with StorageProvider

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

the class DataDomainUtils method refreshDDConnections.

/**
 * Refresh DataDomain connections.
 *
 * @param ddProviderList the DataDomain provider list
 * @param dbClient the db client
 * @return the list of active providers
 */
public static List<URI> refreshDDConnections(final List<StorageProvider> ddProviderList, DbClient dbClient, DataDomainClientFactory ddClientFactory) {
    List<URI> activeProviders = new ArrayList<URI>();
    for (StorageProvider storageProvider : ddProviderList) {
        try {
            // Is the DDMC reachable
            DataDomainClient ddClient = getDataDomainClient(storageProvider, ddClientFactory);
            if (ddClient == null) {
                storageProvider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
                _log.error("Storage Provider {} is not reachable", storageProvider.getIPAddress());
            } else {
                ddClient.getManagementSystemInfo();
                storageProvider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
                activeProviders.add(storageProvider.getId());
                _log.info("Storage Provider {} is reachable", storageProvider.getIPAddress());
            }
        } catch (Exception e) {
            storageProvider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
            _log.error("Storage Provider {} is not reachable", storageProvider.getIPAddress());
        } finally {
            dbClient.persistObject(storageProvider);
        }
    }
    return activeProviders;
}
Also used : ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)

Example 60 with StorageProvider

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

the class HDSStorageDevice method validateStorageProviderConnection.

@Override
public boolean validateStorageProviderConnection(String ipAddress, Integer portNumber) {
    boolean isConnectionValid = false;
    try {
        StringBuffer providerID = new StringBuffer(ipAddress).append(HDSConstants.HYPHEN_OPERATOR).append(portNumber);
        URIQueryResultList providerUriList = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageProviderByProviderIDConstraint(providerID.toString()), providerUriList);
        if (providerUriList.iterator().hasNext()) {
            StorageProvider provider = dbClient.queryObject(StorageProvider.class, providerUriList.iterator().next());
            HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(provider), provider.getUserName(), provider.getPassword());
            List<StorageArray> storageArrayList = hdsApiClient.getStorageSystemsInfo();
            if (null != storageArrayList && !storageArrayList.isEmpty()) {
                isConnectionValid = true;
            }
        }
    } catch (Exception ex) {
        log.error("Problem in checking provider live connection for ipaddress: {} due to", ipAddress, ex);
    }
    return isConnectionValid;
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) StorageArray(com.emc.storageos.hds.model.StorageArray)

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