Search in sources :

Example 11 with VNXeLun

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

the class VNXeApiClient method expandLun.

public VNXeCommandJob expandLun(String lunID, long newSize, String lunGroupID) {
    VNXeCommandJob job = null;
    _logger.info("expanding lun:" + lunID);
    VNXeLun vnxeLun = getLun(lunID);
    if (vnxeLun == null) {
        _logger.info("Could not find lun in the vxne");
        throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun in the vnxe for: " + lunID);
    }
    LunModifyParam lunModifyParam = new LunModifyParam();
    // set lunParam
    LunParam lunParam = new LunParam();
    lunParam.setSize(newSize);
    lunModifyParam.setLunParameters(lunParam);
    if (vnxeLun.getType() == GENERIC_STORAGE_LUN_TYPE) {
        if (lunGroupID == null || lunGroupID.isEmpty()) {
            _logger.error("Lun Group Id not found for lun: " + lunID);
            throw VNXeException.exceptions.vnxeCommandFailed("Could not find lun group for lun: " + lunID);
        }
        LunGroupModifyParam param = new LunGroupModifyParam();
        List<LunModifyParam> lunModifyParamList = new ArrayList<LunModifyParam>();
        lunModifyParam.setLun(new VNXeBase(lunID));
        lunModifyParamList.add(lunModifyParam);
        param.setLunModify(lunModifyParamList);
        if (isUnityClient()) {
            ConsistencyGroupRequests cgRequest = new ConsistencyGroupRequests(_khClient);
            job = cgRequest.modifyConsistencyGroupAsync(lunGroupID, param);
        } else {
            LunGroupRequests lunGroupRequest = new LunGroupRequests(_khClient);
            job = lunGroupRequest.modifyLunGroupAsync(lunGroupID, param);
        }
    } else if (vnxeLun.getType() == STANDALONE_LUN_TYPE) {
        BlockLunRequests req = new BlockLunRequests(_khClient);
        job = req.modifyLunAsync(lunModifyParam, lunID);
    }
    return job;
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunParam(com.emc.storageos.vnxe.models.LunParam) BlockLunRequests(com.emc.storageos.vnxe.requests.BlockLunRequests) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) ConsistencyGroupRequests(com.emc.storageos.vnxe.requests.ConsistencyGroupRequests) HostLunModifyParam(com.emc.storageos.vnxe.models.HostLunModifyParam) LunModifyParam(com.emc.storageos.vnxe.models.LunModifyParam)

Example 12 with VNXeLun

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

the class DeleteStorageResourceRequest method deleteLunAsync.

/**
 * Delete lun in async mode
 *
 * @param lunId
 * @param isForceSnapDeletion
 * @return
 * @throws VNXeException
 */
public VNXeCommandJob deleteLunAsync(String lunId, boolean isForceSnapDeletion) throws VNXeException {
    BlockLunRequests req = new BlockLunRequests(_client);
    VNXeLun lun = req.getLun(lunId);
    if (lun == null) {
        String error = "Could not find lun: " + lunId;
        _logger.error(error);
        throw VNXeException.exceptions.vnxeCommandFailed(error);
    }
    return deleteResourceAsync(lunId, isForceSnapDeletion);
}
Also used : VNXeLun(com.emc.storageos.vnxe.models.VNXeLun)

Example 13 with VNXeLun

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

the class DeleteStorageResourceRequest method deleteLunSync.

public VNXeCommandResult deleteLunSync(String id, boolean isForceSnapDeletion) throws VNXeException {
    _logger.info("deleting lun : {}", id);
    BlockLunRequests req = new BlockLunRequests(_client);
    VNXeLun lun = req.getLun(id);
    if (lun == null) {
        String error = "Could not find lun: " + id;
        _logger.error(error);
        throw VNXeException.exceptions.vnxeCommandFailed(error);
    }
    return deleteResourceSync(id, isForceSnapDeletion);
}
Also used : VNXeLun(com.emc.storageos.vnxe.models.VNXeLun)

Example 14 with VNXeLun

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

the class ApiClientTest method getLunByLunGroup.

// @Test
public void getLunByLunGroup() {
    VNXeLun lun = apiClient.getLunByLunGroup("res_1", "vol9");
    System.out.println(lun.getId());
}
Also used : VNXeLun(com.emc.storageos.vnxe.models.VNXeLun)

Example 15 with VNXeLun

use of com.emc.storageos.vnxe.models.VNXeLun 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)

Aggregations

VNXeLun (com.emc.storageos.vnxe.models.VNXeLun)22 ArrayList (java.util.ArrayList)9 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)7 BlockLunRequests (com.emc.storageos.vnxe.requests.BlockLunRequests)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 Volume (com.emc.storageos.db.client.model.Volume)5 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)5 HostLunModifyParam (com.emc.storageos.vnxe.models.HostLunModifyParam)5 LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)5 LunModifyParam (com.emc.storageos.vnxe.models.LunModifyParam)5 LunParam (com.emc.storageos.vnxe.models.LunParam)5 ConsistencyGroupRequests (com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)5 LunGroupRequests (com.emc.storageos.vnxe.requests.LunGroupRequests)5 HashMap (java.util.HashMap)5 StoragePool (com.emc.storageos.db.client.model.StoragePool)4 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)4 HostLun (com.emc.storageos.vnxe.models.HostLun)4 Snap (com.emc.storageos.vnxe.models.Snap)4 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)4 VNXeLunGroupSnap (com.emc.storageos.vnxe.models.VNXeLunGroupSnap)4