Search in sources :

Example 1 with SiteArrays

use of com.emc.storageos.recoverpoint.objectmodel.SiteArrays in project coprhd-controller by CoprHD.

the class RPCommunicationInterface method discoverRPSiteArrays.

@SuppressWarnings("unchecked")
private void discoverRPSiteArrays(ProtectionSystem rpSystem) throws RecoverPointCollectionException {
    _log.info("BEGIN RecoverPointProtection.discoveryProtectionSystem()");
    // Retrieve the storage device info from the database.
    ProtectionSystem storageObj = rpSystem;
    // Wait for any storage system discovery to complete
    waitForStorageSystemDiscovery();
    // Get the rp system's array mappings from the RP client
    BiosCommandResult result = getRPArrayMappings(storageObj);
    _log.info(String.format("discoverProtectionSystem(): after rpa array mappings with result: [%s] ", result.getCommandStatus()));
    RPSiteArray rpSiteArray = null;
    if (result.getCommandSuccess()) {
        // Current implementation:
        // 1. Clear out any of its entries regarding associations
        // 2. For each RPSite object, there is an associated RP storage system
        // 3. Find the storage system in the database
        // 4. Fill in associations
        List<URI> ids = _dbClient.queryByType(RPSiteArray.class, true);
        for (URI id : ids) {
            _log.info("discoverProtectionSystem(): reading RPSiteArray: " + id.toASCIIString());
            rpSiteArray = _dbClient.queryObject(RPSiteArray.class, id);
            if (rpSiteArray == null) {
                continue;
            }
            if ((rpSiteArray.getRpProtectionSystem() != null) && (rpSiteArray.getRpProtectionSystem().equals(storageObj.getId()))) {
                _log.info(String.format("discoverProtectionSystem(): removing RPSiteArray[%s](%s) " + "entry for Storage System [%s].", rpSiteArray.getLabel(), rpSiteArray.getId().toASCIIString(), rpSiteArray.getArraySerialNumber()));
                _dbClient.markForDeletion(rpSiteArray);
            } else if (rpSiteArray.getRpProtectionSystem() == null) {
                _log.error("RPSiteArray " + id.toASCIIString() + " does not have a parent assigned, therefore it is an orphan.");
            }
        }
        // Store any unmatched WWNs for logging purposes
        StringBuffer unmatchedWWNs = new StringBuffer();
        // Map the information from the RP client to information in our database
        for (SiteArrays siteArray : (List<SiteArrays>) result.getObjectList().get(0)) {
            for (String wwn : siteArray.getArrays()) {
                // Find the array that corresponds to the wwn endpoint we found
                URIQueryResultList storagePortList = new URIQueryResultList();
                StoragePort storagePort = null;
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(WwnUtils.convertWWN(wwn, WwnUtils.FORMAT.COLON)), storagePortList);
                List<URI> storagePortURIs = new ArrayList<URI>();
                for (URI uri : storagePortList) {
                    storagePort = _dbClient.queryObject(StoragePort.class, uri);
                    if (storagePort != null && !storagePort.getInactive() && storagePort.getRegistrationStatus().equals(RegistrationStatus.REGISTERED.name())) {
                        // ignore cinder managed storage system's port
                        StorageSystem system = _dbClient.queryObject(StorageSystem.class, storagePort.getStorageDevice());
                        if (!DiscoveredDataObject.Type.openstack.name().equals(system.getSystemType())) {
                            storagePortURIs.add(uri);
                        }
                    }
                }
                if (!storagePortURIs.isEmpty()) {
                    storagePort = _dbClient.queryObject(StoragePort.class, storagePortURIs).get(0);
                    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storagePort.getStorageDevice());
                    rpSiteArray = new RPSiteArray();
                    rpSiteArray.setInactive(false);
                    rpSiteArray.setLabel(siteArray.getSite().getSiteName() + ":" + wwn);
                    rpSiteArray.setRpProtectionSystem(storageObj.getId());
                    rpSiteArray.setStorageSystem(storagePort.getStorageDevice());
                    rpSiteArray.setArraySerialNumber(storageSystem.getSerialNumber());
                    rpSiteArray.setRpInternalSiteName(siteArray.getSite().getInternalSiteName());
                    rpSiteArray.setRpSiteName(siteArray.getSite().getSiteName());
                    rpSiteArray.setId(URIUtil.createId(RPSiteArray.class));
                    _log.info(String.format("discoverProtectionSystem(): adding RPSiteArray[%s](%s) " + "entry for Storage System [%s].", rpSiteArray.getLabel(), rpSiteArray.getId().toASCIIString(), rpSiteArray.getArraySerialNumber()));
                    _dbClient.createObject(rpSiteArray);
                } else {
                    unmatchedWWNs.append("\n" + wwn);
                }
            }
        }
        if (!StringUtils.isEmpty(unmatchedWWNs.toString())) {
            _log.warn(String.format("Discovery of RecoverPoint Protection System [%s](%s) found the following endpoints, however " + "they could not be aligned with existing configured arrays. Note this is not an error and that some could be Host " + "endpoints but please ensure all arrays are registered before registering/running discovery of " + "RecoverPoint: [%s]", rpSystem.getLabel(), rpSystem.getId(), unmatchedWWNs));
        }
    } else {
        _log.warn(String.format("RPA array mappings did not return a successful result, " + "please check network connectivity for RecoverPoint Protection System [%s](%s)."), rpSystem.getLabel(), rpSystem.getId());
    }
    _log.info("END RecoverPointProtection.discoveryProtectionSystem()");
}
Also used : RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) SiteArrays(com.emc.storageos.recoverpoint.objectmodel.SiteArrays) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) List(java.util.List) ArrayList(java.util.ArrayList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with SiteArrays

use of com.emc.storageos.recoverpoint.objectmodel.SiteArrays in project coprhd-controller by CoprHD.

the class RPCommunicationInterface method getRPArrayMappings.

/**
 * For an RP configuration, determine the arrays that each site can see.
 *
 * @param system RP system
 * @return command result object, object list [0] has List<SiteArrays>
 * @throws RecoverPointException
 */
public BiosCommandResult getRPArrayMappings(ProtectionSystem system) throws RecoverPointException {
    _log.info("getRPArrayMappings {} - start", system.getId());
    RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
    Set<RPSite> sites = rp.getAssociatedRPSites();
    // For determining which storage system to use with the RPA, we will look at the Network created as a result of
    // a NetworkSystem (aka switch or Fabric Manager) discovery. We look at each NetworkSystem to check if the RPA WWN(aka RP Initiator)
    // is in one of the
    // Networks/VSANs and if we do find a match then we look at the arrays in that Network/VSAN and determine which one to use.
    // For now, this code assumes there are Networks/VSANs created on the switch, might need to tweak this if there are no
    // Networks/VSANs.
    // One more important note : Networks/VSANs have be configured on the switch in order for zoning to work and NetworkSystem to
    // discover.
    // No Networks/VSANs on the switch means, none of this will work and zoning has to be done by the end-user prior to using StorageOS.
    // Get all the NetworkSystems already in the system (if there are any NetworkSystems configured).
    // Possible zoning candidates can be identified only if there is a NetworkSystem configured.
    List<SiteArrays> rpSiteArrays = new ArrayList<SiteArrays>();
    List<URI> networkSystemList = _dbClient.queryByType(NetworkSystem.class, true);
    boolean isNetworkSystemConfigured = false;
    if (networkSystemList.iterator().hasNext()) {
        List<URI> allNetworks = _dbClient.queryByType(Network.class, true);
        // Transfer to a reset-able list
        List<URI> networks = new ArrayList<>();
        for (URI networkURI : allNetworks) {
            networks.add(networkURI);
        }
        for (RPSite site : sites) {
            // Get the initiators for this site.
            Map<String, Map<String, String>> rpaWWNs = rp.getInitiatorWWNs(site.getInternalSiteName());
            SiteArrays siteArrays = new SiteArrays();
            siteArrays.setArrays(new HashSet<String>());
            siteArrays.setSite(site);
            // Add an RP site -> initiators entry to the protection system
            StringSet siteInitiators = new StringSet();
            for (String rpaId : rpaWWNs.keySet()) {
                siteInitiators.addAll(rpaWWNs.get(rpaId).keySet());
            }
            system.putSiteIntitiatorsEntry(site.getInternalSiteName(), siteInitiators);
            // trying to find a valid Storage Port (of which they will not return a result).
            for (String rpaId : rpaWWNs.keySet()) {
                _log.info(String.format("Discovering RPA %s initiators for RPA Cluster %s(%s)...", rpaId, site.getSiteName(), site.getInternalSiteName()));
                boolean foundNetworkForRPA = false;
                for (Map.Entry<String, String> rpaWWN : rpaWWNs.get(rpaId).entrySet()) {
                    Initiator initiator = new Initiator();
                    initiator.addInternalFlags(Flag.RECOVERPOINT);
                    // Remove all non alpha-numeric characters, excluding "_", from the hostname
                    String rpClusterName = site.getSiteName().replaceAll(NON_ALPHA_NUMERICS, "");
                    initiator.setClusterName(rpClusterName);
                    initiator.setProtocol("FC");
                    initiator.setIsManualCreation(false);
                    // Group RP initiators by their RPA. This will ensure that separate IGs are created for each RPA
                    // A child RP IG will be created containing all the RPA IGs
                    String hostName = rpClusterName + RPA + rpaId;
                    hostName = hostName.replaceAll(NON_ALPHA_NUMERICS, "");
                    initiator.setHostName(hostName);
                    initiator.setInitiatorPort(rpaWWN.getKey());
                    initiator.setInitiatorNode(rpaWWN.getValue());
                    // Either get the existing initiator or create a new if needed
                    initiator = getOrCreateNewInitiator(initiator);
                    _log.info(String.format("RPA Initiator %s detected: [port: %s, node: %s, host: %s, cluster: %s]", initiator.getInitiatorPort(), initiator.getInitiatorPort(), initiator.getInitiatorNode(), initiator.getHostName(), initiator.getClusterName()));
                    // Find the network associated with this initiator
                    for (URI networkURI : networks) {
                        Network network = _dbClient.queryObject(Network.class, networkURI);
                        StringMap discoveredEndpoints = network.getEndpointsMap();
                        if (discoveredEndpoints.containsKey(initiator.getInitiatorPort().toUpperCase())) {
                            _log.info(String.format("RPA Initiator %s is associated to Network %s.", initiator.getInitiatorPort().toUpperCase(), network.getLabel()));
                            // Set this to true as we found the RP initiators in a Network on the Network system
                            isNetworkSystemConfigured = true;
                            foundNetworkForRPA = true;
                            for (String discoveredEndpoint : discoveredEndpoints.keySet()) {
                                // in that NetworkVSAN.
                                if (discoveredEndpoint.startsWith(RP_INITIATOR_PREFIX)) {
                                    continue;
                                }
                                // Add the found endpoints to the list
                                siteArrays.getArrays().add(discoveredEndpoint);
                            }
                        }
                    }
                }
                if (!foundNetworkForRPA) {
                    // This is not an error to the end-user. When they add a network system, everything will rediscover correctly.
                    _log.warn(String.format("RPA %s initiators for RPA Cluster %s(%s) are not seen in any configured network.", rpaId, site.getSiteName(), site.getInternalSiteName()));
                }
            }
            // add to the list
            rpSiteArrays.add(siteArrays);
        }
    }
    // If its a non RP4.0 system, then query the normal way and find out the targets/arrays from the RPAs.
    if (!rp.getAssociatedRPSites().isEmpty()) {
        _log.info("site1 version: " + rp.getAssociatedRPSites().iterator().next().getSiteVersion());
    }
    if (!isNetworkSystemConfigured) {
        // This is not an error to the end-user. When they add a network system, everything will rediscover correctly.
        _log.warn("Network systems are required when configuring RecoverPoint.");
    }
    _log.info("getRPArrayMappings {} - complete", system.getId());
    BiosCommandResult result = new BiosCommandResult();
    result.setCommandSuccess(true);
    result.setCommandStatus(Operation.Status.ready.name());
    List<Object> returnList = new ArrayList<Object>();
    returnList.add(rpSiteArrays);
    result.setObjectList(returnList);
    return result;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) SiteArrays(com.emc.storageos.recoverpoint.objectmodel.SiteArrays) ArrayList(java.util.ArrayList) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Aggregations

SiteArrays (com.emc.storageos.recoverpoint.objectmodel.SiteArrays)2 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 Network (com.emc.storageos.db.client.model.Network)1 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)1 RPSiteArray (com.emc.storageos.db.client.model.RPSiteArray)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)1 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)1 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)1 List (java.util.List)1 Map (java.util.Map)1