Search in sources :

Example 1 with XtremIOInitiatorGroup

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

the class XtremIOV1Client method getInitiatorGroup.

@Override
public XtremIOInitiatorGroup getInitiatorGroup(String initiatorGroupName, String clusterName) throws Exception {
    try {
        String uriStr = XtremIOConstants.XTREMIO_INITIATOR_GROUPS_STR.concat(XtremIOConstants.getInputNameString(initiatorGroupName));
        ClientResponse response = get(URI.create(uriStr));
        XtremIOInitiatorGroups igGroups = getResponseObject(XtremIOInitiatorGroups.class, response);
        XtremIOInitiatorGroup igGroup = igGroups.getContent();
        log.info(igGroup.toString());
        return igGroup;
    } catch (Exception e) {
        if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
            throw e;
        } else {
            log.warn("Initiator group {} not found on cluster {}", initiatorGroupName, clusterName);
        }
    }
    log.info("Initiator Group not registered on Array with name : {}", initiatorGroupName);
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOInitiatorGroups(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroups) XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)

Example 2 with XtremIOInitiatorGroup

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

the class XtremIOArrayAffinityDiscoverer method getMaskTypeForHost.

/**
 * Identifies the mask type (Host/Cluster) for the given host's IGs.
 *
 * @param xtremIOClient - xtremio client
 * @param xioClusterName - xio cluster name
 * @param groupInitiatorsByIG - IG name to initiators map
 * @param igNameToHostsMap - IG name to hosts map
 * @param hostIGNames - host to IG names map
 * @param volumeNames - volume names for the host
 * @return the mask type for host
 * @throws Exception
 */
private String getMaskTypeForHost(XtremIOClient xtremIOClient, String xioClusterName, ArrayListMultimap<String, Initiator> groupInitiatorsByIG, Map<String, Set<String>> igNameToHostsMap, Set<String> hostIGNames, Set<String> volumeNames) throws Exception {
    log.debug("Finding out mask type for the host");
    /**
     * 1. If any of the host's IG has initiators other than host's initiators, then cluster type. Otherwise, exclusive type.
     * 2. Further check: Get Lun mappings from host's volumes, get IG names from each Lun mapping,
     * - if volumes are shared with more than the host's IGs, it means it is a shared volume.
     */
    String maskType = ExportGroup.ExportGroupType.Host.name();
    for (String igName : hostIGNames) {
        XtremIOInitiatorGroup xioIG = xtremIOClient.getInitiatorGroup(igName, xioClusterName);
        if (Integer.parseInt(xioIG.getNumberOfInitiators()) > groupInitiatorsByIG.get(igName).size() || (igNameToHostsMap != null && igNameToHostsMap.get(igName) != null && igNameToHostsMap.get(igName).size() > 1)) {
            maskType = ExportGroup.ExportGroupType.Cluster.name();
            log.info("This Host has volume(s) shared with multiple hosts");
            break;
        }
    }
    if (!ExportGroup.ExportGroupType.Cluster.name().equalsIgnoreCase(maskType)) {
        Set<String> volumeIGNames = new HashSet<String>();
        for (String volumeName : volumeNames) {
            XtremIOVolume xioVolume = xtremIOClient.getVolumeDetails(volumeName, xioClusterName);
            for (List<Object> lunMapEntries : xioVolume.getLunMaps()) {
                @SuppressWarnings("unchecked") List<Object> igDetails = (List<Object>) lunMapEntries.get(0);
                if (null == igDetails.get(1)) {
                    log.warn("IG Name is null in returned lun map response for volume {}", volumeName);
                    continue;
                }
                String volumeIGName = (String) igDetails.get(1);
                volumeIGNames.add(volumeIGName);
            }
        }
        log.info("Host IG names: {}, Volumes IG names: {}", hostIGNames, volumeIGNames);
        volumeIGNames.removeAll(hostIGNames);
        if (!volumeIGNames.isEmpty()) {
            maskType = ExportGroup.ExportGroupType.Cluster.name();
            log.info("This Host has volume(s) shared with multiple hosts");
        }
    }
    return maskType;
}
Also used : XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 3 with XtremIOInitiatorGroup

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

the class XtremIOExportOperations method addInitiatorToInitiatorGroup.

