Search in sources :

Example 1 with SMISProvider

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

the class DbSMISProviderToStorageProviderMigrationTest method validateSMISProviderInstances.

private void validateSMISProviderInstances(boolean isAfterMigration) {
    int size = 0;
    List<URI> keys = _dbClient.queryByType(SMISProvider.class, true);
    Iterator<SMISProvider> iter = _dbClient.queryIterativeObjects(SMISProvider.class, keys);
    while (iter.hasNext()) {
        size++;
        SMISProvider smisProvider = iter.next();
        StringSet storageSystems = smisProvider.getStorageSystems();
        Assert.assertNotNull(storageSystems);
        int storageSystemCount = 0;
        for (String storageSystemURI : storageSystems) {
            storageSystemCount++;
        }
        if (!isAfterMigration) {
            if ("smis1".equals(smisProvider.getLabel())) {
                Assert.assertEquals("StorageSystems count is mismatch for " + smisProvider.getLabel(), 2, storageSystemCount);
            } else if ("smis3".equals(smisProvider.getLabel()) || "smis2".equals(smisProvider.getLabel())) {
                Assert.assertEquals("StorageSystems count is mismatch for " + smisProvider.getLabel(), 1, storageSystemCount);
            }
        }
    }
    if (isAfterMigration) {
        Assert.assertEquals("SMISProvider instance should be removed after successful migration", 0, size);
    } else {
        Assert.assertEquals("SMISProvider instance size should be 3 before migration", 3, size);
    }
}
Also used : SMISProvider(com.emc.storageos.db.client.model.SMISProvider) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI)

Example 2 with SMISProvider

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

the class DbSMISProviderToStorageProviderMigrationTest method prepareData.

@Override
protected void prepareData() throws Exception {
    log.info("started prepareData");
    /**
     * Mock data for migration test
     */
    StorageSystem storageSystem1 = new StorageSystem();
    StorageSystem storageSystem2 = new StorageSystem();
    StorageSystem storageSystem3 = new StorageSystem();
    SMISProvider smisProvider1 = new SMISProvider();
    SMISProvider smisProvider2 = new SMISProvider();
    SMISProvider smisProvider3 = new SMISProvider();
    storageSystem1.setId(URIUtil.createId(StorageSystem.class));
    storageSystem2.setId(URIUtil.createId(StorageSystem.class));
    storageSystem3.setId(URIUtil.createId(StorageSystem.class));
    storageSystem1.setLabel("st1");
    storageSystem2.setLabel("st2");
    storageSystem3.setLabel("st3");
    _dbClient.createObject(storageSystem1);
    _dbClient.createObject(storageSystem2);
    _dbClient.createObject(storageSystem3);
    smisProvider1.setId(URIUtil.createId(SMISProvider.class));
    smisProvider2.setId(URIUtil.createId(SMISProvider.class));
    smisProvider3.setId(URIUtil.createId(SMISProvider.class));
    smisProvider1.setLabel("smis1");
    smisProvider2.setLabel("smis2");
    smisProvider3.setLabel("smis3");
    _dbClient.createObject(smisProvider1);
    _dbClient.createObject(smisProvider2);
    _dbClient.createObject(smisProvider3);
    smisProvider1.addStorageSystem(_dbClient, storageSystem1, true);
    smisProvider1.addStorageSystem(_dbClient, storageSystem2, true);
    smisProvider2.addStorageSystem(_dbClient, storageSystem2, false);
    smisProvider3.addStorageSystem(_dbClient, storageSystem3, true);
    // Prepare VPLEX test data
    prepareVPlexTestData();
    validateSMISProviderInstances(false);
    validateStorageSystemInstances(false);
    validateStorageProviderInstances(false);
    log.info("completed prepareData");
}
Also used : SMISProvider(com.emc.storageos.db.client.model.SMISProvider) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with SMISProvider

use of com.emc.storageos.db.client.model.SMISProvider 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)

Aggregations

SMISProvider (com.emc.storageos.db.client.model.SMISProvider)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 URI (java.net.URI)2 DbClient (com.emc.storageos.db.client.DbClient)1 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)1 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)1