Search in sources :

Example 36 with VNXeBase

use of com.emc.storageos.vnxe.models.VNXeBase 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 37 with VNXeBase

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

the class VNXUnityUnManagedObjectDiscoverer method getStoragePortPool.

private StoragePort getStoragePortPool(StorageSystem storageSystem, DbClient dbClient, VNXeApiClient apiClient, VNXeFileSystem fs) throws IOException {
    StoragePort storagePort = null;
    // Retrieve the list of data movers interfaces for the VNX File device.
    List<VNXeFileInterface> interfaces = apiClient.getFileInterfaces();
    VNXeBase fsNasserver = fs.getNasServer();
    if (interfaces == null || interfaces.isEmpty()) {
        log.info("No file interfaces found for the system: {} ", storageSystem.getId());
        return storagePort;
    }
    log.info("Number file interfaces found: {}", interfaces.size());
    // Create the list of storage ports.
    for (VNXeFileInterface intf : interfaces) {
        VNXeBase nasServer = intf.getNasServer();
        if (nasServer == null || (!fsNasserver.getId().equalsIgnoreCase(nasServer.getId()))) {
            continue;
        }
        // Check if storage port was already discovered
        URIQueryResultList results = new URIQueryResultList();
        String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
        Iterator<URI> storagePortIter = results.iterator();
        if (storagePortIter.hasNext()) {
            URI storagePortURI = storagePortIter.next();
            storagePort = dbClient.queryObject(StoragePort.class, storagePortURI);
            if (storagePort.getStorageDevice().equals(storageSystem.getId()) && storagePort.getPortGroup().equals(nasServer.getId())) {
                log.debug("found a port for storage system  {} {}", storageSystem.getSerialNumber(), storagePort);
                break;
            }
        }
    }
    return storagePort;
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeFileInterface(com.emc.storageos.vnxe.models.VNXeFileInterface) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 38 with VNXeBase

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

the class VNXUnityUnManagedObjectDiscoverer method populateSnapInfo.

/**
 * Populate snap detail info
 *
 * @param unManagedVolume
 * @param snap
 * @param parentVolumeNatvieGuid
 * @param parentMatchedVPools
 */
private void populateSnapInfo(UnManagedVolume unManagedVolume, Snap snap, String parentVolumeNatvieGuid, StringSet parentMatchedVPools) {
    log.info("populate snap: {}", snap.getName());
    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_SNAP_SHOT.toString(), Boolean.TRUE.toString());
    StringSet parentVol = new StringSet();
    parentVol.add(parentVolumeNatvieGuid);
    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.toString(), parentVol);
    StringSet isSyncActive = new StringSet();
    isSyncActive.add(Boolean.TRUE.toString());
    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.IS_SYNC_ACTIVE.toString(), isSyncActive);
    StringSet isReadOnly = new StringSet();
    Boolean readOnly = snap.getIsReadOnly();
    isReadOnly.add(readOnly.toString());
    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.IS_READ_ONLY.toString(), isReadOnly);
    StringSet techType = new StringSet();
    techType.add(BlockSnapshot.TechnologyType.NATIVE.toString());
    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.TECHNOLOGY_TYPE.toString(), techType);
    VNXeBase snapGroup = snap.getSnapGroup();
    if (snapGroup != null) {
        unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), snapGroup.getId());
    }
    log.debug("Matched Pools : {}", Joiner.on("\t").join(parentMatchedVPools));
    if (null == parentMatchedVPools || parentMatchedVPools.isEmpty()) {
        // Clearn all vpools as no matching vpools found.
        log.info("no parent pool");
        unManagedVolume.getSupportedVpoolUris().clear();
    } else {
        // replace with new StringSet
        unManagedVolume.getSupportedVpoolUris().replace(parentMatchedVPools);
        log.info("Replaced Pools :{}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
    }
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 39 with VNXeBase

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

the class VNXeApiClient method addLunsToLunGroup.

/**
 * Add luns to LunGroup
 */
public VNXeCommandResult addLunsToLunGroup(String lunGroupId, List<String> luns) {
    LunGroupModifyParam param = new LunGroupModifyParam();
    List<LunAddParam> lunAdds = new ArrayList<LunAddParam>();
    for (String lunId : luns) {
        VNXeBase lun = new VNXeBase(lunId);
        LunAddParam lunAdd = new LunAddParam();
        lunAdd.setLun(lun);
        lunAdds.add(lunAdd);
    }
    param.setLunAdd(lunAdds);
    LunGroupRequests req = new LunGroupRequests(_khClient);
    return req.modifyLunGroupSync(lunGroupId, param);
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) LunAddParam(com.emc.storageos.vnxe.models.LunAddParam) LunGroupRequests(com.emc.storageos.vnxe.requests.LunGroupRequests) LunGroupModifyParam(com.emc.storageos.vnxe.models.LunGroupModifyParam) ArrayList(java.util.ArrayList)

Example 40 with VNXeBase

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

the class VNXeApiClient method createCifsShareForSnap.

/**
 * Create CIFS share for snapshot
 *
 * @param snapId
 *            snapshot id
 * @param shareName
 *            CIFS share name
 * @param permission
 *            READ, CHANGE, FULL
 * @return VNXeCommandJob
 * @throws VNXeException
 */
public VNXeCommandJob createCifsShareForSnap(String snapId, String shareName, String permission, String path, String fsId) throws VNXeException {
    _logger.info("Creating CIFS snapshot share name: {} for path: {}", shareName, path);
    // to get NETBIOS of CIFS Server file system is used as for snapshot
    FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
    VNXeFileSystem fs = fsRequest.get();
    List<VNXeCifsServer> cifsServers = getCifsServers(fs.getNasServer().getId());
    netBios = cifsServers.get(0).getNetbiosName();
    CifsShareRequests req = new CifsShareRequests(_khClient);
    CifsShareCreateForSnapParam param = new CifsShareCreateForSnapParam();
    param.setPath(path);
    VNXeBase snap = new VNXeBase();
    snap.setId(snapId);
    if (!VNXeUtils.isHigherVersion(getBasicSystemInfo().getSoftwareVersion(), VNXeConstants.VNXE_BASE_SOFT_VER)) {
        param.setFilesystemSnap(snap);
    } else {
        param.setSnap(snap);
    }
    param.setName(shareName);
    if (permission != null && !permission.isEmpty() && permission.equalsIgnoreCase(AccessEnum.READ.name())) {
        param.setIsReadOnly(true);
    } else {
        param.setIsReadOnly(false);
    }
    return req.createShareForSnapshot(param);
}
Also used : FileSystemRequest(com.emc.storageos.vnxe.requests.FileSystemRequest) CifsShareRequests(com.emc.storageos.vnxe.requests.CifsShareRequests) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) VNXeCifsServer(com.emc.storageos.vnxe.models.VNXeCifsServer) CifsShareCreateForSnapParam(com.emc.storageos.vnxe.models.CifsShareCreateForSnapParam)

Aggregations

VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)71 ArrayList (java.util.ArrayList)39 URI (java.net.URI)17 HashMap (java.util.HashMap)14 LunGroupModifyParam (com.emc.storageos.vnxe.models.LunGroupModifyParam)13 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)12 VNXeHostInitiator (com.emc.storageos.vnxe.models.VNXeHostInitiator)11 HashSet (java.util.HashSet)11 List (java.util.List)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)9 VNXeException (com.emc.storageos.vnxe.VNXeException)9 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)9 ConsistencyGroupRequests (com.emc.storageos.vnxe.requests.ConsistencyGroupRequests)9 LunGroupRequests (com.emc.storageos.vnxe.requests.LunGroupRequests)9 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 BlockHostAccess (com.emc.storageos.vnxe.models.BlockHostAccess)8 LunParam (com.emc.storageos.vnxe.models.LunParam)8 ModifyFileSystemParam (com.emc.storageos.vnxe.models.ModifyFileSystemParam)8 Initiator (com.emc.storageos.db.client.model.Initiator)7 VNXeHost (com.emc.storageos.vnxe.models.VNXeHost)7