Search in sources :

Example 11 with XtremIOObjectInfo

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo 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)

Example 12 with XtremIOObjectInfo

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

the class XtremIOV1Client method getXtremIOVolumesForLinks.

@Override
public List<XtremIOVolume> getXtremIOVolumesForLinks(List<XtremIOObjectInfo> volumeLinks, String clusterName) throws Exception {
    List<XtremIOVolume> volumeList = new ArrayList<XtremIOVolume>();
    for (XtremIOObjectInfo volumeInfo : volumeLinks) {
        URI volumeURI = URI.create(URIUtil.getFromPath(volumeInfo.getHref()));
        ClientResponse response = get(volumeURI);
        XtremIOVolumes volumes = getResponseObject(XtremIOVolumes.class, response);
        log.info("Volume {}", volumes.getContent().getVolInfo().get(1) + "-" + volumes.getContent().getVolInfo().get(2));
        volumeList.add(volumes.getContent());
    }
    return volumeList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) XtremIOVolumes(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolumes) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) URI(java.net.URI)

Example 13 with XtremIOObjectInfo

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

the class XtremIOArrayAffinityDiscoverer method getIgToVolumesMap.

/**
 * Queries the lun maps information from array, forms IG name to volume names map.
 */
private Map<String, Set<String>> getIgToVolumesMap(XtremIOClient xtremIOClient, String xioClusterName) throws Exception {
    log.info("Querying lun maps for cluster {}", xioClusterName);
    Map<String, Set<String>> igToVolumesMap = new HashMap<>();
    // get the XtremIO lun map links and process them in batches
    List<XtremIOObjectInfo> lunMapLinks = xtremIOClient.getXtremIOLunMapLinks(xioClusterName);
    List<List<XtremIOObjectInfo>> lunMapPartitions = Lists.partition(lunMapLinks, Constants.DEFAULT_PARTITION_SIZE);
    for (List<XtremIOObjectInfo> partition : lunMapPartitions) {
        // Get the lun map details
        List<XtremIOLunMap> lunMaps = xtremIOClient.getXtremIOLunMapsForLinks(partition, xioClusterName);
        for (XtremIOLunMap lunMap : lunMaps) {
            try {
                log.info("Looking at lun map {}; IG name: {}, Volume: {}", lunMap.getMappingInfo().get(2), lunMap.getIgName(), lunMap.getVolumeName());
                String igName = lunMap.getIgName();
                Set<String> volumes = igToVolumesMap.get(igName);
                if (volumes == null) {
                    volumes = new HashSet<String>();
                    igToVolumesMap.put(igName, volumes);
                }
                volumes.add(lunMap.getVolumeName());
            } catch (Exception ex) {
                log.warn("Error processing XtremIO lun map {}. {}", lunMap, ex.getMessage());
            }
        }
    }
    return igToVolumesMap;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) XtremIOLunMap(com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with XtremIOObjectInfo

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

the class XtremIOUnManagedVolumeDiscoverer method discoverUnManagedObjects.

public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, storageSystem, xtremioRestClientFactory);
    unManagedVolumesToCreate = new ArrayList<UnManagedVolume>();
    unManagedVolumesToUpdate = new ArrayList<UnManagedVolume>();
    unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
    // get the storage pool associated with the xtremio system
    StoragePool storagePool = XtremIOProvUtils.getXtremIOStoragePool(storageSystem.getId(), dbClient);
    if (storagePool == null) {
        log.error("Skipping unmanaged volume discovery as the volume storage pool doesn't exist in ViPR");
        return;
    }
    Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap = new HashMap<String, List<UnManagedVolume>>();
    Map<String, StringSet> igKnownVolumesMap = new HashMap<String, StringSet>();
    Map<String, Map<String, Integer>> volumeIGHLUMap = new HashMap<String, Map<String, Integer>>();
    String xioClusterName = xtremIOClient.getClusterDetails(storageSystem.getSerialNumber()).getName();
    // get the xtremio volume links and process them in batches
    List<XtremIOObjectInfo> volLinks = xtremIOClient.getXtremIOVolumeLinks(xioClusterName);
    // Get the volume details
    List<List<XtremIOObjectInfo>> volume_partitions = Lists.partition(volLinks, Constants.DEFAULT_PARTITION_SIZE);
    // Set containing cgs that cannot be ingested, for now that
    // means they contain volumes which belong to more than one cg
    unSupportedCG = new HashSet<String>();
    for (List<XtremIOObjectInfo> partition : volume_partitions) {
        List<XtremIOVolume> volumes = xtremIOClient.getXtremIOVolumesForLinks(partition, xioClusterName);
        for (XtremIOVolume volume : volumes) {
            try {
                // volumes later
                if (volume.getAncestoVolInfo() != null && !volume.getAncestoVolInfo().isEmpty()) {
                    log.debug("Skipping volume {} as it is a snap", volume.getVolInfo().get(0));
                    continue;
                }
                // check if cgs are null before trying to access, older versions of
                // the XtremIO REST client do not return cgs as part of volume response
                // flag indicating the volume is part of a cg
                boolean hasCGs = false;
                if (volume.getConsistencyGroups() != null && !volume.getConsistencyGroups().isEmpty()) {
                    hasCGs = true;
                    if (volume.getConsistencyGroups().size() > 1) {
                        // volumes that belong to multiple CGs are not supported in ViPR
                        log.warn("Skipping volume {} as it belongs to multiple CGs and this is not supported", volume.getVolInfo().get(0));
                        // add all the CGs that this volume belongs to to the list that are unsupported for ingestion
                        for (List<Object> cg : volume.getConsistencyGroups()) {
                            Object cgNameToProcess = cg.get(1);
                            unSupportedCG.add(cgNameToProcess.toString());
                            log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
                        }
                        continue;
                    }
                }
                UnManagedVolume unManagedVolume = null;
                boolean isExported = !volume.getLunMaps().isEmpty();
                boolean hasSnaps = !volume.getSnaps().isEmpty();
                String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
                Volume viprVolume = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid);
                if (null != viprVolume) {
                    log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
                    // export masks.
                    if (isExported) {
                        populateKnownVolsMap(volume, viprVolume, igKnownVolumesMap);
                    }
                    // retrieve snap info to be processed later
                    if (hasSnaps) {
                        StringSet vpoolUriSet = new StringSet();
                        vpoolUriSet.add(viprVolume.getVirtualPool().toString());
                        discoverVolumeSnaps(storageSystem, volume.getSnaps(), viprVolume.getNativeGuid(), vpoolUriSet, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
                    }
                    continue;
                }
                String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
                // retrieve snap info to be processed later
                unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
                unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, volume, igUnmanagedVolumesMap, storageSystem, storagePool, dbClient);
                // if the volume is associated with a CG, set up the unmanaged CG
                if (hasCGs) {
                    for (List<Object> cg : volume.getConsistencyGroups()) {
                        // retrieve what should be the first and only consistency group from the list
                        // volumes belonging to multiple cgs are not supported and were excluded above
                        Object cgNameToProcess = cg.get(1);
                        addObjectToUnManagedConsistencyGroup(xtremIOClient, unManagedVolume, cgNameToProcess.toString(), storageSystem, xioClusterName, dbClient);
                    }
                } else {
                    // Make sure the unManagedVolume object does not contain CG information from previous discovery
                    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
                    // set the uri of the unmanaged CG in the unmanaged volume object to empty
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
                }
                if (isExported) {
                    Map<String, Integer> igHLUMap = new HashMap<String, Integer>();
                    for (List<Object> lunMapEntries : volume.getLunMaps()) {
                        Double hlu = (Double) lunMapEntries.get(2);
                        log.info("Found HLU {}", hlu);
                        List<Object> igDetails = (List<Object>) lunMapEntries.get(0);
                        // key value IG-HLU
                        igHLUMap.put(igDetails.get(1).toString(), Integer.valueOf(hlu.intValue()));
                    }
                    if (!igHLUMap.isEmpty()) {
                        volumeIGHLUMap.put(unManagedVolumeNatvieGuid, igHLUMap);
                    }
                }
                boolean hasReplicas = false;
                if (hasSnaps) {
                    StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
                    StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, volume.getSnaps(), unManagedVolumeNatvieGuid, parentMatchedVPools, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
                    if (!discoveredSnaps.isEmpty()) {
                        hasReplicas = true;
                        // set the HAS_REPLICAS property
                        unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
                        StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
                        if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
                            log.debug("Snaps :" + Joiner.on("\t").join(discoveredSnaps));
                            if (null != discoveredSnaps && discoveredSnaps.isEmpty()) {
                                // replace with empty string set doesn't work, hence added explicit code to remove all
                                unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
                            } else {
                                // replace with new StringSet
                                unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
                                log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
                            }
                        } else {
                            unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
                        }
                    }
                }
                if (!hasReplicas) {
                    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), FALSE);
                    StringSet snapshots = unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString());
                    if (snapshots != null && !snapshots.isEmpty()) {
                        unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
                    }
                }
                allCurrentUnManagedVolumeUris.add(unManagedVolume.getId());
            } catch (Exception ex) {
                log.error("Error processing XIO volume {}", volume, ex);
            }
        }
    }
    if (!unManagedCGToUpdateMap.isEmpty()) {
        unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
        partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
        unManagedCGToUpdate.clear();
    }
    if (!unManagedVolumesToCreate.isEmpty()) {
        partitionManager.insertInBatches(unManagedVolumesToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedVolumesToCreate.clear();
    }
    if (!unManagedVolumesToUpdate.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(unManagedVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedVolumesToUpdate.clear();
    }
    // Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
    DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allCurrentUnManagedVolumeUris, dbClient, partitionManager);
    // Process those active unmanaged consistency group objects available in database but not in newly discovered items, to mark them
    // inactive.
    DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
    // Next discover the unmanaged export masks
    discoverUnmanagedExportMasks(storageSystem.getId(), igUnmanagedVolumesMap, igKnownVolumesMap, xtremIOClient, xioClusterName, dbClient, partitionManager, volumeIGHLUMap);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) HashMap(java.util.HashMap) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 15 with XtremIOObjectInfo

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

