Search in sources :

Example 6 with XtremIOInitiator

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator in project coprhd-controller by CoprHD.

the class XtremIOProvUtils method getIGNameForInitiator.

/**
 * @param initiator
 * @param storageSerialNumber
 * @param client
 * @param xioClusterName
 * @return
 * @throws Exception
 */
public static String getIGNameForInitiator(Initiator initiator, String storageSerialNumber, XtremIOClient client, String xioClusterName) throws Exception {
    String igName = null;
    String initiatorName = initiator.getMappedInitiatorName(storageSerialNumber);
    if (null != initiatorName) {
        // Get initiator by Name and find IG Group
        XtremIOInitiator initiatorObj = client.getInitiator(initiatorName, xioClusterName);
        if (null != initiatorObj) {
            igName = initiatorObj.getInitiatorGroup().get(1);
        }
    }
    return igName;
}
Also used : XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Example 7 with XtremIOInitiator

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator in project coprhd-controller by CoprHD.

the class XtremIOArrayAffinityDiscoverer method findAndUpdatePreferredPools.

/**
 * Find and update preferred pools information for all Hosts.
 *
 * @param system the system
 * @param dbClient the db client
 * @param partitionManager
 * @throws Exception the exception
 */
public void findAndUpdatePreferredPools(StorageSystem system, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    /**
     * Get all initiators on array,
     * Group initiators by IG, also maintain a map of Host to IGs, and a map of IG to Hosts.
     * For each Host in the DB:
     * - Find if any of its IG has volumes,
     * - Find the mask type for the host.
     */
    XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, system, xtremioRestClientFactory);
    String xioClusterName = xtremIOClient.getClusterDetails(system.getSerialNumber()).getName();
    // Group all the initiators and their initiator groups based on ViPR host.
    ArrayListMultimap<String, Initiator> igNameToInitiatorsMap = ArrayListMultimap.create();
    Map<URI, Set<String>> hostToIGNamesMap = new HashMap<URI, Set<String>>();
    Map<String, Set<String>> igNameToHostsMap = new HashMap<String, Set<String>>();
    List<XtremIOInitiator> initiators = xtremIOClient.getXtremIOInitiatorsInfo(xioClusterName);
    for (XtremIOInitiator initiator : initiators) {
        String initiatorNetworkId = initiator.getPortAddress();
        // check if a host initiator exists for this id
        Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, dbClient);
        if (knownInitiator == null) {
            log.debug("Skipping XtremIO initiator {} as it is not found in database", initiatorNetworkId);
            continue;
        }
        URI hostId = knownInitiator.getHost();
        String hostName = knownInitiator.getHostName();
        if (!NullColumnValueGetter.isNullURI(hostId)) {
            log.info("Found a host {}({}) in ViPR for initiator {}", hostId.toString(), knownInitiator.getHostName(), initiatorNetworkId);
            String igName = initiator.getInitiatorGroup().get(1);
            igNameToInitiatorsMap.put(igName, knownInitiator);
            Set<String> hostIGNames = hostToIGNamesMap.get(hostId);
            if (hostIGNames == null) {
                hostIGNames = new HashSet<String>();
                hostToIGNamesMap.put(hostId, hostIGNames);
            }
            hostIGNames.add(igName);
            Set<String> igHostNames = igNameToHostsMap.get(igName);
            if (igHostNames == null) {
                igHostNames = new HashSet<String>();
                igNameToHostsMap.put(igName, igHostNames);
            }
            igHostNames.add(hostName);
        } else {
            log.info("No host in ViPR found configured for initiator {}", initiatorNetworkId);
        }
    }
    log.info("IG name to Initiators Map: {}", Joiner.on(",").join(igNameToInitiatorsMap.asMap().entrySet()));
    log.info("IG name to Hosts Map: {}", Joiner.on(",").join(igNameToHostsMap.entrySet()));
    log.info("Host to IG names Map: {}", Joiner.on(",").join(hostToIGNamesMap.entrySet()));
    // map of IG name to Volume names mapped
    Map<String, Set<String>> igToVolumesMap = getIgToVolumesMap(xtremIOClient, xioClusterName);
    // As XtremIO array has only one storage pool, add the pool directly.
    // get the storage pool associated with the XtremIO system
    StoragePool storagePool = XtremIOProvUtils.getXtremIOStoragePool(system.getId(), dbClient);
    List<Host> hostsToUpdate = new ArrayList<Host>();
    List<URI> hostURIs = dbClient.queryByType(Host.class, true);
    Iterator<Host> hosts = dbClient.queryIterativeObjectFields(Host.class, ArrayAffinityDiscoveryUtils.HOST_PROPERTIES, hostURIs);
    while (hosts.hasNext()) {
        Host host = hosts.next();
        if (host != null && !host.getInactive()) {
            log.info("Processing Host {}", host.getLabel());
            Map<String, String> preferredPoolMap = new HashMap<String, String>();
            Set<String> volumeNames = getVolumesForHost(hostToIGNamesMap.get(host.getId()), igToVolumesMap);
            // consider only unmanaged volumes
            filterKnownVolumes(system, dbClient, xtremIOClient, xioClusterName, volumeNames);
            if (!volumeNames.isEmpty()) {
                log.info("UnManaged Volumes found for this Host: {}", volumeNames);
                if (storagePool != null) {
                    String maskType = getMaskTypeForHost(xtremIOClient, xioClusterName, igNameToInitiatorsMap, igNameToHostsMap, hostToIGNamesMap.get(host.getId()), volumeNames);
                    ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, storagePool.getId().toString(), maskType);
                }
            } else {
                log.info("No UnManaged Volumes found for this Host");
            }
            if (ArrayAffinityDiscoveryUtils.updatePreferredPools(host, Sets.newHashSet(system.getId().toString()), dbClient, preferredPoolMap)) {
                hostsToUpdate.add(host);
            }
        }
    }
    if (!hostsToUpdate.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(hostsToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, HOST);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient)

