Search in sources :

Example 51 with StorageHADomain

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

the class VNXeCommunicationInterface method discoverNasServers.

/**
 * Discover the NasServer (Port Groups) for the specified VNXe storage
 * array.
 *
 * @param system
 *            storage system information
 * @param client
 *            VNXeServiceClient
 * @param nasServerIdMap
 *            all valid nasServer id map
 * @param arraySupportedProtocol
 *            array supported protocol
 * @return Map of New and Existing NasServers
 * @throws VNXeException
 */
private HashMap<String, List<StorageHADomain>> discoverNasServers(StorageSystem system, VNXeApiClient client, Map<String, URI> nasServerIdMap, StringSet arraySupportedProtocols) throws VNXeException {
    HashMap<String, List<StorageHADomain>> allNasServers = new HashMap<String, List<StorageHADomain>>();
    List<StorageHADomain> newNasServers = new ArrayList<StorageHADomain>();
    List<StorageHADomain> existingNasServers = new ArrayList<StorageHADomain>();
    boolean isNFSSupported = false;
    boolean isCIFSSupported = false;
    boolean isBothSupported = false;
    _logger.info("Start NasServer discovery for storage system {}", system.getId());
    List<VNXeNasServer> nasServers = client.getNasServers();
    List<VNXeCifsServer> cifsServers = client.getCifsServers();
    List<VNXeNfsServer> nfsServers = client.getNfsServers();
    for (VNXeNasServer nasServer : nasServers) {
        StorageHADomain haDomain = null;
        if (null == nasServer) {
            _logger.debug("Null data mover in list of port groups.");
            continue;
        }
        if (nasServer.getMode() == VNXeNasServer.NasServerModeEnum.DESTINATION) {
            _logger.debug("Found a replication destination NasServer");
            continue;
        }
        if (nasServer.getIsSystem()) {
            // skip system nasServer
            continue;
        }
        StringSet protocols = new StringSet();
        // Check if port group was previously discovered
        URIQueryResultList results = new URIQueryResultList();
        String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, nasServer.getName(), NativeGUIDGenerator.ADAPTER);
        _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(adapterNativeGuid), results);
        if (results.iterator().hasNext()) {
            StorageHADomain tmpDomain = _dbClient.queryObject(StorageHADomain.class, results.iterator().next());
            if (tmpDomain.getStorageDeviceURI().equals(system.getId())) {
                haDomain = tmpDomain;
                _logger.debug("Found duplicate {} ", nasServer.getName());
            }
        }
        // get the supported protocol on the nasServer
        if (cifsServers != null && !cifsServers.isEmpty()) {
            for (VNXeCifsServer cifsServer : cifsServers) {
                if (cifsServer.getNasServer().getId().equals(nasServer.getId())) {
                    protocols.add(StorageProtocol.File.CIFS.name());
                    isCIFSSupported = true;
                    break;
                }
            }
        }
        if (nfsServers != null && !nfsServers.isEmpty()) {
            for (VNXeNfsServer nfsServer : nfsServers) {
                if (nfsServer.getNasServer().getId().equals(nasServer.getId())) {
                    protocols.add(StorageProtocol.File.NFS.name());
                    isNFSSupported = true;
                    break;
                }
            }
        }
        if (protocols.size() == 2) {
            // this nasServer support both
            isBothSupported = true;
        }
        // If the nasServer was not previously discovered
        if (haDomain == null) {
            haDomain = new StorageHADomain();
            haDomain.setId(URIUtil.createId(StorageHADomain.class));
            haDomain.setNativeGuid(adapterNativeGuid);
            haDomain.setStorageDeviceURI(system.getId());
            haDomain.setAdapterName(nasServer.getName());
            haDomain.setName(nasServer.getName());
            haDomain.setSerialNumber(nasServer.getId());
            haDomain.setFileSharingProtocols(protocols);
            newNasServers.add(haDomain);
        } else {
            haDomain.setFileSharingProtocols(protocols);
            existingNasServers.add(haDomain);
        }
        nasServerIdMap.put(nasServer.getId(), haDomain.getId());
    }
    if (isBothSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.NFS.name());
        arraySupportedProtocols.add(StorageProtocol.File.CIFS.name());
    } else if (isNFSSupported && isCIFSSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.NFS_OR_CIFS.name());
    } else if (isNFSSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.NFS.name());
    } else if (isCIFSSupported) {
        arraySupportedProtocols.add(StorageProtocol.File.CIFS.name());
    }
    _logger.info("NasServer discovery for storage system {} complete.", system.getId());
    for (StorageHADomain newDomain : newNasServers) {
        _logger.info("New NasServer : {} : {}", newDomain.getNativeGuid(), newDomain.getId());
    }
    for (StorageHADomain domain : existingNasServers) {
        _logger.info("Existing NasServer : {} : {}", domain.getNativeGuid(), domain.getId());
    }
    // return portGroups;
    allNasServers.put(NEW, newNasServers);
    allNasServers.put(EXISTING, existingNasServers);
    return allNasServers;
}
Also used : HashMap(java.util.HashMap) VNXeNasServer(com.emc.storageos.vnxe.models.VNXeNasServer) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeCifsServer(com.emc.storageos.vnxe.models.VNXeCifsServer) VNXeNfsServer(com.emc.storageos.vnxe.models.VNXeNfsServer) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 52 with StorageHADomain

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

