Search in sources :

Example 1 with Snap

use of com.emc.storageos.vnxe.models.Snap in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverVolumeSnaps.

/**
 * Discover Lun Snaps, and create UnManagedVolume for the snaps
 *
 * @param system
 * @param snaps
 * @param parentGUID
 * @param parentMatchedVPools
 * @param apiClient
 * @param dbClient
 * @param hostVolumesMap
 * @param lun
 * @param isSnapInCG
 * @param cgName
 * @return
 * @throws Exception
 */
private StringSet discoverVolumeSnaps(StorageSystem system, List<Snap> snaps, String parentGUID, StringSet parentMatchedVPools, VNXeApiClient apiClient, DbClient dbClient, Map<String, List<UnManagedVolume>> hostVolumesMap, VNXeLun lun, boolean isSnapInCG, String cgName) throws Exception {
    StringSet snapsets = new StringSet();
    for (Snap snapDetail : snaps) {
        UnManagedVolume unManagedVolume = null;
        String managedSnapNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(system.getNativeGuid(), snapDetail.getId());
        BlockSnapshot viprSnap = DiscoveryUtils.checkBlockSnapshotExistsInDB(dbClient, managedSnapNativeGuid);
        if (null != viprSnap) {
            log.info("Skipping snapshot {} as it is already managed by ViPR", managedSnapNativeGuid);
            snapsets.add(managedSnapNativeGuid);
            continue;
        }
        String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(system.getNativeGuid(), snapDetail.getId());
        unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
        unManagedVolume = createUnManagedVolumeForSnap(unManagedVolume, unManagedVolumeNatvieGuid, lun, system, dbClient, hostVolumesMap, snapDetail);
        populateSnapInfo(unManagedVolume, snapDetail, parentGUID, parentMatchedVPools);
        snapsets.add(unManagedVolumeNatvieGuid);
        unManagedVolumesReturnedFromProvider.add(unManagedVolume.getId());
        if (isSnapInCG) {
            addObjectToUnManagedConsistencyGroup(apiClient, unManagedVolume, cgName, system, dbClient);
        }
    }
    return snapsets;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Snap(com.emc.storageos.vnxe.models.Snap)

Example 2 with Snap

use of com.emc.storageos.vnxe.models.Snap in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverUnManagedVolumes.

public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
    unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
    unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
    unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    List<VNXeLun> luns = apiClient.getAllLuns();
    if (luns != null && !luns.isEmpty()) {
        Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
        Map<String, List<UnManagedVolume>> hostVolumesMap = new HashMap<String, List<UnManagedVolume>>();
        for (VNXeLun lun : luns) {
            UnManagedVolume unManagedVolume = null;
            String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), lun.getId());
            if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
                log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
            }
            StoragePool storagePool = getStoragePoolOfUnManagedObject(lun.getPool().getId(), storageSystem, pools);
            if (null == storagePool) {
                log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", lun.getId());
                continue;
            }
            String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), lun.getId());
            unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
            unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, lun, storageSystem, storagePool, dbClient, hostVolumesMap);
            unManagedVolumesReturnedFromProvider.add(unManagedVolume.getId());
            Boolean isVolumeInCG = lun.getType() == VNXeApiClient.GENERIC_STORAGE_LUN_TYPE ? true : false;
            String cgId = null;
            if (isVolumeInCG) {
                cgId = lun.getStorageResource().getId();
                addObjectToUnManagedConsistencyGroup(apiClient, unManagedVolume, cgId, storageSystem, dbClient);
            } else {
                // Make sure the unManagedVolume object does not contain CG information from previous discovery
                unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
                // set the uri of the unmanaged CG in the unmanaged volume object to empty
                unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
            }
            // Discover snaps
            Integer snapCount = lun.getSnapCount();
            boolean hasSnap = false;
            if (snapCount > 0) {
                List<Snap> snaps = apiClient.getSnapshotsForLun(lun.getId());
                if (snaps != null && !snaps.isEmpty()) {
                    StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
                    StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, snaps, unManagedVolumeNatvieGuid, parentMatchedVPools, apiClient, dbClient, hostVolumesMap, lun, isVolumeInCG, cgId);
                    if (discoveredSnaps != null && !discoveredSnaps.isEmpty()) {
                        hasSnap = true;
                        unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.TRUE.toString());
                        StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
                        if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
                            // replace with new StringSet
                            unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
                            log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
                        } else {
                            unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
                        }
                    }
                }
            }
            if (!hasSnap) {
                // no snap
                unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.FALSE.toString());
                StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
                if (unManagedVolumeInformation != null && unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
                    // replace with empty string set doesn't work, hence added explicit code to remove all
                    unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
                }
            }
        }
        if (!unManagedCGToUpdateMap.isEmpty()) {
            unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
            partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
            unManagedCGToUpdate.clear();
        }
        if (!unManagedVolumesInsert.isEmpty()) {
            partitionManager.insertInBatches(unManagedVolumesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        }
        if (!unManagedVolumesUpdate.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedVolumesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        }
        // Process those active unmanaged volume objects available in database but not in newly discovered items, to
        // mark them inactive.
        DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, unManagedVolumesReturnedFromProvider, dbClient, partitionManager);
        // Process those active unmanaged consistency group objects available in database but not in newly
        // discovered items, to mark them
        // inactive.
        DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
        // Next discover the unmanaged export masks
        discoverUnmanagedExportMasks(storageSystem.getId(), hostVolumesMap, apiClient, dbClient, partitionManager);
    } else {
        log.info("There are no luns found on the system: {}", storageSystem.getId());
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) HashMap(java.util.HashMap) Snap(com.emc.storageos.vnxe.models.Snap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with Snap

use of com.emc.storageos.vnxe.models.Snap in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverUnmanagedExportMasks.

/**
 * Create unmanaged export masks per host
 *
 * @param systemId
 * @param hostVolumesMap
 *            host-- exportedvolume list
 * @param apiClient
 * @param dbClient
 * @param partitionManager
 * @throws Exception
 */
private void discoverUnmanagedExportMasks(URI systemId, Map<String, List<UnManagedVolume>> hostVolumesMap, VNXeApiClient apiClient, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
    unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
    List<UnManagedVolume> unManagedExportVolumesToUpdate = new ArrayList<UnManagedVolume>();
    // In Unity, the volumes are exposed through all the storage ports.
    // Get all the storage ports to be added as known ports in the unmanaged export mask
    // If the host ports are FC, then add all FC storage ports to the mask
    // else add all IP ports
    StringSet knownFCStoragePortUris = new StringSet();
    StringSet knownIPStoragePortUris = new StringSet();
    List<StoragePort> matchedFCPorts = new ArrayList<StoragePort>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(systemId), storagePortURIs);
    Iterator<URI> portsItr = storagePortURIs.iterator();
    while (portsItr.hasNext()) {
        URI storagePortURI = portsItr.next();
        StoragePort port = dbClient.queryObject(StoragePort.class, storagePortURI);
        if (TransportType.FC.toString().equals(port.getTransportType())) {
            knownFCStoragePortUris.add(storagePortURI.toString());
            matchedFCPorts.add(port);
        } else if (TransportType.IP.toString().equals(port.getTransportType())) {
            knownIPStoragePortUris.add(storagePortURI.toString());
        }
    }
    for (Map.Entry<String, List<UnManagedVolume>> entry : hostVolumesMap.entrySet()) {
        String hostId = entry.getKey();
        List<UnManagedVolume> volumes = entry.getValue();
        StringSet knownInitSet = new StringSet();
        StringSet knownNetworkIdSet = new StringSet();
        StringSet knownVolumeSet = new StringSet();
        List<Initiator> matchedFCInitiators = new ArrayList<Initiator>();
        VNXeHost host = apiClient.getHostById(hostId);
        List<VNXeBase> fcInits = host.getFcHostInitiators();
        List<VNXeBase> iScsiInits = host.getIscsiHostInitiators();
        boolean isVplexHost = false;
        boolean isRPHost = false;
        Set<URI> hostURIs = new HashSet<>();
        if (fcInits != null && !fcInits.isEmpty()) {
            for (VNXeBase init : fcInits) {
                VNXeHostInitiator initiator = apiClient.getHostInitiator(init.getId());
                String portwwn = initiator.getPortWWN();
                if (portwwn == null || portwwn.isEmpty()) {
                    continue;
                }
                Initiator knownInitiator = NetworkUtil.getInitiator(portwwn, dbClient);
                if (knownInitiator != null) {
                    knownInitSet.add(knownInitiator.getId().toString());
                    knownNetworkIdSet.add(portwwn);
                    matchedFCInitiators.add(knownInitiator);
                    URI hostURI = knownInitiator.getHost();
                    if (!NullColumnValueGetter.isNullURI(hostURI) && URIUtil.isType(hostURI, Host.class)) {
                        hostURIs.add(hostURI);
                    }
                } else {
                    knownInitiator = new Initiator();
                    knownInitiator.setInitiatorPort(portwwn);
                }
                if (!isVplexHost && VPlexControllerUtils.isVplexInitiator(knownInitiator, dbClient)) {
                    isVplexHost = true;
                }
            }
        }
        if (!matchedFCInitiators.isEmpty() && ExportUtils.checkIfInitiatorsForRP(matchedFCInitiators)) {
            log.info("host {} contains RP initiators, " + "so this mask contains RP protected volumes", host.getName());
            isRPHost = true;
        }
        if (iScsiInits != null && !iScsiInits.isEmpty()) {
            for (VNXeBase init : iScsiInits) {
                VNXeHostInitiator initiator = apiClient.getHostInitiator(init.getId());
                String portwwn = initiator.getInitiatorId();
                if (portwwn == null || portwwn.isEmpty()) {
                    continue;
                }
                Initiator knownInitiator = NetworkUtil.getInitiator(portwwn, dbClient);
                if (knownInitiator != null) {
                    knownInitSet.add(knownInitiator.getId().toString());
                    knownNetworkIdSet.add(portwwn);
                    URI hostURI = knownInitiator.getHost();
                    if (!NullColumnValueGetter.isNullURI(hostURI) && URIUtil.isType(hostURI, Host.class)) {
                        hostURIs.add(hostURI);
                    }
                }
            }
        }
        if (knownNetworkIdSet.isEmpty()) {
            log.info(String.format("The host %s does not have any known initiators", hostId));
            continue;
        }
        if (hostURIs.size() > 1) {
            log.warn(String.format("Skip export on host %s as the initiators on the host belong to more than one hosts in DB %s", hostId, Joiner.on(",").join(hostURIs)));
            continue;
        }
        String firstNetworkId = knownNetworkIdSet.iterator().next();
        UnManagedExportMask mask = getUnManagedExportMask(firstNetworkId, dbClient, systemId);
        mask.setStorageSystemUri(systemId);
        // set the host name as the mask name
        mask.setMaskName(host.getName());
        allCurrentUnManagedExportMaskUris.add(mask.getId());
        for (UnManagedVolume hostUnManagedVol : volumes) {
            hostUnManagedVol.getInitiatorNetworkIds().addAll(knownNetworkIdSet);
            hostUnManagedVol.getInitiatorUris().addAll(knownInitSet);
            hostUnManagedVol.getUnmanagedExportMasks().add(mask.getId().toString());
            if (isVplexHost) {
                log.info("marking unmanaged unity volume {} as a VPLEX backend volume", hostUnManagedVol.getLabel());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VPLEX_BACKEND_VOLUME.toString(), Boolean.TRUE.toString());
            }
            if (isRPHost) {
                log.info("unmanaged volume {} is an RP volume", hostUnManagedVol.getLabel());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), Boolean.TRUE.toString());
            } else {
                log.info("unmanaged volume {} is exported to something other than RP.  Marking IS_NONRP_EXPORTED.", hostUnManagedVol.forDisplay());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), Boolean.TRUE.toString());
            }
            mask.getUnmanagedVolumeUris().add(hostUnManagedVol.getId().toString());
            // update mask to HLU information
            StringSet nativeId = hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.NATIVE_ID.name());
            String nativeGuid = hostUnManagedVol.getNativeGuid();
            String lunId = (nativeId != null && nativeId.iterator().hasNext()) ? nativeId.iterator().next() : nativeGuid.substring(nativeGuid.lastIndexOf(Constants.PLUS) + 1);
            String idCharSequence = HostLunRequests.ID_SEQUENCE_LUN;
            if (Boolean.valueOf(hostUnManagedVol.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_SNAP_SHOT.name()))) {
                idCharSequence = HostLunRequests.ID_SEQUENCE_SNAP;
                Snap snap = apiClient.getSnapshot(lunId);
                // get snap's parent id
                lunId = snap.getLun().getId();
            }
            HostLun hostLun = apiClient.getHostLun(lunId, hostId, idCharSequence);
            if (hostLun != null) {
                String hostHlu = host.getName() + "=" + hostLun.getHlu();
                StringSet existingHostHlu = hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name());
                if (existingHostHlu != null) {
                    existingHostHlu.add(hostHlu);
                } else {
                    hostUnManagedVol.getVolumeInformation().put(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name(), hostHlu);
                }
            }
            unManagedExportVolumesToUpdate.add(hostUnManagedVol);
        }
        mask.replaceNewWithOldResources(knownInitSet, knownNetworkIdSet, knownVolumeSet, !matchedFCInitiators.isEmpty() ? knownFCStoragePortUris : knownIPStoragePortUris);
        updateZoningMap(mask, matchedFCInitiators, matchedFCPorts);
    }
    if (!unManagedExportMasksToCreate.isEmpty()) {
        partitionManager.insertInBatches(unManagedExportMasksToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
        unManagedExportMasksToCreate.clear();
    }
    if (!unManagedExportMasksToUpdate.isEmpty()) {
        partitionManager.updateInBatches(unManagedExportMasksToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
        unManagedExportMasksToUpdate.clear();
    }
    if (!unManagedExportVolumesToUpdate.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(unManagedExportVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedExportVolumesToUpdate.clear();
    }
    DiscoveryUtils.markInActiveUnManagedExportMask(systemId, allCurrentUnManagedExportMaskUris, dbClient, partitionManager);
}
Also used : ArrayList(java.util.ArrayList) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) Snap(com.emc.storageos.vnxe.models.Snap) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) HashSet(java.util.HashSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) HostLun(com.emc.storageos.vnxe.models.HostLun) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) Host(com.emc.storageos.db.client.model.Host) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 4 with Snap