Example 8 with XtremIOInitiator

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator in project coprhd-controller by CoprHD.

the class XtremIOCommunicationInterface method discoverInitiators.

private void discoverInitiators(XtremIOClient restClient, StorageSystem system) throws Exception {
    try {
        String clusterName = restClient.getClusterDetails(system.getSerialNumber()).getName();
        List<XtremIOInitiator> initiators = restClient.getXtremIOInitiatorsInfo(clusterName);
        for (XtremIOInitiator initiator : initiators) {
            @SuppressWarnings("deprecation") List<URI> initiatorUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getInitiatorPortInitiatorConstraint(initiator.getPortAddress()));
            if (initiatorUris.isEmpty()) {
                continue;
            } else {
                Initiator initiatorObj = _dbClient.queryObject(Initiator.class, initiatorUris.get(0));
                initiatorObj.setLabel(initiator.getName());
                initiatorObj.mapInitiatorName(system.getSerialNumber(), initiator.getName());
                _dbClient.updateObject(initiatorObj);
            }
        }
    } catch (Exception e) {
        _logger.error("Discovering XtremIO Initiator ports failed", e);
        throw e;
    }
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Example 9 with XtremIOInitiator

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator in project coprhd-controller by CoprHD.

the class XtremIOV2Client method getInitiator.

@Override
public XtremIOInitiator getInitiator(String initiatorName, String clusterName) throws Exception {
    try {
        String uriStr = XtremIOConstants.XTREMIO_V2_INITIATORS_STR.concat(XtremIOConstants.getInputNameForClusterString(initiatorName, clusterName));
        ClientResponse response = get(URI.create(uriStr));
        XtremIOInitiators initiators = getResponseObject(XtremIOInitiators.class, response);
        XtremIOInitiator initiator = initiators.getContent();
        log.info(initiator.toString());
        return initiator;
    } catch (Exception e) {
        if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
            throw e;
        } else {
            log.warn("Initiator {} not found on cluster {}", initiatorName, clusterName);
        }
    }
    log.info("Initiators not registered on Array with name : {}", initiatorName);
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiators(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Example 10 with XtremIOInitiator

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator in project coprhd-controller by CoprHD.

the class XtremIOV2Client method getXtremIOInitiatorsInfo.

@Override
public List<XtremIOInitiator> getXtremIOInitiatorsInfo(String clusterName) throws Exception {
    String uriString = XtremIOConstants.XTREMIO_V2_INITIATORS_STR.concat(XtremIOConstants.getInputClusterString(clusterName));
    ClientResponse response = get(URI.create(uriString));
    XtremIOInitiatorsInfo initiatorPortLinks = getResponseObject(XtremIOInitiatorsInfo.class, response);
    log.info("Returned Initiator Links size : {}", initiatorPortLinks.getInitiators().length);
    List<XtremIOInitiator> initiatorPortList = new ArrayList<XtremIOInitiator>();
    for (XtremIOObjectInfo initiatorPortInfo : initiatorPortLinks.getInitiators()) {
        URI initiatorPortUri = URI.create(URIUtil.getFromPath(initiatorPortInfo.getHref().concat(XtremIOConstants.getInputClusterString(clusterName))));
        try {
            response = get(initiatorPortUri);
            XtremIOInitiators initiatorPorts = getResponseObject(XtremIOInitiators.class, response);
            log.info("Initiator Port {}", initiatorPorts.getContent().getName() + "-" + initiatorPorts.getContent().getPortAddress());
            initiatorPortList.add(initiatorPorts.getContent());
        } catch (Exception e) {
            if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
                throw e;
            } else {
                log.warn("GET initiator - {} failed with obj_not_found. Initiator might be deleted from the system", initiatorPortUri.toString());
            }
        }
    }
    return initiatorPortList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiators(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) XtremIOInitiatorsInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)

Aggregations

XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)11 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)7 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 Initiator (com.emc.storageos.db.client.model.Initiator)6 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)4 XtremIOInitiators (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 HashSet (java.util.HashSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Set (java.util.Set)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 XtremIOInitiatorsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo)2 XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)2 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 ExportMask (com.emc.storageos.db.client.model.ExportMask)1