use of com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy in project coprhd-controller by CoprHD.
the class SmisCommandHelper method getExportMaskPolicy.
/**
* Get policy and host limits information about the export mask that is specific to VMAX.
*
* @param storage
* storage system
* @param exportMask
* export mask
* @return export mask policy
*/
public ExportMaskPolicy getExportMaskPolicy(StorageSystem storage, ExportMask exportMask) {
ExportMaskPolicy policy = new ExportMaskPolicy();
policy.simpleMask = false;
CloseableIterator<CIMInstance> cimInstanceItr = null;
String storageGroupName;
try {
CIMObjectPath maskingViewPath = _cimPath.getMaskingViewPath(storage, exportMask.getMaskName());
CIMInstance maskingViewInstance = checkExists(storage, maskingViewPath, false, false);
String maxUnitsControlled = CIMPropertyFactory.getPropertyValue(maskingViewInstance, CP_MAX_UNITS_CONTROLLED);
if (!Strings.isNullOrEmpty(maxUnitsControlled)) {
int maxVolumesAllowed = Integer.valueOf(maxUnitsControlled);
policy.setMaxVolumesAllowed(maxVolumesAllowed);
}
storageGroupName = getStorageGroupForGivenMaskingView(maskingViewInstance, exportMask.getMaskName(), storage);
CIMObjectPath storageGroupPath = _cimPath.getStorageGroupObjectPath(storageGroupName, storage);
CIMObjectPath igPath = getInitiatorGroupForGivenMaskingView(exportMask.getMaskName(), storage);
if (isCascadedIG(storage, igPath)) {
policy.setIgType(IG_TYPE.CASCADED.name());
} else {
policy.setIgType(IG_TYPE.SIMPLE.name());
}
CIMInstance storageGroupInstance = checkExists(storage, storageGroupPath, false, false);
String hostIOLimitBandwidth = CIMPropertyFactory.getPropertyValue(storageGroupInstance, EMC_MAX_BANDWIDTH);
String hostIOLimitIOPs = CIMPropertyFactory.getPropertyValue(storageGroupInstance, EMC_MAX_IO);
policy.tierPolicies = findTierPoliciesForStorageGroup(storage, storageGroupName);
policy.sgName = storageGroupName;
policy.setHostIOLimitBandwidth(StringUtils.isEmpty(hostIOLimitBandwidth) ? null : Integer.parseInt(hostIOLimitBandwidth));
policy.setHostIOLimitIOPs(StringUtils.isEmpty(hostIOLimitIOPs) ? null : Integer.parseInt(hostIOLimitIOPs));
boolean childSG = !this.isCascadedSG(storage, storageGroupPath);
// It is expected there would be only one fast policy, grab the first or set null
policy.localTierPolicy = null;
if (childSG && policy.tierPolicies != null && !policy.tierPolicies.isEmpty()) {
for (String tier : policy.tierPolicies) {
policy.localTierPolicy = tier;
}
}
Set<String> storageGroupNames = null;
// If this is a non-cascaded, non-fast policy, check for additional phantom storage groups
if (childSG && policy.tierPolicies.isEmpty()) {
storageGroupNames = this.getPhantomStorageGroupsForGivenMaskingView(exportMask.getMaskName(), storage);
StringSet policyNames = new StringSet();
for (String sgName : storageGroupNames) {
policyNames.addAll(findTierPoliciesForStorageGroup(storage, sgName));
}
policy.tierPolicies.addAll(policyNames);
}
// If this is non-cascaded, and we found no phantoms either, it's a simple mask.
if (childSG && (storageGroupNames == null || storageGroupNames.isEmpty())) {
policy.simpleMask = true;
}
// if Non-cascaded SG and Phantom SGs found, then its Phantom Type
if (childSG && (storageGroupNames != null && !storageGroupNames.isEmpty())) {
policy.setExportType(ExportMaskPolicy.EXPORT_TYPE.PHANTOM.name());
}
} catch (Exception e) {
String msg = "Error when attempting to query LUN masking information: " + e.getMessage();
_log.error(MessageFormat.format("Encountered an SMIS error when attempting to query existing exports policy: {0}", msg), e);
throw SmisException.exceptions.queryExistingMasksFailure(msg, e);
} finally {
closeCIMIterator(cimInstanceItr);
}
return policy;
}
use of com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy in project coprhd-controller by CoprHD.
the class ExportMaskUtils method sortMasksByEligibility.
/**
* Sorts export masks by eligibility.
* For instance, less utilized export masks will be listed before more utilized ones.
*
* @param maskSet list of export masks
* @return list of sorted export masks
*/
public static List<ExportMask> sortMasksByEligibility(Map<ExportMask, ExportMaskPolicy> maskMap, ExportGroup exportGroup) {
List<ExportMaskComparatorContainer> exportMaskContainerList = new ArrayList<ExportMaskComparatorContainer>();
for (Map.Entry<ExportMask, ExportMaskPolicy> entry : maskMap.entrySet()) {
exportMaskContainerList.add(new ExportMaskComparatorContainer(entry.getKey(), entry.getValue(), exportGroup));
}
Collections.sort(exportMaskContainerList, new ExportMaskComparator());
List<ExportMask> sortedMasks = new ArrayList<ExportMask>();
for (ExportMaskComparatorContainer container : exportMaskContainerList) {
ExportMaskPolicy policy = container.policy;
ExportMask mask = container.mask;
_log.info(String.format("Sorted ExportMasks by eligibility: %s { isSimple:%s, igType:%s, xpType:%s, localAutoTier:%s, autoTiers:%s }", mask.getMaskName(), policy.isSimpleMask(), policy.getIgType(), policy.getExportType(), policy.localTierPolicy, CommonTransformerFunctions.collectionToString(policy.getTierPolicies())));
sortedMasks.add(container.mask);
}
return sortedMasks;
}
use of com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy in project coprhd-controller by CoprHD.
the class ExportMaskUtilsTest method testExportMaskUtils.
@Test
public void testExportMaskUtils() {
// TODO add code to make this work
ExportGroup egp = new ExportGroup();
ExportMask e1 = new ExportMask();
e1.setLabel("e1");
ExportMask e2 = new ExportMask();
e2.setLabel("e2");
ExportMask e3 = new ExportMask();
e3.setLabel("e3");
ExportMask e4 = new ExportMask();
e4.setLabel("e4");
ExportMask e5 = new ExportMask();
e5.setLabel("e5");
StringMap e1vols = new StringMap();
e1vols.put("k1", "v1");
e1vols.put("k2", "v2");
e1vols.put("k3", "v3");
e1.setExistingVolumes(e1vols);
StringMap e2vols = new StringMap();
e2vols.put("k1", "v1");
e2.setExistingVolumes(e2vols);
StringMap e3vols = new StringMap();
e3vols.put("k1", "v1");
e3vols.put("k2", "v2");
e3.setExistingVolumes(e3vols);
StringMap e4vols = new StringMap();
e4.setExistingVolumes(e4vols);
StringMap e5vols = new StringMap();
e5vols.put("k1", "v1");
e5vols.put("k2", "v2");
e5vols.put("k3", "v3");
e5vols.put("k4", "v1");
e5vols.put("k5", "v2");
e5vols.put("k6", "v3");
e5.setExistingVolumes(e5vols);
List<ExportMask> sortedMasks = new ArrayList<ExportMask>();
sortedMasks.add(e1);
sortedMasks.add(e2);
sortedMasks.add(e3);
sortedMasks.add(e4);
sortedMasks.add(e5);
ExportMaskPolicy policy1 = new ExportMaskPolicy();
Map<ExportMask, ExportMaskPolicy> maskPolicyMap = new HashMap<ExportMask, ExportMaskPolicy>();
maskPolicyMap.put(e1, policy1);
maskPolicyMap.put(e2, policy1);
maskPolicyMap.put(e3, policy1);
maskPolicyMap.put(e4, policy1);
maskPolicyMap.put(e5, policy1);
sortedMasks = ExportMaskUtils.sortMasksByEligibility(maskPolicyMap, egp);
Assert.assertEquals(sortedMasks.get(0).getLabel(), "e4");
Assert.assertEquals(sortedMasks.get(1).getLabel(), "e2");
Assert.assertEquals(sortedMasks.get(2).getLabel(), "e3");
Assert.assertEquals(sortedMasks.get(3).getLabel(), "e1");
Assert.assertEquals(sortedMasks.get(4).getLabel(), "e5");
}
use of com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy in project coprhd-controller by CoprHD.
the class ExportMaskUtilsTest method testExportMaskUtilsCSG.
@Test
public void testExportMaskUtilsCSG() {
// TODO add code to make this work
ExportGroup egp = new ExportGroup();
ExportMask e1 = new ExportMask();
e1.setLabel("e1");
ExportMask e2 = new ExportMask();
e2.setLabel("e2");
ExportMask e3 = new ExportMask();
e3.setLabel("e3");
ExportMask e4 = new ExportMask();
e4.setLabel("e4");
ExportMask e5 = new ExportMask();
e5.setLabel("e5");
StringMap e1vols = new StringMap();
e1vols.put("k1", "v1");
e1vols.put("k2", "v2");
e1vols.put("k3", "v3");
e1.setExistingVolumes(e1vols);
StringMap e2vols = new StringMap();
e2vols.put("k1", "v1");
e2.setExistingVolumes(e2vols);
StringMap e3vols = new StringMap();
e3vols.put("k1", "v1");
e3vols.put("k2", "v2");
e3.setExistingVolumes(e3vols);
StringMap e4vols = new StringMap();
e4.setExistingVolumes(e4vols);
StringMap e5vols = new StringMap();
e5vols.put("k1", "v1");
e5vols.put("k2", "v2");
e5vols.put("k3", "v3");
e5vols.put("k4", "v1");
e5vols.put("k5", "v2");
e5vols.put("k6", "v3");
e5.setExistingVolumes(e5vols);
List<ExportMask> sortedMasks = new ArrayList<ExportMask>();
sortedMasks.add(e1);
sortedMasks.add(e2);
sortedMasks.add(e3);
sortedMasks.add(e4);
sortedMasks.add(e5);
ExportMaskPolicy policy1simple = new ExportMaskPolicy();
policy1simple.simpleMask = true;
ExportMaskPolicy policy2notsimple = new ExportMaskPolicy();
policy2notsimple.simpleMask = false;
Map<ExportMask, ExportMaskPolicy> maskPolicyMap = new HashMap<ExportMask, ExportMaskPolicy>();
maskPolicyMap.put(e1, policy1simple);
maskPolicyMap.put(e2, policy1simple);
maskPolicyMap.put(e3, policy2notsimple);
maskPolicyMap.put(e4, policy1simple);
maskPolicyMap.put(e5, policy2notsimple);
sortedMasks = ExportMaskUtils.sortMasksByEligibility(maskPolicyMap, egp);
Assert.assertEquals(sortedMasks.get(0).getLabel(), "e3");
Assert.assertEquals(sortedMasks.get(1).getLabel(), "e5");
Assert.assertEquals(sortedMasks.get(2).getLabel(), "e4");
Assert.assertEquals(sortedMasks.get(3).getLabel(), "e2");
Assert.assertEquals(sortedMasks.get(4).getLabel(), "e1");
}
use of com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy in project coprhd-controller by CoprHD.
the class ExportMaskUtilsTest method testExportMaskUtilsFAST.
@Test
public void testExportMaskUtilsFAST() {
// TODO add code to make this work
ExportGroup egp = new ExportGroup();
ExportMask e1 = new ExportMask();
e1.setLabel("e1");
e1.setMaskName("e1");
ExportMask e2 = new ExportMask();
e2.setLabel("e2-FAST1");
e2.setMaskName("e2-FAST1");
ExportMask e3 = new ExportMask();
e3.setLabel("e3");
e3.setMaskName("e3");
ExportMask e4 = new ExportMask();
e4.setLabel("e4-FAST1");
e4.setMaskName("e4-FAST1");
ExportMask e5 = new ExportMask();
e5.setLabel("e5");
e5.setMaskName("e5");
StringMap e1vols = new StringMap();
e1vols.put("k1", "v1");
e1vols.put("k2", "v2");
e1vols.put("k3", "v3");
e1.setExistingVolumes(e1vols);
StringMap e2vols = new StringMap();
e2vols.put("k1", "v1");
e2.setExistingVolumes(e2vols);
StringMap e3vols = new StringMap();
e3vols.put("k1", "v1");
e3vols.put("k2", "v2");
e3.setExistingVolumes(e3vols);
StringMap e4vols = new StringMap();
e4.setExistingVolumes(e4vols);
StringMap e5vols = new StringMap();
e5vols.put("k1", "v1");
e5vols.put("k2", "v2");
e5vols.put("k3", "v3");
e5vols.put("k4", "v1");
e5vols.put("k5", "v2");
e5vols.put("k6", "v3");
e5.setExistingVolumes(e5vols);
List<ExportMask> sortedMasks = new ArrayList<ExportMask>();
sortedMasks.add(e1);
sortedMasks.add(e2);
sortedMasks.add(e3);
sortedMasks.add(e4);
sortedMasks.add(e5);
ExportMaskPolicy policy1simple = new ExportMaskPolicy();
policy1simple.simpleMask = true;
policy1simple.setExportType(ExportMaskPolicy.EXPORT_TYPE.PHANTOM.name());
ExportMaskPolicy policy2notsimple = new ExportMaskPolicy();
policy2notsimple.simpleMask = false;
StringSet fastTiers = new StringSet();
fastTiers.add("FAST1");
ExportMaskPolicy policy3simpleFAST = new ExportMaskPolicy();
policy3simpleFAST.simpleMask = true;
policy3simpleFAST.setTierPolicies(fastTiers);
Map<ExportMask, ExportMaskPolicy> maskPolicyMap = new HashMap<ExportMask, ExportMaskPolicy>();
maskPolicyMap.put(e1, policy1simple);
maskPolicyMap.put(e2, policy3simpleFAST);
maskPolicyMap.put(e3, policy1simple);
maskPolicyMap.put(e4, policy3simpleFAST);
maskPolicyMap.put(e5, policy1simple);
sortedMasks = ExportMaskUtils.sortMasksByEligibility(maskPolicyMap, egp);
System.out.println(Joiner.on('\n').join(sortedMasks));
Assert.assertEquals(sortedMasks.get(0).getLabel(), "e4-FAST1");
Assert.assertEquals(sortedMasks.get(1).getLabel(), "e2-FAST1");
Assert.assertEquals(sortedMasks.get(2).getLabel(), "e3");
Assert.assertEquals(sortedMasks.get(3).getLabel(), "e1");
Assert.assertEquals(sortedMasks.get(4).getLabel(), "e5");
}
Aggregations