Search in sources :

Example 56 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class SmisCommandHelper method getVolumesFromLunMaskingInstance.

/**
 * Will return a map of the volume WWNs to their HLU values for an instance of LunMasking
 * container on the array.
 *
 * @param client
 *            [in] - WBEM client used to read data from SMI-S
 * @param instance
 *            [in] - Instance of CIM_LunMaskingSCSIProtocolController, holding a representation
 *            of an array masking container.
 * @return - Will return a map of the volume WWNs to their HLU values for an instance of
 *         LunMasking container on the array.
 * @throws WBEMException
 */
public Map<String, Integer> getVolumesFromLunMaskingInstance(WBEMClient client, CIMInstance instance) throws WBEMException {
    Map<String, Integer> wwnToHLU = new HashMap<String, Integer>();
    CloseableIterator<CIMInstance> iterator = null;
    CloseableIterator<CIMInstance> protocolControllerForUnitIter = null;
    try {
        int retry = 0;
        boolean failures = true;
        Map<String, Integer> deviceIdToHLU = new HashMap<String, Integer>();
        while (failures) {
            failures = false;
            deviceIdToHLU.clear();
            protocolControllerForUnitIter = client.referenceInstances(instance.getObjectPath(), CIM_PROTOCOL_CONTROLLER_FOR_UNIT, null, false, PS_DEVICE_NUMBER);
            while (protocolControllerForUnitIter.hasNext()) {
                CIMInstance pcu = protocolControllerForUnitIter.next();
                CIMObjectPath pcuPath = pcu.getObjectPath();
                CIMProperty<CIMObjectPath> dependentVolumePropery = (CIMProperty<CIMObjectPath>) pcuPath.getKey(CP_DEPENDENT);
                CIMObjectPath dependentVolumePath = dependentVolumePropery.getValue();
                String deviceId = dependentVolumePath.getKey(CP_DEVICE_ID).getValue().toString();
                String deviceNumber = CIMPropertyFactory.getPropertyValue(pcu, CP_DEVICE_NUMBER);
                try {
                    Integer decimalHLU = (int) Long.parseLong(deviceNumber, 16);
                    deviceIdToHLU.put(deviceId, decimalHLU);
                } catch (NumberFormatException nfe) {
                    // We've found in testing when users remove volumes from masks, the volume will still be in the
                    // provider, but the HLU will get returned as an empty string, causing the overall operation to
                    // fail. This retry loop will ensure that we wait until the provider is returning only volumes
                    // with valid HLUs, thus removing any volumes from the mask that are in-flight outside of the
                    // controller.
                    _log.error(String.format("deviceId: %s returned an invalid HLU.  It may be currently getting removed from the mask.", deviceId));
                    failures = true;
                    if (retry++ > GET_VOLUMES_BAD_HLU_RETRIES) {
                        // rethrow
                        throw nfe;
                    }
                    try {
                        _log.warn("Retrying query operation for volumes and HLU after 10 seconds");
                        Thread.sleep(GET_VOLUMES_BAD_HLU_RETRY_SLEEP_MSEC);
                    } catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                    }
                }
            }
        }
        _log.debug(String.format("getVolumesFromLunMaskingInstance(%s) - deviceIdToHLU map = %s", instance.getObjectPath().toString(), Joiner.on(',').join(deviceIdToHLU.entrySet())));
        iterator = client.associatorInstances(instance.getObjectPath(), null, CIM_STORAGE_VOLUME, null, null, false, PS_EMCWWN);
        while (iterator.hasNext()) {
            CIMInstance cimInstance = iterator.next();
            String deviceId = cimInstance.getObjectPath().getKey(CP_DEVICE_ID).getValue().toString();
            String wwn = CIMPropertyFactory.getPropertyValue(cimInstance, CP_WWN_NAME);
            wwnToHLU.put(wwn.toUpperCase(), deviceIdToHLU.get(deviceId));
        }
        _log.debug(String.format("getVolumesFromLunMaskingInstance(%s) - wwnToHLU map = %s", instance.getObjectPath().toString(), Joiner.on(',').join(wwnToHLU.entrySet())));
    } catch (WBEMException we) {
        _log.error("Caught an error will attempting to get volume list from " + "masking instance", we);
        throw we;
    } finally {
        closeCIMIterator(iterator);
        closeCIMIterator(protocolControllerForUnitIter);
    }
    return wwnToHLU;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) CIMProperty(javax.cim.CIMProperty)

Example 57 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class SmisCommandHelper method getReplicationSettingDataInstanceForDesiredCopyMethod.

/*
     * Get ReplicationSettingData instance.
     * 
     * @param storageSystem A reference to the storage system
     * 
     * @param elementName An optional name for the instance
     * 
     * @param desiredValue DesiredCopyMethodology value
     * 
     * @param steTargetSupplier Whether or not the TargetElementSupplier should also be specified.
     */
