Search in sources :

Example 66 with UnManagedVolume

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

the class DiscoveryUtils method checkUnManagedVolumeExistsInDBByWwn.

/**
 * check UnManagedVolume exists in DB by WWN
 *
 * @param dbClient db client
 * @param wwn WWN
 * @return volume, if it's in the DB
 */
public static UnManagedVolume checkUnManagedVolumeExistsInDBByWwn(DbClient dbClient, String wwn) {
    URIQueryResultList unManagedVolumeList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedVolumeWwnConstraint(wwn), unManagedVolumeList);
    if (unManagedVolumeList.iterator().hasNext()) {
        URI unManagedVolumeURI = unManagedVolumeList.iterator().next();
        UnManagedVolume volumeInfo = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeURI);
        if (!volumeInfo.getInactive()) {
            return volumeInfo;
        }
    }
    return null;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 67 with UnManagedVolume

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

the class DiscoveryUtils method markInActiveUnManagedVolumes.

/**
 * This method cleans up UnManaged Volumes in DB, which had been deleted manually from the Array
 * 1. Get All UnManagedVolumes from DB
 * 2. Store URIs of unmanaged volumes returned from the Provider in unManagedVolumesBookKeepingList.
 * 3. If unmanaged volume is found only in DB, but not in unManagedVolumesBookKeepingList, then set unmanaged volume to inactive.
 *
 * DB | Provider
 *
 * x,y,z | y,z.a [a --> new entry has been added but indexes didn't get added yet into DB]
 *
 * x--> will be set to inactive
 *
 * @param storageSystem
 * @param discoveredUnManagedVolumes
 * @param dbClient
 * @param partitionManager
 */