the class VPlexCommunicationInterface method setHADomainForStoragePort.

/**
 * Sets the storage HA domain for the passed port, creating and persisting
 * the domain if necessary.
 *
 * @param vplexStorageSystem A reference to the VPlex virtual storage
 *            system.
 * @param storagePort The storage port whose HA domain is to be set.
 * @param portInfo The port information from the VPlex.
 *
 * @throws IOException When an error occurs accessing the database.
 */
private void setHADomainForStoragePort(StorageSystem vplexStorageSystem, StoragePort storagePort, VPlexPortInfo portInfo) throws IOException {
    StorageHADomain haDomain = null;
    VPlexDirectorInfo directorInfo = portInfo.getDirectorInfo();
    String directorSerialNumber = directorInfo.getSerialNumber();
    String directorNativeGuid = NativeGUIDGenerator.generateNativeGuid(vplexStorageSystem, directorSerialNumber, NativeGUIDGenerator.ADAPTER);
    s_logger.debug("Looking for storage HA domain {}  in the database", directorNativeGuid);
    URIQueryResultList queryResults = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(directorNativeGuid), queryResults);
    Iterator<URI> resultsIter = queryResults.iterator();
    if (resultsIter.hasNext()) {
        s_logger.debug("Found storage HA doamin {}", directorNativeGuid);
        haDomain = _dbClient.queryObject(StorageHADomain.class, resultsIter.next());
    } else {
        s_logger.info("Creating storage HA domain {}", directorNativeGuid);
        haDomain = new StorageHADomain();
        haDomain.setId(URIUtil.createId(StorageHADomain.class));
        haDomain.setName(directorInfo.getName());
        haDomain.setAdapterName(directorInfo.getName());
        haDomain.setStorageDeviceURI(vplexStorageSystem.getId());
        haDomain.setNativeGuid(directorNativeGuid);
        haDomain.setSerialNumber(directorSerialNumber);
        List<PortRole> portRoles = new ArrayList<PortRole>();
        portRoles.add(PortRole.FRONTEND);
        portRoles.add(PortRole.BACKEND);
        haDomain.setNumberofPorts(String.valueOf(directorInfo.getNumberOfPortsOfType(portRoles)));
        haDomain.setProtocol(StorageProtocol.Block.FC.name());
        haDomain.setSlotNumber(String.valueOf(directorInfo.getSlotNumber()));
        _dbClient.createObject(haDomain);
    }
    s_logger.info("Setting storage HA domain {} for port {}", directorNativeGuid, storagePort.getPortNetworkId());
    storagePort.setStorageHADomain(haDomain.getId());
    storagePort.setPortGroup(haDomain.getAdapterName());
}
Also used : VPlexDirectorInfo(com.emc.storageos.vplex.api.VPlexDirectorInfo) PortRole(com.emc.storageos.vplex.api.VPlexPortInfo.PortRole) ArrayList(java.util.ArrayList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 53 with StorageHADomain

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

the class XtremIOCommunicationInterface method createStorageHADomain.

private StorageHADomain createStorageHADomain(StorageSystem system, String scName, int numOfPorts) {
    StorageHADomain haDomain = null;
    String haDomainNativeGUID = NativeGUIDGenerator.generateNativeGuid(system, scName, NativeGUIDGenerator.ADAPTER);
    _logger.info("HA Domain Native Guid : {}", haDomainNativeGUID);
    @SuppressWarnings("deprecation") List<URI> uriHaList = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageHADomainByNativeGuidConstraint(haDomainNativeGUID));
    if (uriHaList.isEmpty()) {
        haDomain = new StorageHADomain();
        haDomain.setId(URIUtil.createId(StorageHADomain.class));
        haDomain.setNativeGuid(haDomainNativeGUID);
        haDomain.setName(scName);
        haDomain.setAdapterName(scName);
        haDomain.setStorageDeviceURI(system.getId());
        haDomain.setNumberofPorts(String.valueOf(numOfPorts));
        _dbClient.createObject(haDomain);
    } else {
        haDomain = _dbClient.queryObject(StorageHADomain.class, uriHaList.get(0));
        haDomain.setNumberofPorts(String.valueOf(numOfPorts));
        _dbClient.persistObject(haDomain);
    }
    return haDomain;
}
Also used : StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI)

