use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class RPCommunicationInterface method discoverVisibleStorageSystems.
/**
* Discovers the Storage Systems associated to the Protection System.
*
* @param protectionSystem A reference to the Protection System
*/
private void discoverVisibleStorageSystems(ProtectionSystem protectionSystem) {
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
Map<String, Set<String>> siteStorageSystems = rp.getArraysForClusters();
if (protectionSystem.getSiteVisibleStorageArrays() != null) {
protectionSystem.getSiteVisibleStorageArrays().clear();
} else {
protectionSystem.setSiteVisibleStorageArrays(new StringSetMap());
}
List<URI> storageSystemIDs = _dbClient.queryByType(StorageSystem.class, true);
if (storageSystemIDs == null) {
return;
}
List<StorageSystem> storageSystems = _dbClient.queryObject(StorageSystem.class, storageSystemIDs);
if (storageSystems == null) {
return;
}
// (for the arrays ViPR knows about)
if (siteStorageSystems != null) {
for (Map.Entry<String, Set<String>> clusterEntry : siteStorageSystems.entrySet()) {
if (clusterEntry.getValue() == null || clusterEntry.getValue().isEmpty()) {
continue;
}
for (String serialNumber : clusterEntry.getValue()) {
if (serialNumber == null || serialNumber.isEmpty()) {
continue;
}
// Find the storage system ID associated with this serial number
// We have a serial number from the RP appliances, and for the most part, that works
// with a Constraint Query, but in the case of VPLEX, the serial number object for distributed
// VPLEX clusters will contain two serial numbers, not just one. So we need a long-form
// way of finding those VPLEXs as well.
Iterator<StorageSystem> activeSystemListItr = storageSystems.iterator();
StorageSystem foundStorageSystem = null;
while (activeSystemListItr.hasNext() && foundStorageSystem == null) {
StorageSystem system = activeSystemListItr.next();
if (NullColumnValueGetter.isNotNullValue(system.getSerialNumber()) && system.getSerialNumber().contains(serialNumber)) {
foundStorageSystem = system;
}
}
if (foundStorageSystem != null) {
protectionSystem.addSiteVisibleStorageArrayEntry(clusterEntry.getKey(), serialNumber);
_log.info(String.format("RP Discovery found RP cluster %s is configured to use a registered storage system: %s, %s", clusterEntry.getKey(), serialNumber, foundStorageSystem.getNativeGuid()));
} else {
_log.info(String.format("RP Discovery found RP cluster %s is configured to use a storage system: %s, but it is not configured for use in ViPR", clusterEntry.getKey(), serialNumber));
}
}
}
}
_dbClient.persistObject(protectionSystem);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VirtualPoolMapper method mapVirtualPoolFields.
private static <T extends VirtualPoolCommonRestRep> T mapVirtualPoolFields(VirtualPool from, T to, Map<URI, VpoolProtectionVarraySettings> protectionSettings) {
mapDataObjectFieldsNoLink(from, to);
ResourceTypeEnum type = ResourceTypeEnum.BLOCK_VPOOL;
switch(VirtualPool.Type.valueOf(from.getType())) {
case block:
type = ResourceTypeEnum.BLOCK_VPOOL;
break;
case file:
type = ResourceTypeEnum.FILE_VPOOL;
break;
case object:
type = ResourceTypeEnum.OBJECT_VPOOL;
}
to.setLink(new RestLinkRep("self", RestLinkFactory.newLink(type, from.getId())));
to.setType(from.getType());
to.setDescription(from.getDescription());
to.setProtocols(from.getProtocols());
to.setProvisioningType(from.getSupportedProvisioningType());
to.setNumPaths(from.getNumPaths());
if (from.getArrayInfo() != null) {
StringSetMap arrayInfo = from.getArrayInfo();
// System Type
StringSet systemTypes = arrayInfo.get(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE);
if (systemTypes != null) {
// TODO: CD - This does not seem right. Do we support many?
for (String systemType : systemTypes) {
to.setSystemType(systemType);
}
}
}
if (!VdcUtil.isRemoteObject(from)) {
mapVirtualPoolCommonLocalMappings(from, to);
}
return to;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExportMaskUtils method initializeExportMaskWithVolumes.
// don't want to disturb the existing method, hence overloaded
public static <T extends BlockObject> ExportMask initializeExportMaskWithVolumes(URI storage, ExportGroup exportGroup, String maskName, String maskLabel, List<Initiator> initiators, Map<URI, Integer> volumeMap, List<URI> targets, ZoneInfoMap zoneInfoMap, T volume, Set<String> unManagedInitiators, String nativeId, List<Initiator> userAddedInis, DbClient dbClient, Map<String, Integer> wwnToHluMap) throws Exception {
ExportMask exportMask = new ExportMask();
exportMask.setId(URIUtil.createId(ExportMask.class));
exportMask.setMaskName(maskName);
exportMask.setStorageDevice(storage);
String resourceRef;
if (exportGroup.getType() != null) {
if (exportGroup.getType().equals(ExportGroup.ExportGroupType.Cluster.name())) {
resourceRef = initiators.get(0).getClusterName();
} else {
resourceRef = initiators.get(0).getHost().toString();
}
exportMask.setResource(resourceRef);
} else {
// This resource is used when we add initiators to existing masks on VMAX, which should not be
// case with VPLEX and RP, which do not associate their initiators with hosts or clusters.
exportMask.setResource(NullColumnValueGetter.getNullURI().toString());
}
exportMask.setLabel(maskLabel);
exportMask.setCreatedBySystem(true);
exportMaskUpdate(exportMask, null, initiators, targets);
StringSetMap zoneMap = getZoneMapFromZoneInfoMap(zoneInfoMap, initiators);
if (!zoneMap.isEmpty()) {
exportMask.setZoningMap(zoneMap);
}
exportMask.addToExistingInitiatorsIfAbsent(new ArrayList<String>(unManagedInitiators));
exportMask.addToUserCreatedInitiators(userAddedInis);
// if the block object is marked as internal, then add to existing volumes of the mask
if (volume.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
_log.info("Block object {} is marked internal. Adding to existing volumes of the mask {}", volume.getNativeGuid(), exportMask.getMaskName());
String hlu = ExportGroup.LUN_UNASSIGNED_STR;
if (wwnToHluMap.containsKey(volume.getWWN())) {
hlu = String.valueOf(wwnToHluMap.get(volume.getWWN()));
}
exportMask.addToExistingVolumesIfAbsent(volume, hlu);
} else {
exportMask.addToUserCreatedVolumes(volume);
exportMask.removeFromExistingVolumes(volume);
}
Integer hlu = wwnToHluMap.get(volume.getWWN()) != null ? wwnToHluMap.get(volume.getWWN()) : ExportGroup.LUN_UNASSIGNED;
exportMask.addVolume(volume.getId(), hlu);
exportMask.setNativeId(nativeId);
// need to sync up all remaining existing volumes
exportMask.addToExistingVolumesIfAbsent(wwnToHluMap);
// Update the FCZoneReferences if zoning is enables for the varray
updateFCZoneReferences(exportGroup, exportMask, volume, zoneInfoMap, initiators, dbClient);
return exportMask;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExportMaskUtils method getNewPaths.
/*
* Get new paths which are not in any of the export masks zoning maps from the given paths
*
* @param dbClient
* @param exportMasks
* @param maskURIs - OUTPUT the export masks URI list which have zoning map entries
* @param paths - new and retained paths
* @return - the new paths for the export masks
*/
public static Map<URI, List<URI>> getNewPaths(DbClient dbClient, List<ExportMask> exportMasks, List<URI> maskURIs, Map<URI, List<URI>> paths) {
Map<URI, List<URI>> newPaths = new HashMap<URI, List<URI>>();
StringSetMap allZoningMap = new StringSetMap();
for (ExportMask mask : exportMasks) {
StringSetMap map = mask.getZoningMap();
if (map != null && !map.isEmpty()) {
for (String init : map.keySet()) {
StringSet allPorts = allZoningMap.get(init);
if (allPorts == null) {
allPorts = new StringSet();
allZoningMap.put(init, allPorts);
}
allPorts.addAll(map.get(init));
}
maskURIs.add(mask.getId());
}
}
for (Map.Entry<URI, List<URI>> entry : paths.entrySet()) {
URI init = entry.getKey();
List<URI> entryPorts = entry.getValue();
StringSet zoningPorts = allZoningMap.get(init.toString());
if (zoningPorts != null && !zoningPorts.isEmpty()) {
List<URI> diffPorts = new ArrayList<URI>(Sets.difference(newHashSet(entryPorts), zoningPorts));
if (diffPorts != null && !diffPorts.isEmpty()) {
newPaths.put(init, diffPorts);
}
} else {
newPaths.put(init, entryPorts);
}
}
return newPaths;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExportMaskUtils method initializeExportMask.
/**
* Create and initialize the ExportMask. To do this we:
* 1. Create and persist the ExportMask.
* 2. Save our targets and exportMaskURI in the ExportGroupCreateData.
*
* @param storage - Storage System
* @param exportGroup - ExportGroup object this ExportMask will apply to
* @param initiators - Initiator objects pointing to initiators for this mask
* @param volumeMap - Map of Volume URIs to Integer HLUs
* @param targets List<URI> of StoragePorts
* @param zoneAssignments - Map from InitiatorURI to List of assigned port URIs.
* @param maskName the mask name
* @param dbClient an instance of DbClient
* @return new ExportMask object, persisted in database
* @throws Exception
*/
public static ExportMask initializeExportMask(StorageSystem storage, ExportGroup exportGroup, List<Initiator> initiators, Map<URI, Integer> volumeMap, List<URI> targets, Map<URI, List<URI>> zoneAssignments, String maskName, DbClient dbClient) throws Exception {
if (maskName == null) {
maskName = ExportMaskUtils.getMaskName(dbClient, initiators, exportGroup, storage);
}
ExportMask exportMask = ExportMaskUtils.createExportMask(dbClient, exportGroup, storage.getId(), maskName);
String resourceRef;
if (exportGroup.getType() != null) {
if (exportGroup.getType().equals(ExportGroup.ExportGroupType.Cluster.name())) {
resourceRef = initiators.get(0).getClusterName();
} else {
resourceRef = initiators.get(0).getHost().toString();
}
exportMask.setResource(resourceRef);
} else {
// This resource is used when we add initiators to existing masks on VMAX, which should not be
// case with VPLEX and RP, which do not associate their initiators with hosts or clusters.
exportMask.setResource(NullColumnValueGetter.getNullURI().toString());
}
exportMask.setCreatedBySystem(true);
exportMaskUpdate(exportMask, volumeMap, initiators, targets);
if (!exportGroup.getZoneAllInitiators() && null != zoneAssignments) {
StringSetMap zoneMap = getZoneMapFromAssignments(zoneAssignments);
if (!zoneMap.isEmpty()) {
exportMask.setZoningMap(zoneMap);
}
}
dbClient.updateObject(exportMask);
return exportMask;
}
Aggregations