public static void markInActiveUnManagedVolumes(StorageSystem storageSystem, Set<URI> discoveredUnManagedVolumes, DbClient dbClient, PartitionManager partitionManager) {
    _log.info(" -- Processing {} discovered UnManaged Volumes Objects from -- {}", discoveredUnManagedVolumes.size(), storageSystem.getLabel());
    if (discoveredUnManagedVolumes.isEmpty()) {
        return;
    }
    // Get all available existing unmanaged Volume URIs for this array from DB
    URIQueryResultList allAvailableUnManagedVolumesInDB = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceUnManagedVolumeConstraint(storageSystem.getId()), allAvailableUnManagedVolumesInDB);
    Set<URI> unManagedVolumesInDBSet = new HashSet<URI>();
    Iterator<URI> allAvailableUnManagedVolumesItr = allAvailableUnManagedVolumesInDB.iterator();
    while (allAvailableUnManagedVolumesItr.hasNext()) {
        unManagedVolumesInDBSet.add(allAvailableUnManagedVolumesItr.next());
    }
    SetView<URI> onlyAvailableinDB = Sets.difference(unManagedVolumesInDBSet, discoveredUnManagedVolumes);
    _log.info("Diff :" + Joiner.on("\t").join(onlyAvailableinDB));
    if (!onlyAvailableinDB.isEmpty()) {
        List<UnManagedVolume> unManagedVolumeTobeDeleted = new ArrayList<UnManagedVolume>();
        Iterator<UnManagedVolume> unManagedVolumes = dbClient.queryIterativeObjects(UnManagedVolume.class, new ArrayList<URI>(onlyAvailableinDB));
        while (unManagedVolumes.hasNext()) {
            UnManagedVolume volume = unManagedVolumes.next();
            if (null == volume || volume.getInactive()) {
                continue;
            }
            _log.info("Setting unManagedVolume {} inactive", volume.getId());
            volume.setStoragePoolUri(NullColumnValueGetter.getNullURI());
            volume.setStorageSystemUri(NullColumnValueGetter.getNullURI());
            volume.setInactive(true);
            unManagedVolumeTobeDeleted.add(volume);
        }
        if (!unManagedVolumeTobeDeleted.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedVolumeTobeDeleted, 1000, dbClient, UNMANAGED_VOLUME);
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Example 68 with UnManagedVolume

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

the class PersistingChangesTest method testStringSetMapRemove.

@Test
public void testStringSetMapRemove() throws Exception {
    UnManagedVolume unManagedVolume = new UnManagedVolume();
    URI id = URIUtil.createId(UnManagedVolume.class);
    unManagedVolume.setId(id);
    StringSet set1 = new StringSet();
    set1.add("test1");
    set1.add("test2");
    set1.add("test3");
    set1.add("test4");
    StringSet set2 = new StringSet();
    set2.add("test5");
    set2.add("test6");
    set2.add("test7");
    set2.add("test8");
    String key1 = "key1";
    String key2 = "key2";
    unManagedVolume.putVolumeInfo("key1", set1);
    unManagedVolume.putVolumeInfo("key2", set2);
    dbClient.createObject(unManagedVolume);
    unManagedVolume = dbClient.queryObject(UnManagedVolume.class, id);
    Assert.assertTrue(unManagedVolume.getVolumeInformation().containsKey(key1));
    Assert.assertTrue(unManagedVolume.getVolumeInformation().containsKey(key2));
    unManagedVolume.getVolumeInformation().remove(key1);
    unManagedVolume.getVolumeInformation().get(key2).remove("test6");
    dbClient.updateObject(unManagedVolume);
    unManagedVolume = dbClient.queryObject(UnManagedVolume.class, id);
    Assert.assertFalse(unManagedVolume.getVolumeInformation().containsKey(key1));
    Assert.assertTrue(unManagedVolume.getVolumeInformation().get(key2).contains("test7"));
    Assert.assertFalse(unManagedVolume.getVolumeInformation().get(key2).contains("test6"));
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) URI(java.net.URI) Test(org.junit.Test) DbClientTest(com.emc.storageos.db.server.DbClientTest)

Example 69 with UnManagedVolume

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

the class ImplicitUnManagedObjectsMatcher method addVPoolToUnManagedObjectSupportedVPools.

/**
 * add VPool to Supported VPool List of UnManaged Objects.
 * @param virtualPool the virtual pool
 * @param unManagedObjectInfo the un managed object info
 * @param system the system (for Block systems, to verify policy matching)
 * @param srdfEnabledTargetVPools SRDF enabled target vpools
 * @param rpEnabledTargetVPools RP enabled target vpools
 * @param supportedVPoolsList the supported v pools list
 * @param unManagedObjectURI the un managed object uri
 *
 * @return true, if successful
 */
private static boolean addVPoolToUnManagedObjectSupportedVPools(VirtualPool virtualPool, StringSetMap unManagedObjectInfo, UnManagedDiscoveredObject unManagedObject, StorageSystem system, Set<URI> srdfEnabledTargetVPools, Set<URI> rpEnabledTargetVPools) {
    // if virtual pool is already part of supported vpool
    // List, then continue;
    StringSet supportedVPoolsList = unManagedObject.getSupportedVpoolUris();
    if (null != supportedVPoolsList && supportedVPoolsList.contains(virtualPool.getId().toString())) {
        _log.debug("Matched VPool already there {}", virtualPool.getId().toString());
        return false;
    }
    if (VirtualPool.Type.block.name().equals(virtualPool.getType())) {
        // Before adding this vPool to supportedVPoolList, check if Tiering policy matches
        if (system != null && system.getAutoTieringEnabled()) {
            String autoTierPolicyId = null;
            if (unManagedObjectInfo.containsKey(SupportedVolumeInformation.AUTO_TIERING_POLICIES.toString())) {
                for (String policyName : unManagedObjectInfo.get(SupportedVolumeInformation.AUTO_TIERING_POLICIES.toString())) {
                    autoTierPolicyId = NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(system.getNativeGuid(), policyName, NativeGUIDGenerator.getTieringPolicyKeyForSystem(system));
                    break;
                }
            }
            if (!DiscoveryUtils.checkVPoolValidForUnManagedVolumeAutoTieringPolicy(virtualPool, autoTierPolicyId, system)) {
                String msg = "VPool %s is not added to UnManaged Volume's (%s) supported vPool list " + "since Auto-tiering Policy %s in UnManaged Volume does not match with vPool's (%s)";
                _log.debug(String.format(msg, new Object[] { virtualPool.getId(), unManagedObject.getId(), autoTierPolicyId, virtualPool.getAutoTierPolicyName() }));
                return false;
            }
        }
        // don't add vplex virtual pools to non vplex volumes
        if (VirtualPool.vPoolSpecifiesHighAvailability(virtualPool) && (unManagedObject instanceof UnManagedVolume)) {
            UnManagedVolume unManagedVolume = (UnManagedVolume) unManagedObject;
            if (null != unManagedVolume.getVolumeCharacterstics()) {
                String isVplexVolume = unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_VPLEX_VOLUME.toString());
                if (isVplexVolume == null || isVplexVolume.isEmpty() || !TRUE.equals(isVplexVolume)) {
                    _log.debug(String.format("VPool %s is not added to UnManaged Volume's (%s) supported vPool list " + "since the vpool has high availability set and the volume is non VPLEX.", new Object[] { virtualPool.getId(), unManagedVolume.forDisplay() }));
                    return false;
                }
            }
        }
        // Verify whether unmanaged volume SRDF properties with the Vpool
        boolean srdfSourceVpool = (null != virtualPool.getProtectionRemoteCopySettings() && !virtualPool.getProtectionRemoteCopySettings().isEmpty());
        boolean srdfTargetVpool = srdfEnabledTargetVPools == null ? false : (srdfEnabledTargetVPools.contains(virtualPool.getId()));
        StringSet remoteVolType = unManagedObjectInfo.get(SupportedVolumeInformation.REMOTE_VOLUME_TYPE.toString());
        boolean isRegularVolume = (null == remoteVolType);
        boolean isSRDFSourceVolume = (null != remoteVolType && remoteVolType.contains(RemoteMirrorObject.Types.SOURCE.toString()));
        boolean isSRDFTargetVolume = (null != remoteVolType && remoteVolType.contains(RemoteMirrorObject.Types.TARGET.toString()));
        if (isRegularVolume && (srdfSourceVpool || srdfTargetVpool)) {
            _log.debug("Found a regular volume with SRDF Protection Virtual Pool. No need to update.");
            return false;
        } else if (isSRDFSourceVolume && !(srdfSourceVpool || srdfTargetVpool)) {
            _log.debug("Found a SRDF unmanaged volume with non-srdf virtualpool. No need to update.");
            return false;
        } else if (isSRDFSourceVolume && srdfTargetVpool) {
            _log.debug("Found a SRDF source volume & target srdf vpool. No need to update.");
            return false;
        } else if (isSRDFTargetVolume && srdfSourceVpool) {
            _log.debug("Found a SRDFTarget volume & source srdf source vpool No need to update.");
            return false;
        }
        // Verify whether unmanaged volume RP properties with the Vpool
        boolean isRPSourceVpool = (null != virtualPool.getProtectionVarraySettings() && !virtualPool.getProtectionVarraySettings().isEmpty());
        boolean isRPTargetVpool = rpEnabledTargetVPools == null ? false : (rpEnabledTargetVPools.contains(virtualPool.getId()));
        remoteVolType = unManagedObjectInfo.get(SupportedVolumeInformation.RP_PERSONALITY.toString());
        isRegularVolume = (null == remoteVolType);
        boolean isRPSourceVolume = (null != remoteVolType && remoteVolType.contains(Volume.PersonalityTypes.SOURCE.toString()));
        if (isRegularVolume && (isRPSourceVpool || isRPTargetVpool)) {
            _log.debug("Found a regular volume with RP Protection Virtual Pool. No need to update.");
            return false;
        } else if (isRPSourceVolume && !isRPSourceVpool) {
            _log.debug("Found a RP unmanaged volume with non-rp virtualpool. No need to update.");
            return false;
        } else if (isRPSourceVolume && isRPTargetVpool) {
            _log.debug("Found a RP source volume & target rp vpool. No need to update.");
            return false;
        }
    }
    // empty
    if (null == supportedVPoolsList) {
        _log.debug("Adding a new Supported VPool List {}", virtualPool.getId().toString());
        supportedVPoolsList = new StringSet();
    }
    // updating the vpool list with new vpool
    supportedVPoolsList.add(virtualPool.getId().toString());
    return true;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) DataObject(com.emc.storageos.db.client.model.DataObject) UnManagedDiscoveredObject(com.emc.storageos.db.client.model.UnManagedDiscoveredObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject)