@SuppressWarnings("rawtypes")
public CIMInstance getReplicationSettingDataInstanceForDesiredCopyMethod(final StorageSystem storageSystem, String elementName, int desiredValue, Boolean setTargetSupplier) {
    CIMInstance modifiedInstance = null;
    // only for vmax, otherwise, return null
    if (!storageSystem.deviceIsType(Type.vmax)) {
        return modifiedInstance;
    }
    try {
        CIMObjectPath replicationSettingCapabilities = _cimPath.getReplicationServiceCapabilitiesPath(storageSystem);
        CIMArgument[] inArgs = getReplicationSettingDataInstance();
        CIMArgument[] outArgs = new CIMArgument[5];
        invokeMethod(storageSystem, replicationSettingCapabilities, GET_DEFAULT_REPLICATION_SETTING_DATA, inArgs, outArgs);
        for (CIMArgument<?> outArg : outArgs) {
            if (null == outArg) {
                continue;
            }
            ArrayList<CIMProperty> list = new ArrayList<>();
            if (outArg.getName().equalsIgnoreCase(SmisConstants.DEFAULT_INSTANCE)) {
                CIMInstance repInstance = (CIMInstance) outArg.getValue();
                if (null != repInstance) {
                    CIMProperty<?> desiredMethod = new CIMProperty<Object>(SmisConstants.DESIRED_COPY_METHODOLOGY, UINT16_T, new UnsignedInteger16(desiredValue));
                    list.add(desiredMethod);
                    if (setTargetSupplier) {
                        CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(CREATE_NEW_TARGET_VALUE));
                        list.add(targetElementSupplier);
                    }
                    /**
                     * To create SNAPVX snapshot smis uses the ElementName attribute in replicationSettingsInstance.
                     * By default Element Name of replicationSettingsInstance is "Default ReplicationSettingData".
                     * Element Name should not be having white space as it accept only alphanumeric value.
                     * To avoid SNAPVX creation failure i just removed white space as a workaround.
                     */
                    if (null == elementName) {
                        elementName = SmisConstants.DEFAULT_REPLICATION_SETTING_DATA_ELEMENT_NAME;
                    }
                    CIMProperty<?> elementNameProp = new CIMProperty<Object>(SmisConstants.CP_ELEMENT_NAME, STRING_T, elementName);
                    list.add(elementNameProp);
                    modifiedInstance = repInstance.deriveInstance(list.toArray(new CIMProperty[] {}));
                    break;
                }
            }
        }
    } catch (Exception e) {
        _log.error("Error retrieving Replication Setting Data Instance ", e);
    }
    return modifiedInstance;
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) 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) CIMArgument(javax.cim.CIMArgument)

Example 58 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method getCreateVolumesInputArguments.

/**
 * Construct input arguments for creating volumes.
 */
public CIMArgument[] getCreateVolumesInputArguments(StorageSystem storageDevice, StoragePool pool, List<String> labels, Long capacity, int count, boolean isThinlyProvisioned) {
    ArrayList<CIMArgument> list = new ArrayList<CIMArgument>();
    try {
        list.add(_cimArgument.stringArray(CP_ELEMENT_NAMES, labels.toArray(new String[labels.size()])));
        // Use thick/thin volume type
        int volumeType = isThinlyProvisioned ? STORAGE_VOLUME_TYPE_THIN : STORAGE_VOLUME_VALUE;
        list.add(_cimArgument.uint16(CP_ELEMENT_TYPE, volumeType));
        CIMProperty[] goalPropKeys = { _cimProperty.string(CP_INSTANCE_ID, SYSTEM_BLOCK_SIZE) };
        CIMObjectPath goalPath = CimObjectPathCreator.createInstance(DATA_TYPE_SETTING, Constants.IBM_NAMESPACE, goalPropKeys);
        list.add(_cimArgument.reference(CP_GOAL, goalPath));
        CIMProperty[] inPoolPropKeys = { _cimProperty.string(CP_INSTANCE_ID, pool.getNativeId()) };
        CIMObjectPath inPoolPath = CimObjectPathCreator.createInstance(pool.getPoolClassName(), Constants.IBM_NAMESPACE, inPoolPropKeys);
        list.add(_cimArgument.reference(CP_IN_POOL, inPoolPath));
        list.add(_cimArgument.uint32(CP_QUANTITY, count));
        list.add(_cimArgument.uint64(CP_SIZE, capacity));
    } catch (Exception e) {
        throw new IllegalStateException("Problem getting input arguments: " + storageDevice.getLabel());
    }
    return list.toArray(new CIMArgument[list.size()]);
}
Also used : CIMProperty(javax.cim.CIMProperty) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) CIMArgument(javax.cim.CIMArgument)

Example 59 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method getVolumesFromScsiProtocolController.