use of com.emc.storageos.vnxe.models.Snap in project coprhd-controller by CoprHD.

the class VNXUnitySnapshotOperations method deleteGroupSnapshots.

@Override
public void deleteGroupSnapshots(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        String groupId = snapshotObj.getReplicationGroupInstance();
        Snap snapGroup = apiClient.getSnapshot(groupId);
        if (snapGroup != null) {
            apiClient.deleteSnap(groupId);
        }
        List<BlockSnapshot> snaps = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
        if (snaps != null) {
            for (BlockSnapshot snap : snaps) {
                snap.setInactive(true);
                snap.setIsSyncActive(false);
                _dbClient.updateObject(snap);
            }
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception ex) {
        log.error("Delete group snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeletGroupSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Snap(com.emc.storageos.vnxe.models.Snap) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 5 with Snap

use of com.emc.storageos.vnxe.models.Snap in project coprhd-controller by CoprHD.

the class VNXUnitySnapshotOperations method deleteSingleVolumeSnapshot.

@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        Snap lunSnap = apiClient.getSnapshot(snap.getNativeId());
        if (lunSnap != null) {
            apiClient.deleteSnap(lunSnap.getId());
        }
        snap.setInactive(true);
        snap.setIsSyncActive(false);
        _dbClient.updateObject(snap);
        taskCompleter.ready(_dbClient);
    } catch (Exception ex) {
        log.error("Delete volume snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Snap(com.emc.storageos.vnxe.models.Snap) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

Snap (com.emc.storageos.vnxe.models.Snap)16 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)5 VNXeLunSnap (com.emc.storageos.vnxe.models.VNXeLunSnap)5 ArrayList (java.util.ArrayList)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 VNXeLun (com.emc.storageos.vnxe.models.VNXeLun)4 HashMap (java.util.HashMap)4 DbClient (com.emc.storageos.db.client.DbClient)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)3 Volume (com.emc.storageos.db.client.model.Volume)3 ParametersOut (com.emc.storageos.vnxe.models.ParametersOut)3 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)2 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)2