use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExportUtils method updateZoningMap.
/**
* This method updates zoning map to add new assignments.
*
* @param dbClient an instance of {@link DbClient}
* @param exportMask The reference to exportMask
* @param assignments New assignments Map of initiator to storagePorts that will be updated in the zoning map
* @param exportMasksToUpdateOnDeviceWithStoragePorts OUT param -- Map of ExportMask to new Storage ports
* @return returns an updated exportMask
*/
public static ExportMask updateZoningMap(DbClient dbClient, ExportMask exportMask, Map<URI, List<URI>> assignments, Map<URI, List<URI>> exportMasksToUpdateOnDeviceWithStoragePorts) {
StringSetMap existingZoningMap = exportMask.getZoningMap();
for (URI initiatorURI : assignments.keySet()) {
boolean initiatorMatchFound = false;
if (existingZoningMap != null && !existingZoningMap.isEmpty()) {
for (String initiatorId : existingZoningMap.keySet()) {
if (initiatorURI.toString().equals(initiatorId)) {
StringSet ports = existingZoningMap.get(initiatorId);
if (ports != null && !ports.isEmpty()) {
initiatorMatchFound = true;
StringSet newTargets = StringSetUtil.uriListToStringSet(assignments.get(initiatorURI));
if (!ports.containsAll(newTargets)) {
ports.addAll(newTargets);
// Adds zoning map entry with new and existing ports. Its kind of updating storage ports for the initiator.
exportMask.addZoningMapEntry(initiatorId, ports);
updateExportMaskStoragePortsMap(exportMask, exportMasksToUpdateOnDeviceWithStoragePorts, assignments, initiatorURI);
}
}
}
}
}
if (!initiatorMatchFound) {
// Adds new zoning map entry for the initiator with new assignments as there isn't one already.
exportMask.addZoningMapEntry(initiatorURI.toString(), StringSetUtil.uriListToStringSet(assignments.get(initiatorURI)));
updateExportMaskStoragePortsMap(exportMask, exportMasksToUpdateOnDeviceWithStoragePorts, assignments, initiatorURI);
}
}
dbClient.persistObject(exportMask);
return exportMask;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExportUtils method getInitiatorPortsInMask.
/**
* Return the storage ports allocated to each initiators in an export mask by looking
* up the zoningMap.
*
* @param mask
* @param initiator
* @return
*/
public static List<URI> getInitiatorPortsInMask(ExportMask mask, Initiator initiator, DbClient dbClient) {
List<URI> list = new ArrayList<URI>();
StringSetMap zoningMap = mask.getZoningMap();
String strUri = initiator.getId().toString();
if (zoningMap != null && zoningMap.containsKey(strUri) && initiator.getProtocol().equals(Protocol.FC.toString())) {
list = StringSetUtil.stringSetToUriList(zoningMap.get(strUri));
}
_log.info("getInitiatorPortsInMask {} {}", initiator, Joiner.on(',').join(list));
return list;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class NetworkZoningParam method updateZoningParamUsingFCZoneReference.
/**
* Build the zoningMap attribute of zoningParam using FCZoneReference and exportGroup
*
* @param zoningParam
* @param initsToRemoveOnlyFromZone
* @param exportGroup
*/
public static void updateZoningParamUsingFCZoneReference(List<NetworkZoningParam> zoningParam, List<URI> initsToRemoveOnlyFromZone, ExportGroup exportGroup, DbClient dbClient) {
HashMap<String, Initiator> initiatorMap = new HashMap<String, Initiator>();
for (URI initiatorURI : initsToRemoveOnlyFromZone) {
Initiator iniObject = dbClient.queryObject(Initiator.class, initiatorURI);
String iniString = iniObject.getInitiatorPort().toUpperCase();
initiatorMap.put(iniString, iniObject);
}
// Retrieve FCZoneReference zone references that have the same initiator WWN.
// These zone should be removed. since the initiator is no longer available.
List<FCZoneReference> fcRefs = NetworkUtil.getFCZoneReferencesFromExportGroup(dbClient, exportGroup);
Set<String> iniConsidered = new HashSet<String>();
for (NetworkZoningParam networkZoningParam : zoningParam) {
StringSetMap zoneMap = networkZoningParam.getZoningMap();
if (zoneMap.isEmpty()) {
for (FCZoneReference fcZoneReference : fcRefs) {
String[] initiatorAndPort = getInitiatorAndPortFromPwwnKey(fcZoneReference.getPwwnKey());
if (initiatorAndPort != null) {
String initiator = initiatorAndPort[0];
String port = initiatorAndPort[1];
Initiator iniObject = initiatorMap.get(initiator);
if (iniObject != null) {
StoragePort sp = NetworkUtil.getStoragePort(port, dbClient);
if (sp != null) {
iniConsidered.add(iniObject.getInitiatorPort());
zoneMap.put(iniObject.getId().toString(), sp.getId().toString());
}
}
} else {
_log.warn("Could not obtain initiator and port correctly from the PwwnKey {}", fcZoneReference.getPwwnKey());
}
}
// removed the initiator from map the as this initiator is considered for zone map
if (!iniConsidered.isEmpty()) {
initiatorMap.keySet().removeAll(iniConsidered);
}
}
}
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ObjectVirtualPoolService method prepareVirtualPool.
// this method must not persist anything to the DB.
private VirtualPool prepareVirtualPool(ObjectVirtualPoolParam param) {
VirtualPool vPool = new VirtualPool();
vPool.setType(VirtualPool.Type.object.name());
// set common VirtualPool parameters.
populateCommonVirtualPoolCreateParams(vPool, param);
StringSetMap arrayInfo = new StringSetMap();
if (null != param.getSystemType()) {
if (!VirtualPool.SystemType.NONE.toString().equals(param.getSystemType()) && !VirtualPool.SystemType.isObjectTypeSystem(param.getSystemType())) {
throw APIException.badRequests.invalidParameter("system_type", param.getSystemType());
}
arrayInfo.put(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE, param.getSystemType());
vPool.addArrayInfoDetails(arrayInfo);
}
if (null != param.getMaxRetention()) {
vPool.setMaxRetention(param.getMaxRetention());
}
if (null != param.getMinDataCenters()) {
vPool.setMinDataCenters(param.getMinDataCenters());
}
return vPool;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class PlacementTests method testPlacementRpXIONoVplex.
/**
* RP placement tests with XIO (no VPLEX)
*/
@Test
public void testPlacementRpXIONoVplex() {
String[] xio1FE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01" };
String[] xio2FE = { "51:FE:FE:FE:FE:FE:FE:00", "51:FE:FE:FE:FE:FE:FE:01" };
String[] xio3FE = { "52:FE:FE:FE:FE:FE:FE:00", "52:FE:FE:FE:FE:FE:FE:01" };
String[] xio4FE = { "53:FE:FE:FE:FE:FE:FE:00", "53:FE:FE:FE:FE:FE:FE:01" };
String[] xio5FE = { "54:FE:FE:FE:FE:FE:FE:00", "54:FE:FE:FE:FE:FE:FE:01" };
String[] xio6FE = { "55:FE:FE:FE:FE:FE:FE:00", "55:FE:FE:FE:FE:FE:FE:01" };
String[] rp1FE = { "56:FE:FE:FE:FE:FE:FE:00", "56:FE:FE:FE:FE:FE:FE:01" };
String[] rp2FE = { "57:FE:FE:FE:FE:FE:FE:00", "57:FE:FE:FE:FE:FE:FE:01" };
// Create 2 Virtual Arrays
VirtualArray varray1 = PlacementTestUtils.createVirtualArray(_dbClient, "varray1");
VirtualArray varray2 = PlacementTestUtils.createVirtualArray(_dbClient, "varray2");
// Create 2 Networks
StringSet connVA = new StringSet();
connVA.add(varray1.getId().toString());
Network network1 = PlacementTestUtils.createNetwork(_dbClient, rp1FE, "VSANSite1", "FC+BROCADE+FE", connVA);
connVA = new StringSet();
connVA.add(varray2.getId().toString());
Network network2 = PlacementTestUtils.createNetwork(_dbClient, rp2FE, "VSANSite2", "FC+CISCO+FE", connVA);
// Create 6 storage systems
StorageSystem storageSystem1 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio1");
StorageSystem storageSystem2 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio2");
StorageSystem storageSystem3 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio3");
StorageSystem storageSystem4 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio4");
StorageSystem storageSystem5 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio5");
StorageSystem storageSystem6 = PlacementTestUtils.createStorageSystem(_dbClient, "xtremio", "xtremio6");
// Create two front-end storage ports XIO1
List<StoragePort> xio1Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio1FE.length; i++) {
xio1Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem1, network1, xio1FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio1" + i, "C0+FC0" + i));
}
// Create two front-end storage ports XIO2
List<StoragePort> xio2Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio2FE.length; i++) {
xio2Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem2, network1, xio2FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio2" + i, "D0+FC0" + i));
}
// Create two front-end storage ports XIO3
List<StoragePort> xio3Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio3FE.length; i++) {
xio3Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem3, network1, xio3FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1xio3" + i, "E0+FC0" + i));
}
// Create two front-end storage ports XIO4
List<StoragePort> xio4Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio4FE.length; i++) {
xio4Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem4, network2, xio4FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio4" + i, "F0+FC0" + i));
}
// Create two front-end storage ports XIO5
List<StoragePort> xio5Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio5FE.length; i++) {
xio5Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem5, network2, xio5FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio5" + i, "G0+FC0" + i));
}
// Create two front-end storage ports XIO6
List<StoragePort> xio6Ports = new ArrayList<StoragePort>();
for (int i = 0; i < xio6FE.length; i++) {
xio6Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem6, network2, xio6FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2xio6" + i, "H0+FC0" + i));
}
// Create RP system
AbstractChangeTrackingSet<String> wwnSite1 = new StringSet();
for (int i = 0; i < rp1FE.length; i++) {
wwnSite1.add(rp1FE[i]);
}
StringSetMap initiatorsSiteMap = new StringSetMap();
initiatorsSiteMap.put("site1", wwnSite1);
AbstractChangeTrackingSet<String> wwnSite2 = new StringSet();
for (int i = 0; i < rp2FE.length; i++) {
wwnSite2.add(rp2FE[i]);
}
initiatorsSiteMap.put("site2", wwnSite2);
StringSet storSystems = new StringSet();
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem1.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem2.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", storageSystem3.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem4.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem5.getSerialNumber()));
storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", storageSystem6.getSerialNumber()));
StringMap siteVolCap = new StringMap();
siteVolCap.put("site1", "3221225472");
siteVolCap.put("site2", "3221225472");
StringMap siteVolCnt = new StringMap();
siteVolCnt.put("site1", "10");
siteVolCnt.put("site2", "10");
ProtectionSystem rpSystem = PlacementTestUtils.createProtectionSystem(_dbClient, "rp", "rp1", "site1", "site2", null, "IP", initiatorsSiteMap, storSystems, null, Long.valueOf("3221225472"), Long.valueOf("2"), siteVolCap, siteVolCnt);
// RP Site Array objects
RPSiteArray rpSiteArray1 = new RPSiteArray();
rpSiteArray1.setId(URI.create("rsa1"));
rpSiteArray1.setStorageSystem(URI.create("xtremio1"));
rpSiteArray1.setRpInternalSiteName("site1");
rpSiteArray1.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray1);
RPSiteArray rpSiteArray2 = new RPSiteArray();
rpSiteArray2.setId(URI.create("rsa2"));
rpSiteArray2.setStorageSystem(URI.create("xtremio2"));
rpSiteArray2.setRpInternalSiteName("site1");
rpSiteArray2.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray2);
RPSiteArray rpSiteArray3 = new RPSiteArray();
rpSiteArray3.setId(URI.create("rsa3"));
rpSiteArray3.setStorageSystem(URI.create("xtremio3"));
rpSiteArray3.setRpInternalSiteName("site1");
rpSiteArray3.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray3);
RPSiteArray rpSiteArray4 = new RPSiteArray();
rpSiteArray4.setId(URI.create("rsa4"));
rpSiteArray4.setStorageSystem(URI.create("xtremio4"));
rpSiteArray4.setRpInternalSiteName("site2");
rpSiteArray4.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray4);
RPSiteArray rpSiteArray5 = new RPSiteArray();
rpSiteArray5.setId(URI.create("rsa5"));
rpSiteArray5.setStorageSystem(URI.create("xtremio5"));
rpSiteArray5.setRpInternalSiteName("site2");
rpSiteArray5.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray5);
RPSiteArray rpSiteArray6 = new RPSiteArray();
rpSiteArray6.setId(URI.create("rsa6"));
rpSiteArray6.setStorageSystem(URI.create("xtremio6"));
rpSiteArray6.setRpInternalSiteName("site2");
rpSiteArray6.setRpProtectionSystem(rpSystem.getId());
_dbClient.createObject(rpSiteArray6);
// Create a storage pool for xio1
StoragePool pool1 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem1, "pool1", "Pool1", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio2
StoragePool pool2 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem2, "pool2", "Pool2", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio3
StoragePool pool3 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem3, "pool3", "Pool3", Long.valueOf(1024 * 1024 * 1), Long.valueOf(1024 * 1024 * 1), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio4
StoragePool pool4 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem4, "pool4", "Pool4", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio5
StoragePool pool5 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem5, "pool5", "Pool5", Long.valueOf(1024 * 1024 * 10), Long.valueOf(1024 * 1024 * 10), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a storage pool for xio6
StoragePool pool6 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem6, "pool6", "Pool6", Long.valueOf(1024 * 1024 * 1), Long.valueOf(1024 * 1024 * 1), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
// Create a RP virtual pool
VirtualPool rpVpool = new VirtualPool();
rpVpool.setId(URI.create("rpVpool"));
rpVpool.setLabel("rpVpool");
rpVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
rpVpool.setDriveType(SupportedDriveTypes.FC.name());
VpoolProtectionVarraySettings protectionSettings = new VpoolProtectionVarraySettings();
protectionSettings.setVirtualPool(URI.create("vpool"));
protectionSettings.setId(URI.create("protectionSettings"));
_dbClient.createObject(protectionSettings);
List<VpoolProtectionVarraySettings> protectionSettingsList = new ArrayList<VpoolProtectionVarraySettings>();
protectionSettingsList.add(protectionSettings);
StringMap protectionVarray = new StringMap();
protectionVarray.put(varray2.getId().toString(), protectionSettingsList.get(0).getId().toString());
rpVpool.setProtectionVarraySettings(protectionVarray);
rpVpool.setRpCopyMode("SYNCHRONOUS");
rpVpool.setRpRpoType("MINUTES");
rpVpool.setRpRpoValue(Long.valueOf("5"));
StringSet matchedPools = new StringSet();
matchedPools.add(pool1.getId().toString());
matchedPools.add(pool2.getId().toString());
matchedPools.add(pool3.getId().toString());
rpVpool.setMatchedStoragePools(matchedPools);
rpVpool.setUseMatchedPools(true);
StringSet virtualArrays1 = new StringSet();
virtualArrays1.add(varray1.getId().toString());
rpVpool.setVirtualArrays(virtualArrays1);
_dbClient.createObject(rpVpool);
// Create a virtual pool
VirtualPool vpool = new VirtualPool();
vpool.setId(URI.create("vpool"));
vpool.setLabel("vpool");
vpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
vpool.setDriveType(SupportedDriveTypes.FC.name());
matchedPools = new StringSet();
matchedPools.add(pool4.getId().toString());
matchedPools.add(pool5.getId().toString());
matchedPools.add(pool6.getId().toString());
vpool.setMatchedStoragePools(matchedPools);
vpool.setUseMatchedPools(true);
StringSet virtualArrays2 = new StringSet();
virtualArrays2.add(varray2.getId().toString());
vpool.setVirtualArrays(virtualArrays2);
_dbClient.createObject(vpool);
// Create Tenant
TenantOrg tenant = new TenantOrg();
tenant.setId(URI.create("tenant"));
_dbClient.createObject(tenant);
// Create a project object
Project project = new Project();
project.setId(URI.create("project"));
project.setLabel("project");
project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
_dbClient.createObject(project);
// Create block consistency group
BlockConsistencyGroup cg = new BlockConsistencyGroup();
cg.setProject(new NamedURI(project.getId(), project.getLabel()));
cg.setId(URI.create("blockCG"));
_dbClient.createObject(cg);
// Create capabilities
VirtualPoolCapabilityValuesWrapper capabilities = PlacementTestUtils.createCapabilities("2GB", 1, cg);
// Run single volume placement: Run 10 times to make sure pool3 never comes up for source and pool6 for target.
for (int i = 0; i < 10; i++) {
List recommendations = PlacementTestUtils.invokePlacement(_dbClient, _coordinator, varray1, project, rpVpool, capabilities);
assertNotNull(recommendations);
assertTrue(!recommendations.isEmpty());
assertNotNull(recommendations.get(0));
RPProtectionRecommendation rec = (RPProtectionRecommendation) recommendations.get(0);
assertNotNull(rec.getSourceRecommendations());
assertTrue(!rec.getSourceRecommendations().isEmpty());
assertNotNull(rec.getProtectionDevice());
assertNotNull(rec.getPlacementStepsCompleted().name());
assertTrue("rp1".equals(rec.getProtectionDevice().toString()));
for (RPRecommendation sourceRec : rec.getSourceRecommendations()) {
assertNotNull(sourceRec);
assertNotNull(sourceRec.getInternalSiteName());
assertNotNull(sourceRec.getSourceStorageSystem());
assertNotNull(sourceRec.getSourceStoragePool());
assertTrue(sourceRec.getVirtualArray().toString().equals("varray1"));
assertTrue("site1".equals(sourceRec.getInternalSiteName()));
assertTrue("xtremio2".equals(sourceRec.getSourceStorageSystem().toString()));
assertTrue(("pool2".equals(sourceRec.getSourceStoragePool().toString())) || ("pool1".equals(sourceRec.getSourceStoragePool().toString())));
assertNotNull(sourceRec.getTargetRecommendations());
assertTrue(!sourceRec.getTargetRecommendations().isEmpty());
for (RPRecommendation targetRec : sourceRec.getTargetRecommendations()) {
assertNotNull(targetRec.getSourceStoragePool());
assertTrue("xtremio4".equals(targetRec.getSourceStorageSystem().toString()));
assertTrue("site2".equals(targetRec.getInternalSiteName()));
assertTrue(targetRec.getVirtualArray().toString().equals("varray2"));
assertTrue("pool4".equals(targetRec.getSourceStoragePool().toString()) || "pool5".equals(targetRec.getSourceStoragePool().toString()));
}
}
// source journal
assertNotNull(rec.getSourceJournalRecommendation());
assertNotNull(rec.getSourceJournalRecommendation().getSourceStoragePool());
assertTrue(("pool2".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())) || ("pool1".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())));
// target journal
assertNotNull(rec.getTargetJournalRecommendations());
assertTrue(!rec.getTargetJournalRecommendations().isEmpty());
for (RPRecommendation targetJournalRec : rec.getTargetJournalRecommendations()) {
assertNotNull(targetJournalRec.getSourceStoragePool());
assertTrue(targetJournalRec.getVirtualArray().toString().equals("varray2"));
assertTrue("pool4".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool5".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool6".equals(targetJournalRec.getSourceStoragePool().toString()));
assertTrue("site2".equals(targetJournalRec.getInternalSiteName()));
assertTrue("xtremio4".equals(targetJournalRec.getSourceStorageSystem().toString()) || "xtremio5".equals(targetJournalRec.getSourceStorageSystem().toString()) || "xtremio6".equals(targetJournalRec.getSourceStorageSystem().toString()));
}
_log.info(rec.toString(_dbClient));
}
}
Aggregations