/**
 * Returns a map of the volume WWNs to their HLU values for a masking
 * container on the array.
 *
 * @param storage
 *            [in] - StorageSystem that the masking belongs to
 * @param controllerPath
 *            [in] - CIMObjectPath of IBMTSDS_SCSIProtocolController, holding a representation
 *            of an array masking container.
 * @return - a map of the volume WWNs to their HLU values for an instance of
 *         LunMasking container on the array.
 */
public Map<String, Integer> getVolumesFromScsiProtocolController(StorageSystem storage, CIMObjectPath controllerPath) {
    Map<String, Integer> wwnToHLU = new HashMap<String, Integer>();
    CloseableIterator<CIMInstance> iterator = null;
    CloseableIterator<CIMInstance> protocolControllerForUnitIter = null;
    try {
        Map<String, Integer> deviceIdToHLU = new HashMap<String, Integer>();
        WBEMClient client = getConnection(storage).getCimClient();
        protocolControllerForUnitIter = client.referenceInstances(controllerPath, CIM_PROTOCOL_CONTROLLER_FOR_UNIT, null, false, PS_DEVICE_NUMBER);
        while (protocolControllerForUnitIter.hasNext()) {
            CIMInstance pcu = protocolControllerForUnitIter.next();
            CIMObjectPath pcuPath = pcu.getObjectPath();
            CIMProperty<CIMObjectPath> dependentVolumePropery = (CIMProperty<CIMObjectPath>) pcuPath.getKey(CP_DEPENDENT);
            CIMObjectPath dependentVolumePath = dependentVolumePropery.getValue();
            String deviceId = dependentVolumePath.getKey(CP_DEVICE_ID).getValue().toString();
            String deviceNumber = CIMPropertyFactory.getPropertyValue(pcu, CP_DEVICE_NUMBER);
            Integer decimalHLU = (int) Long.parseLong(deviceNumber, 16);
            deviceIdToHLU.put(deviceId, decimalHLU);
        }
        iterator = client.associatorInstances(controllerPath, null, CP_STORAGE_VOLUME, null, null, false, PS_NAME);
        while (iterator.hasNext()) {
            CIMInstance cimInstance = iterator.next();
            String deviceId = cimInstance.getObjectPath().getKey(CP_DEVICE_ID).getValue().toString();
            String wwn = CIMPropertyFactory.getPropertyValue(cimInstance, CP_NAME);
            wwnToHLU.put(wwn.toUpperCase(), deviceIdToHLU.get(deviceId));
        }
    } catch (WBEMException we) {
        _log.error("Caught an error will attempting to get volume list from " + "masking instance", we);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
        if (protocolControllerForUnitIter != null) {
            protocolControllerForUnitIter.close();
        }
    }
    return wwnToHLU;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 60 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevicePostProcessor method getAllocatedCapacityInformation.

/*
     * (non-Javadoc) Get allocated capacity.
     * 
     * @see SmisReplicaCreationJobs#getAllocatedCapacityInformation
     */
protected long getAllocatedCapacityInformation(WBEMClient client, CIMInstance volumeInstance) {
    Long allocatedCapacity = 0L;
    CloseableIterator<CIMInstance> iterator = null;
    // TODO - use VirtualSpaceConsumed from SEVolume
    try {
        if (volumeInstance != null) {
            iterator = client.referenceInstances(volumeInstance.getObjectPath(), IBMSmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL, null, false, IBMSmisConstants.PS_SPACE_CONSUMED);
            if (iterator.hasNext()) {
                CIMInstance allocatedFromStoragePoolPath = iterator.next();
                CIMProperty spaceConsumed = allocatedFromStoragePoolPath.getProperty(IBMSmisConstants.CP_SPACE_CONSUMED);
                allocatedCapacity = Long.valueOf(spaceConsumed.getValue().toString());
            }
        }
    } catch (Exception e) {
        _log.error("Updating Allocated Capacity failed for Volume {}", volumeInstance.getObjectPath(), e);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
    }
    return allocatedCapacity;
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException)

Aggregations

CIMProperty (javax.cim.CIMProperty)74 CIMObjectPath (javax.cim.CIMObjectPath)57 CIMInstance (javax.cim.CIMInstance)37 ArrayList (java.util.ArrayList)26 WBEMException (javax.wbem.WBEMException)25 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)18 CIMArgument (javax.cim.CIMArgument)16 WBEMClient (javax.wbem.client.WBEMClient)14 IOException (java.io.IOException)11 Volume (com.emc.storageos.db.client.model.Volume)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10 URI (java.net.URI)9 ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)8 UnsignedInteger16 (javax.cim.UnsignedInteger16)8 DbClient (com.emc.storageos.db.client.DbClient)7 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 HashMap (java.util.HashMap)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)5 Initiator (com.emc.storageos.db.client.model.Initiator)5