Example 70 with UnManagedVolume

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

the class VplexBackendIngestionContext method getUnManagedClones.

/**
 * Copied from VolumeIngestionUtil, which is in apisvc and
 * can't be accessed from controllersvc.
 */
public List<UnManagedVolume> getUnManagedClones(UnManagedVolume unManagedVolume) {
    List<UnManagedVolume> clones = new ArrayList<UnManagedVolume>();
    _logger.info("checking for clones (full copies) related to unmanaged volume " + unManagedVolume.getLabel());
    if (checkUnManagedVolumeHasReplicas(unManagedVolume)) {
        StringSet cloneNativeIds = extractValuesFromStringSet(SupportedVolumeInformation.FULL_COPIES.toString(), unManagedVolume.getVolumeInformation());
        List<URI> cloneUris = new ArrayList<URI>();
        if (null != cloneNativeIds && !cloneNativeIds.isEmpty()) {
            for (String nativeId : cloneNativeIds) {
                _logger.info("\tfound clone native id " + nativeId);
                URIQueryResultList unManagedVolumeList = new URIQueryResultList();
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(nativeId), unManagedVolumeList);
                if (unManagedVolumeList.iterator().hasNext()) {
                    cloneUris.add(unManagedVolumeList.iterator().next());
                }
            }
        }
        if (!cloneUris.isEmpty()) {
            clones = _dbClient.queryObject(UnManagedVolume.class, cloneUris, true);
            _logger.info("\treturning clone objects: " + clones);
        }
    }
    return clones;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)146 StringSet (com.emc.storageos.db.client.model.StringSet)66 URI (java.net.URI)53 Volume (com.emc.storageos.db.client.model.Volume)48 ArrayList (java.util.ArrayList)48 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)33 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)31 BlockObject (com.emc.storageos.db.client.model.BlockObject)30 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)24 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)19 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 DataObject (com.emc.storageos.db.client.model.DataObject)13 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)13 CIMObjectPath (javax.cim.CIMObjectPath)13 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)12 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)11 Map (java.util.Map)11 StringMap (com.emc.storageos.db.client.model.StringMap)10