use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class ExportUtilsTestUtils method createStorageSystem.
public static StorageSystem createStorageSystem(DbClient _dbClient, String type, String label) {
StorageSystem storageSystem = new StorageSystem();
storageSystem.setId(URI.create(label));
storageSystem.setLabel(label);
storageSystem.setNativeGuid(label);
storageSystem.setInactive(false);
storageSystem.setSystemType(type);
storageSystem.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
storageSystem.setReachableStatus(true);
if (type.equals("vplex")) {
storageSystem.setSerialNumber(label + "cluster1:" + label + "cluster2");
StringMap vplexAssemblyIdtoClusterId = new StringMap();
vplexAssemblyIdtoClusterId.put(label + "cluster1", "1");
vplexAssemblyIdtoClusterId.put(label + "cluster2", "2");
storageSystem.setVplexAssemblyIdtoClusterId(vplexAssemblyIdtoClusterId);
} else {
storageSystem.setSerialNumber(label);
}
_dbClient.createObject(storageSystem);
return storageSystem;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class NetworkScheduler method getZoningTargetsForPaths.
/**
* Returns a list of zoning targets for adding paths to the export mask.
*
* @param exportGroup ExportGroup
* @param exportMaskURIs export mask URIs
* @param path Map of initiator URI to List of storage port URIs
* @param zonesMap a list of existing zones mapped by the initiator port WWN
* @param dbClient
* @return List of Zones (NetworkFCZoneInfo)
* @throws DeviceControllerException
*/
public List<NetworkFCZoneInfo> getZoningTargetsForPaths(URI storageSystemURI, ExportGroup exportGroup, Collection<URI> exportMaskURIs, Map<URI, List<URI>> paths, Map<String, List<Zone>> zonesMap, DbClient dbClient) throws DeviceControllerException {
List<NetworkFCZoneInfo> zones = new ArrayList<NetworkFCZoneInfo>();
if (!isZoningRequired(dbClient, exportGroup.getVirtualArray())) {
_log.info("Zoning not required, returning empty zones list");
return zones;
}
for (URI maskURI : exportMaskURIs) {
ExportMask mask = _dbClient.queryObject(ExportMask.class, maskURI);
StringMap volumeMap = mask.getVolumes();
if (volumeMap == null || volumeMap.isEmpty()) {
_log.info(String.format("There are no volumes in the export mask %s, skipping", mask.getMaskName()));
continue;
}
List<URI> maskVolumes = StringSetUtil.stringSetToUriList(volumeMap.keySet());
List<ExportGroup> maskExportGroups = ExportMaskUtils.getExportGroups(dbClient, mask);
// Filter the paths based on the initiators in zoningMap of this ExportMask
Map<URI, List<URI>> pathsForMask = new HashMap<URI, List<URI>>();
for (String initiatorString : mask.getInitiators()) {
URI initiatorKey = URI.create(initiatorString);
if (paths.containsKey(initiatorKey)) {
pathsForMask.put(initiatorKey, paths.get(initiatorKey));
}
}
// Use the intersection of the volumes in the ExportMask and ExportGroup.
for (ExportGroup group : maskExportGroups) {
if (group.getVolumes() != null) {
List<URI> volumes = new ArrayList<URI>(maskVolumes);
volumes.retainAll(StringSetUtil.stringSetToUriList(group.getVolumes().keySet()));
zones.addAll(getZoningTargetsForPaths(group, volumes, exportGroup.getVirtualArray(), pathsForMask, zonesMap));
}
}
// Check for zones needed in alternate varray for VPLEX cross-connected
if (exportGroup.hasAltVirtualArray(storageSystemURI.toString())) {
URI altVirtualArray = URI.create(exportGroup.getAltVirtualArrays().get(storageSystemURI.toString()));
if (isZoningRequired(dbClient, altVirtualArray)) {
for (ExportGroup group : maskExportGroups) {
if (group.getVolumes() != null) {
List<URI> volumes = new ArrayList<URI>(maskVolumes);
volumes.retainAll(StringSetUtil.stringSetToUriList(group.getVolumes().keySet()));
zones.addAll(getZoningTargetsForPaths(group, volumes, altVirtualArray, pathsForMask, zonesMap));
}
}
}
}
}
return zones;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VPlexUtil method getVPlexClusterSerialNumber.
/**
* Returns the assembly id (i.e., serial number) for the passed cluster on
* the passed VPLEX system.
*
* @param clusterId The cluster Id.
* @param vplexSystem A reference to the VPLEX system
*
* @return The serial number for the passed cluster.
*/
public static String getVPlexClusterSerialNumber(String clusterId, StorageSystem vplexSystem) {
String clusterSerialNo = null;
StringMap assemblyIdMap = vplexSystem.getVplexAssemblyIdtoClusterId();
if ((assemblyIdMap == null) || (assemblyIdMap.isEmpty())) {
_log.warn("Assembly id map not set for storage system {}", vplexSystem.getId());
}
for (String assemblyId : assemblyIdMap.keySet()) {
String clusterIdForAssemblyId = assemblyIdMap.get(assemblyId);
if (clusterId.equals(clusterIdForAssemblyId)) {
// The cluster assembly id is the cluster serial number.
clusterSerialNo = assemblyId;
break;
}
}
// serial number.
if (clusterSerialNo == null) {
_log.warn("Could not determine assembly id for cluster {} for VPLEX {}", clusterId, vplexSystem.getId());
clusterSerialNo = vplexSystem.getSerialNumber();
}
return clusterSerialNo;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VPlexUtil method getHAMirrorVpool.
/**
* Convenience method to get HA MirrorVpool if it's set.
*
* @param sourceVirtualPool A Reference to VPLEX Volume source virtual pool
* @param associatedVolumeIds Set of associated backend volumes for a VPLEX volume
* @param dbClient an instance of {@link DbClient}
*
* @return returns HA mirror vpool if its set for the HA Vpool else returns null
*/
public static VirtualPool getHAMirrorVpool(VirtualPool sourceVirtualPool, StringSet associatedVolumeIds, DbClient dbClient) {
VirtualPool haMirrorVpool = null;
StringMap haVarrayVpoolMap = sourceVirtualPool.getHaVarrayVpoolMap();
if (associatedVolumeIds.size() > 1 && haVarrayVpoolMap != null && !haVarrayVpoolMap.isEmpty()) {
String haVarray = haVarrayVpoolMap.keySet().iterator().next();
String haVpoolStr = haVarrayVpoolMap.get(haVarray);
if (haVpoolStr != null && !(haVpoolStr.equals(NullColumnValueGetter.getNullURI().toString()))) {
VirtualPool haVpool = dbClient.queryObject(VirtualPool.class, URI.create(haVpoolStr));
if (haVpool.getMirrorVirtualPool() != null) {
haMirrorVpool = dbClient.queryObject(VirtualPool.class, URI.create(haVpool.getMirrorVirtualPool()));
}
}
}
return haMirrorVpool;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class ExportUtils method getAllLUNsForHost.
/**
* Get all LUNs on the array that mapped to a host identified by initiators in the mask
*
* @param dbClient
* @param exportMask
* @return LUNs mapped to the host
*/
public static Set<String> getAllLUNsForHost(DbClient dbClient, ExportMask exportMask) {
Set<String> lunIds = new HashSet<>();
URI storageUri = exportMask.getStorageDevice();
if (NullColumnValueGetter.isNullURI(storageUri)) {
return lunIds;
}
URI hostUri = null;
for (String init : exportMask.getInitiators()) {
Initiator initiator = dbClient.queryObject(Initiator.class, URI.create(init));
if (initiator != null && !initiator.getInactive()) {
hostUri = initiator.getHost();
if (!NullColumnValueGetter.isNullURI(hostUri)) {
break;
}
}
}
// get initiators from host
Map<URI, ExportMask> exportMasks = new HashMap<>();
if (!NullColumnValueGetter.isNullURI(hostUri)) {
URIQueryResultList list = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(hostUri, Initiator.class, "host"), list);
Iterator<URI> uriIter = list.iterator();
while (uriIter.hasNext()) {
URI initiatorId = uriIter.next();
URIQueryResultList egUris = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getExportGroupInitiatorConstraint(initiatorId.toString()), egUris);
ExportGroup exportGroup = null;
for (URI egUri : egUris) {
exportGroup = dbClient.queryObject(ExportGroup.class, egUri);
if (exportGroup == null || exportGroup.getInactive() || exportGroup.getExportMasks() == null) {
continue;
}
List<ExportMask> masks = ExportMaskUtils.getExportMasks(dbClient, exportGroup);
for (ExportMask mask : masks) {
if (mask != null && !mask.getInactive() && mask.hasInitiator(initiatorId.toString()) && mask.getVolumes() != null && storageUri.equals(mask.getStorageDevice())) {
exportMasks.put(mask.getId(), mask);
}
}
}
}
}
for (ExportMask mask : exportMasks.values()) {
StringMap volumeMap = mask.getVolumes();
if (volumeMap != null && !volumeMap.isEmpty()) {
for (String strUri : mask.getVolumes().keySet()) {
BlockObject bo = BlockObject.fetch(dbClient, URI.create(strUri));
if (bo != null && !bo.getInactive()) {
lunIds.add(bo.getNativeId());
}
}
}
}
return lunIds;
}
Aggregations