the class XtremIOProvUtils method getInitiatorGroupVolumes.

/**
 * @param igName
 * @param clusterName
 * @param client
 * @return
 * @throws Exception
 */
public static List<XtremIOVolume> getInitiatorGroupVolumes(String igName, String clusterName, XtremIOClient client) throws Exception {
    List<XtremIOVolume> igVolumes = new ArrayList<XtremIOVolume>();
    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 igVolumes;
        }
        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);
            }
        }
    }
    for (XtremIOObjectInfo igLunMap : igLunMaps) {
        String[] igLunInfo = igLunMap.getName().split(XtremIOConstants.UNDERSCORE);
        igVolumes.add(client.getVolumeByIndex(igLunInfo[0], clusterName));
    }
    return igVolumes;
}
Also used : XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) XtremIOInitiatorGroup(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup) ArrayList(java.util.ArrayList) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)

Aggregations

XtremIOObjectInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo)15 ArrayList (java.util.ArrayList)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 URI (java.net.URI)9 XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)4 XtremIOLunMap (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMap)4 XtremIOVolume (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume)4 XtremIOInitiator (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)2 XtremIOInitiatorGroup (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorGroup)2 XtremIOInitiators (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiators)2 XtremIOInitiatorsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiatorsInfo)2 XtremIOLunMaps (com.emc.storageos.xtremio.restapi.model.response.XtremIOLunMaps)2 XtremIOPort (com.emc.storageos.xtremio.restapi.model.response.XtremIOPort)2 XtremIOPorts (com.emc.storageos.xtremio.restapi.model.response.XtremIOPorts)2 XtremIOPortsInfo (com.emc.storageos.xtremio.restapi.model.response.XtremIOPortsInfo)2 XtremIOVolumes (com.emc.storageos.xtremio.restapi.model.response.XtremIOVolumes)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2