Search in sources :

Example 51 with StorageProvider

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

the class SMISProviderToStorageProviderMigration method process.

/**
 * 1. Create new StorageProvider instance per smis provider instance available in db.
 * 2. Populate all existing fields into new StorageProvider instance except id and interfaceType.
 * 3. Generate new id for the new instance. interfaceType will be "smis" in this case.
 * 4. Persist new instance into db.
 * 5: Update the newly created storage provider Id reference with the all storage systems managed by smis provider.
 * a) : Fetch storageSystems using provider.getStorageSystems()
 * b) : Iterate each storage systems.
 * c) : Needs to change storageSystem.activeProviderURI and storageSystem.getProviders() with the newly created
 * StorageProvider id. In this step we need to remove the existing smis provider id add new storage provider id
 */
@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    try {
        List<URI> smisProviderURIList = dbClient.queryByType(SMISProvider.class, true);
        Iterator<SMISProvider> smisProviderListIterator = dbClient.queryIterativeObjects(SMISProvider.class, smisProviderURIList);
        while (smisProviderListIterator.hasNext()) {
            SMISProvider smisProvider = smisProviderListIterator.next();
            StorageProvider newStorageProvider = createNewStorageProviderInstance(smisProvider);
            dbClient.createObject(newStorageProvider);
            StringSet storageSystemSet = smisProvider.getStorageSystems();
            if (storageSystemSet != null) {
                for (String strStorageSystem : storageSystemSet) {
                    URI storageSystemURI = URI.create(strStorageSystem);
                    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
                    updateStorageProvidersforStorageSystems(dbClient, storageSystem, smisProvider, newStorageProvider);
                    smisProvider.setInactive(true);
                    dbClient.persistObject(smisProvider);
                }
            }
        }
        // Handle VPLEX storage systems, which are now discovered using the
        // StorageProvider model.
        List<URI> storageSystemURIs = dbClient.queryByType(StorageSystem.class, true);
        Iterator<StorageSystem> storageSystemIter = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemURIs);
        while (storageSystemIter.hasNext()) {
            StorageSystem storageSystem = storageSystemIter.next();
            if (DiscoveredDataObject.Type.vplex.name().equals(storageSystem.getSystemType())) {
                createStorageProviderForVPlexSystem(storageSystem);
            }
        }
    } catch (Exception e) {
        log.error("Exception occured while migrating SMISProvider CF to StorageProvider");
        log.error(e.getMessage(), e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) SMISProvider(com.emc.storageos.db.client.model.SMISProvider) StringSet(com.emc.storageos.db.client.model.StringSet) 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 52 with StorageProvider

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

the class SMISProviderToStorageProviderMigration method createStorageProviderForVPlexSystem.

/**
 * Creates a new storage provider representing the VPLEX management server
 * used to manage the pass VPLEX storage system. Also, updates the VPLEX
 * storage system itself to set the provider list and active provider to
 * this new storage provider.
 *
 * @param vplexSystem An active VPLEX storage system in ViPR.
 */
private void createStorageProviderForVPlexSystem(StorageSystem vplexSystem) {
    // We'll create a new storage provider representing the VPLEX management
    // server used to manage this VPLEX storage system.
    StorageProvider vplexMgmntSvr = new StorageProvider();
    URI vplexMgmntSvrURI = URIUtil.createId(StorageProvider.class);
    vplexMgmntSvr.setId(vplexMgmntSvrURI);
    vplexMgmntSvr.setInterfaceType(StorageProvider.InterfaceType.vplex.name());
    vplexMgmntSvr.setIPAddress(vplexSystem.getIpAddress());
    vplexMgmntSvr.setPortNumber(vplexSystem.getPortNumber());
    vplexMgmntSvr.setUseSSL(Boolean.TRUE);
    vplexMgmntSvr.setUserName(vplexSystem.getUsername());
    vplexMgmntSvr.setPassword(vplexSystem.getPassword());
    vplexMgmntSvr.setLabel(vplexSystem.getLabel());
    vplexMgmntSvr.setVersionString(vplexSystem.getFirmwareVersion());
    vplexMgmntSvr.setCompatibilityStatus(vplexSystem.getCompatibilityStatus());
    vplexMgmntSvr.setRegistrationStatus(vplexSystem.getRegistrationStatus());
    vplexMgmntSvr.setConnectionStatus(StorageProvider.ConnectionStatus.CONNECTED.name());
    StringSet managedStorageSystems = new StringSet();
    managedStorageSystems.add(vplexSystem.getId().toString());
    vplexMgmntSvr.setStorageSystems(managedStorageSystems);
    dbClient.createObject(vplexMgmntSvr);
    // Now update the providers and active provider for the VPLEX system.
    StringSet vplexMgmntServers = new StringSet();
    vplexMgmntServers.add(vplexMgmntSvrURI.toString());
    vplexSystem.setProviders(vplexMgmntServers);
    vplexSystem.setActiveProviderURI(vplexMgmntSvrURI);
    dbClient.updateAndReindexObject(vplexSystem);
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI)

Example 53 with StorageProvider

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

the class SMISProviderToStorageProviderMigration method createNewStorageProviderInstance.

/**
 * Creates new StorageProvider instance for the given smis provider while doing db upgrade.
 *
 * @param smisProvider
 * @return {@link StorageProvider} newly created StorageProvider instance
 */
private StorageProvider createNewStorageProviderInstance(SMISProvider smisProvider) {
    StorageProvider storageProvider = new StorageProvider();
    storageProvider.setId(URIUtil.createId(StorageProvider.class));
    storageProvider.setCompatibilityStatus(smisProvider.getCompatibilityStatus());
    storageProvider.setConnectionStatus(smisProvider.getConnectionStatus());
    storageProvider.setCreationTime(smisProvider.getCreationTime());
    storageProvider.setDecommissionedSystems(smisProvider.getDecommissionedSystems());
    storageProvider.setDescription(smisProvider.getDescription());
    storageProvider.setInterfaceType(StorageProvider.InterfaceType.smis.name());
    storageProvider.setIPAddress(smisProvider.getIPAddress());
    storageProvider.setLabel(smisProvider.getLabel());
    storageProvider.setLastScanStatusMessage(smisProvider.getLastScanStatusMessage());
    storageProvider.setLastScanTime(smisProvider.getLastScanTime());
    storageProvider.setManufacturer(smisProvider.getManufacturer());
    storageProvider.setNextScanTime(smisProvider.getNextScanTime());
    storageProvider.setPassword(smisProvider.getPassword());
    storageProvider.setPortNumber(smisProvider.getPortNumber());
    storageProvider.setProviderID(smisProvider.getProviderID());
    storageProvider.setRegistrationStatus(smisProvider.getRegistrationStatus());
    storageProvider.setScanStatus(smisProvider.getScanStatus());
    storageProvider.setOpStatus(smisProvider.getOpStatus());
    StringSet storageSystems = smisProvider.getStorageSystems();
    if (storageSystems != null) {
        StringSet newStoargeSystems = new StringSet();
        newStoargeSystems.addAll(storageSystems);
        storageProvider.setStorageSystems(newStoargeSystems);
    }
    storageProvider.setSuccessScanTime(smisProvider.getSuccessScanTime());
    storageProvider.setTag(smisProvider.getTag());
    storageProvider.setUserName(smisProvider.getUserName());
    storageProvider.setUseSSL(smisProvider.getUseSSL());
    storageProvider.setVersionString(smisProvider.getVersionString());
    return storageProvider;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) StorageProvider(com.emc.storageos.db.client.model.StorageProvider)

Example 54 with StorageProvider

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

the class XioStorageSystemToStorageProviderMigrationTest method verifyResults.

@Override
protected void verifyResults() throws Exception {
    List<URI> storageSystemKeys = _dbClient.queryByType(StorageSystem.class, true);
    Iterator<StorageSystem> iter = _dbClient.queryIterativeObjects(StorageSystem.class, storageSystemKeys);
    while (iter.hasNext()) {
        StorageSystem storageSystem = iter.next();
        if (DiscoveredDataObject.Type.xtremio.name().equals(storageSystem.getSystemType())) {
            URI providerURI = storageSystem.getActiveProviderURI();
            Assert.assertNotNull("XtremIO storage system should have an active provider associated.", providerURI);
            StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerURI);
            Assert.assertTrue("Storage provider is not associated with the xtremio storage system", provider.getStorageSystems().contains(storageSystem.getId().toString()));
        }
    }
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 55 with StorageProvider

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

the class StoragePortHADomainPopulater method createStorageAdapter.

private StorageHADomain createStorageAdapter(StorageSystem storageSystem, DbClient dbClient) {
    String cinderHostName = "";
    URI providerUri = storageSystem.getActiveProviderURI();
    StorageProvider provider = dbClient.queryObject(StorageProvider.class, providerUri);
    if (null != provider && null != provider.getKeys()) {
        cinderHostName = provider.getKeyValue("CINDER_HOST_NAME");
    }
    String adapterNativeGUID = generateNativeGuid(storageSystem, cinderHostName, "ADAPTER");
    StorageHADomain adapter = new StorageHADomain();
    adapter.setStorageDeviceURI(storageSystem.getId());
    adapter.setId(URIUtil.createId(StorageHADomain.class));
    adapter.setAdapterName(cinderHostName);
    adapter.setLabel(cinderHostName);
    adapter.setNativeGuid(adapterNativeGUID);
    adapter.setNumberofPorts("1");
    adapter.setAdapterType(StorageHADomain.HADomainType.FRONTEND.name());
    adapter.setInactive(false);
    dbClient.createObject(adapter);
    return adapter;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) 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