private void addInitiatorToInitiatorGroup(XtremIOClient client, String xioClusterName, String clusterName, String hostName, List<Initiator> initiatorsToBeCreated, Set<String> igNames, ExportMask exportMask, StorageSystem storage, TaskCompleter taskCompleter) throws Exception {
    XtremIOInitiatorGroup igGroup = null;
    // create initiator group folder and initiator group
    String igFolderName = getInitiatorGroupFolderName(clusterName, hostName, storage);
    if (null == client.getTagDetails(igFolderName, XTREMIO_ENTITY_TYPE.InitiatorGroup.name(), xioClusterName)) {
        _log.info("Creating IG Folder with name {}", igFolderName);
        client.createTag(igFolderName, null, XtremIOConstants.XTREMIO_ENTITY_TYPE.InitiatorGroup.name(), xioClusterName);
    }
    DataSource dataSource = dataSourceFactory.createXtremIOInitiatorGroupNameDataSource(hostName, storage);
    String igName = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.XTREMIO_INITIATOR_GROUP_NAME, storage.getSystemType(), dataSource);
    igGroup = client.getInitiatorGroup(igName, xioClusterName);
    if (null == igGroup) {
        // create a new IG
        _log.info("Creating Initiator Group with name {}", igName);
        client.createInitiatorGroup(igName, igFolderName, xioClusterName);
        ExportOperationContext.insertContextOperation(taskCompleter, XtremIOExportOperationContext.OPERATION_CREATE_INITIATOR_GROUP, igName);
        igGroup = client.getInitiatorGroup(igName, xioClusterName);
        if (null == igGroup) {
            _log.info("Neither IG is already present nor able to create on Array {}", hostName);
        } else {
            _log.info("Created Initiator Group {} with # initiators {}", igGroup.getName(), igGroup.getNumberOfInitiators());
            igNames.add(igGroup.getName());
        }
    } else {
        igNames.add(igGroup.getName());
        _log.info("Found Initiator Group {} with # initiators {}", igGroup.getName(), igGroup.getNumberOfInitiators());
    }
    // add all the left out initiators to this folder
    for (Initiator remainingInitiator : initiatorsToBeCreated) {
        _log.info("Initiator {} Label {} ", remainingInitiator.getInitiatorPort(), remainingInitiator.getLabel());
        String initiatorName = ((null == remainingInitiator.getLabel() || remainingInitiator.getLabel().isEmpty()) ? remainingInitiator.getInitiatorPort() : remainingInitiator.getLabel());
        List<Initiator> createdInitiators = new ArrayList<Initiator>();
        _log.info("Initiator {}  ", initiatorName);
        try {
            String os = null;
            if (client.isVersion2() && !NullColumnValueGetter.isNullURI(remainingInitiator.getHost())) {
                Host host = dbClient.queryObject(Host.class, remainingInitiator.getHost());
                os = XtremIOProvUtils.getInitiatorHostOS(host);
            }
            // create initiator
            client.createInitiator(initiatorName, igGroup.getName(), remainingInitiator.getInitiatorPort(), os, xioClusterName);
            createdInitiators.add(remainingInitiator);
            remainingInitiator.setLabel(initiatorName);
            remainingInitiator.mapInitiatorName(storage.getSerialNumber(), initiatorName);
            dbClient.updateObject(remainingInitiator);
        } catch (Exception e) {
            // assume initiator already part of another group look for
            // port_address_not_unique
            // CTRL-5956 - Few Initiators cannot be registered on XtremIO Array, throw exception even if one
            // initiator registration
            // fails.
            _log.warn("Initiator {} already available or not able to register the same on Array. Rediscover the Array and try again.", remainingInitiator.getInitiatorPort());
            throw e;
        } finally {
            ExportOperationContext.insertContextOperation(taskCompleter, XtremIOExportOperationContext.OPERATION_ADD_INITIATORS_TO_INITIATOR_GROUP, createdInitiators);
        }
    }
}
Also used : XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataSource(com.emc.storageos.customconfigcontroller.DataSource)

Example 4 with XtremIOInitiatorGroup

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

the class XtremIOProvUtils method getInitiatorGroupLunMaps.

/**
 * Gets the lun maps for the initiator group.
 *
 * @param igName the ig name
 * @param clusterName the cluster name
 * @param client the xtremio client
 * @return the initiator group lun maps
 * @throws Exception
 */
public static List<XtremIOObjectInfo> getInitiatorGroupLunMaps(String igName, String clusterName, XtremIOClient client) throws Exception {
    List<XtremIOObjectInfo> igLunMaps = new ArrayList<XtremIOObjectInfo>();
    if (client.isVersion2()) {
        igLunMaps = client.getLunMapsForInitiatorGroup(igName, clusterName);
    } else {
        XtremIOInitiatorGroup ig = client.getInitiatorGroup(igName, clusterName);
        if (ig == null) {
            return igLunMaps;
        }
        List<XtremIOObjectInfo> lunMaps = client.getLunMaps(clusterName);
        String igIndex = ig.getIndex();
        for (XtremIOObjectInfo lunMap : lunMaps) {
            String[] lunInfo = lunMap.getName().split(XtremIOConstants.UNDERSCORE);
            if (igIndex.equals(lunInfo[1])) {
                igLunMaps.add(lunMap);
            }
        }
    }
    return igLunMaps;
}
Also used : XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)

Example 5 with XtremIOInitiatorGroup

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

the class XtremIOExportOperations method deleteInitiatorGroup.

private void deleteInitiatorGroup(ArrayListMultimap<String, Initiator> groupInitiatorsByIG, XtremIOClient client, String xioClusterName) throws Exception {
    for (Entry<String, Collection<Initiator>> entry : groupInitiatorsByIG.asMap().entrySet()) {
        String igName = entry.getKey();
        try {
            // find # initiators for this IG
            XtremIOInitiatorGroup ig = client.getInitiatorGroup(igName, xioClusterName);
            if (ig != null) {
                int numberOfVolumes = Integer.parseInt(ig.getNumberOfVolumes());
                _log.info("Initiator Group {} left with Volume size {}", igName, numberOfVolumes);
                if (numberOfVolumes == 0) {
                    // delete Initiator Group
                    client.deleteInitiatorGroup(igName, xioClusterName);
                // remove export mask from export groip
                } else {
                    _log.info("Skipping IG Group {} deletion", igName);
                }
            }
        } catch (Exception e) {
            if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
                _log.warn("Deleting Initatiator Group {} failed with exception {}", igName, e.getMessage());
                throw e;
            } else {
                _log.warn("Initatiator Group {} not found. Might be already deleted.", igName);
            }
        }
    }
}
Also used : XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) Collection(java.util.Collection) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

XtremIOInitiatorGroup (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup)7 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)4 ArrayList (java.util.ArrayList)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 XtremIOInitiatorGroups (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroups)2 XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)2 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 DataSource (com.emc.storageos.customconfigcontroller.DataSource)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 Host (com.emc.storageos.db.client.model.Host)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1