Search in sources :

Example 1 with ExportMaskPolicy

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;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) StringSet(com.emc.storageos.db.client.model.StringSet) ExportMaskPolicy(com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy) CIMInstance(javax.cim.CIMInstance) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)

Example 2 with ExportMaskPolicy

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;
}
Also used : UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ExportMaskPolicy(com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap)

Example 3 with ExportMaskPolicy

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");
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ExportMaskPolicy(com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy) Test(org.junit.Test)

Example 4 with ExportMaskPolicy

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");
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ExportMaskPolicy(com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy) Test(org.junit.Test)

Example 5 with ExportMaskPolicy

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");
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) ExportMaskPolicy(com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy) Test(org.junit.Test)

Aggregations

ExportMaskPolicy (com.emc.storageos.volumecontroller.impl.block.ExportMaskPolicy)5 ExportMask (com.emc.storageos.db.client.model.ExportMask)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)3 StringMap (com.emc.storageos.db.client.model.StringMap)3 Test (org.junit.Test)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)1 ZoneInfoMap (com.emc.storageos.db.client.model.ZoneInfoMap)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)1 IOException (java.io.IOException)1 Map (java.util.Map)1 CIMInstance (javax.cim.CIMInstance)1 CIMObjectPath (javax.cim.CIMObjectPath)1 WBEMException (javax.wbem.WBEMException)1