Example 54 with StorageHADomain

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

the class XtremIOCommunicationInterface method discoverPorts.

private Map<String, List<StoragePort>> discoverPorts(XtremIOClient restClient, StorageSystem system) throws Exception {
    Map<String, List<StoragePort>> portMap = new HashMap<String, List<StoragePort>>();
    try {
        String clusterName = restClient.getClusterDetails(system.getSerialNumber()).getName();
        List<XtremIOPort> targetPorts = restClient.getXtremIOPortInfo(clusterName);
        Map<String, List<XtremIOPort>> storageControllerPortMap = new HashMap<String, List<XtremIOPort>>();
        for (XtremIOPort targetPort : targetPorts) {
            String scName = targetPort.getNodeInfo().get(1);
            List<XtremIOPort> scPorts = storageControllerPortMap.get(scName);
            if (scPorts == null) {
                scPorts = new ArrayList<XtremIOPort>();
                storageControllerPortMap.put(scName, scPorts);
            }
            scPorts.add(targetPort);
        }
        portMap.put(NEW, new ArrayList<StoragePort>());
        portMap.put(EXISTING, new ArrayList<StoragePort>());
        Long portSpeed = 0L;
        StoragePort port = null;
        for (String scName : storageControllerPortMap.keySet()) {
            List<XtremIOPort> scPorts = storageControllerPortMap.get(scName);
            StorageHADomain haDomain = createStorageHADomain(system, scName, scPorts.size());
            for (XtremIOPort targetPort : scPorts) {
                if (targetPort.getPortSpeed() != null) {
                    String portSpeedStr = targetPort.getPortSpeed().split("G")[0];
                    try {
                        portSpeed = Long.parseLong(portSpeedStr);
                    } catch (NumberFormatException nfe) {
                        portSpeed = 0L;
                    }
                }
                String nativeGuid = NativeGUIDGenerator.generateNativeGuid(system, targetPort.getPortAddress(), NativeGUIDGenerator.PORT);
                _logger.info("Speed, Target Port Native Guid {} {}", portSpeed, nativeGuid);
                @SuppressWarnings("deprecation") List<URI> uriList = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(nativeGuid));
                if (uriList.isEmpty()) {
                    _logger.info("Creating a Target Port {}", nativeGuid);
                    port = new StoragePort();
                    port.setId(URIUtil.createId(StoragePort.class));
                    port.setNativeGuid(nativeGuid);
                    port.setPortSpeed(portSpeed);
                    port.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
                    port.setPortType(PortType.frontend.toString());
                    if ("iscsi".equalsIgnoreCase(targetPort.getPortType().toLowerCase())) {
                        port.setTransportType(StoragePort.TransportType.IP.toString());
                        port.setPortNetworkId(targetPort.getPortAddress().toLowerCase());
                    } else {
                        port.setTransportType(targetPort.getPortType().toUpperCase());
                        // to make it uniform across other arrays
                        port.setPortNetworkId(targetPort.getPortAddress().toUpperCase());
                    }
                    port.setStorageDevice(system.getId());
                    port.setPortName(targetPort.getName());
                    port.setLabel(nativeGuid);
                    port.setOperationalStatus(getOperationalStatus(targetPort).toString());
                    port.setPortGroup(haDomain.getAdapterName());
                    port.setStorageHADomain(haDomain.getId());
                    port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    portMap.get(NEW).add(port);
                    _dbClient.createObject(port);
                } else {
                    _logger.info("Updating a Target Port {}", nativeGuid);
                    port = _dbClient.queryObject(StoragePort.class, uriList.get(0));
                    port.setPortSpeed(portSpeed);
                    port.setPortName(targetPort.getName());
                    port.setLabel(nativeGuid);
                    port.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
                    port.setOperationalStatus(getOperationalStatus(targetPort).toString());
                    // Prior to release-2.4, we only had one default StorageHADomain for XIO array.
                    // During re-discovery when new StorageHADomains are created, update that info on storage ports.
                    port.setPortGroup(haDomain.getAdapterName());
                    port.setStorageHADomain(haDomain.getId());
                    port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    portMap.get(EXISTING).add(port);
                    _dbClient.persistObject(port);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Discovering XtremIO target ports failed", e);
        throw e;
    }
    return portMap;
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) XtremIOPort(com.emc.storageos.xtremio.restapi.model.response.XtremIOPort) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ArrayList(java.util.ArrayList) List(java.util.List) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 55 with StorageHADomain

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

the class StorageAdapterProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        _storageAdapterList = new ArrayList<StorageHADomain>();
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
        while (it.hasNext()) {
            CIMInstance adapterInstance = null;
            try {
                adapterInstance = it.next();
                StorageHADomain adapter = checkStorageAdapterExistsInDB(adapterInstance, device);
                createStorageAdapter(adapter, adapterInstance, profile);
                addPath(keyMap, operation.getResult(), adapterInstance.getObjectPath());
            } catch (Exception e) {
                _logger.warn("Adapter Discovery failed for {}-->{}", "", getMessage(e));
            }
        }
        _dbClient.createObject(_storageAdapterList);
    } catch (Exception e) {
        _logger.error("Adapter Discovery failed -->{}", getMessage(e));
    } finally {
        _storageAdapterList = null;
    }
}
Also used : Iterator(java.util.Iterator) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) CIMInstance(javax.cim.CIMInstance) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)80 URI (java.net.URI)41 StoragePort (com.emc.storageos.db.client.model.StoragePort)35 ArrayList (java.util.ArrayList)33 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 HashMap (java.util.HashMap)22 List (java.util.List)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)11 URISyntaxException (java.net.URISyntaxException)11 LinkedList (java.util.LinkedList)10 IOException (java.io.IOException)9 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)8 HashSet (java.util.HashSet)8 Map (java.util.Map)7