Search in sources :

Example 26 with CIMProperty

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

the class CIMPropertyFactory method getPropertyValue.

public static String getPropertyValue(CIMInstance instance, String propertyName) {
    _log.debug("instance :{}", instance);
    _log.debug("propertyName :{}", propertyName);
    String propertyValue = SmisConstants.EMPTY_STRING;
    if (instance != null && propertyName != null) {
        CIMProperty property = instance.getProperty(propertyName);
        if (property != null) {
            Object value = property.getValue();
            if (value != null && value.toString() != null) {
                propertyValue = value.toString();
            } else {
                _log.warn(String.format("CIMInstance %s does not have a '%s' property or the property value is null", instance.toString(), propertyName));
            }
        }
    }
    return propertyValue;
}
Also used : CIMProperty(javax.cim.CIMProperty)

Example 27 with CIMProperty

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

the class ExportMaskOperationsHelper method setHLUFromProtocolControllers.

/**
 * During an export group operation e.g. creating one with initiators and volumes or when
 * adding volume(s) to an existing export group the user has the option of supplying HLUs
 * (Host Lun Unit) for the corresponding volumes. If the user does not supply HLUs, the
 * underlying array generates them. This helper function displays those array generated
 * HLUs during a GET/volume/exports operation. If the user has supplied the HLUs, this
 * function does nothing.
 *
 * @throws DeviceControllerException
 */
public static void setHLUFromProtocolControllers(DbClient dbClient, CimConnection cimConnection, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, Collection<CIMObjectPath> protocolControllers, TaskCompleter taskCompleter) throws DeviceControllerException {
    long startTime = System.currentTimeMillis();
    boolean hasNullHLU = volumeURIHLUsHasNullHLU(volumeURIHLUs);
    if (!hasNullHLU || protocolControllers.isEmpty()) {
        return;
    }
    try {
        ExportMask mask = dbClient.queryObject(ExportMask.class, exportMaskURI);
        Map<String, URI> deviceIdToURI = new HashMap<String, URI>();
        for (VolumeURIHLU vuh : volumeURIHLUs) {
            BlockObject volume = BlockObject.fetch(dbClient, vuh.getVolumeURI());
            // with the ExportMask that do not yet have an HLU set
            if (!mask.checkIfVolumeHLUSet(vuh.getVolumeURI())) {
                deviceIdToURI.put(volume.getNativeId(), volume.getId());
            }
        }
        boolean requiresUpdate = false;
        CloseableIterator<CIMInstance> protocolControllerForUnitIter;
        for (CIMObjectPath protocolController : protocolControllers) {
            _log.info(String.format("setHLUFromProtocolControllers -- protocolController=%s", protocolController.toString()));
            protocolControllerForUnitIter = null;
            try {
                protocolControllerForUnitIter = cimConnection.getCimClient().referenceInstances(protocolController, 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();
                    URI volumeURI = deviceIdToURI.get(deviceId);
                    if (volumeURI != null) {
                        String deviceNumber = CIMPropertyFactory.getPropertyValue(pcu, CP_DEVICE_NUMBER);
                        _log.info(String.format("setHLUFromProtocolControllers -- volumeURI=%s --> %s", volumeURI.toString(), deviceNumber));
                        mask.addVolume(volumeURI, (int) Long.parseLong(deviceNumber, 16));
                        requiresUpdate = true;
                    }
                }
            } finally {
                if (protocolControllerForUnitIter != null) {
                    protocolControllerForUnitIter.close();
                }
            }
        }
        if (requiresUpdate) {
            dbClient.persistObject(mask);
        }
    } catch (Exception e) {
        _log.error("Unexpected error: setHLUFromProtocolControllers failed.", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("setHLUFromProtocolControllers", e.getMessage());
        taskCompleter.error(dbClient, error);
    } finally {
        long totalTime = System.currentTimeMillis() - startTime;
        _log.info(String.format("setHLUFromProtocolControllers took %f seconds", (double) totalTime / (double) 1000));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMProperty(javax.cim.CIMProperty) BlockObject(com.emc.storageos.db.client.model.BlockObject) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 28 with CIMProperty

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

the class SRDFOperations method getReplicationSettingDataInstance.

/**
 * Gets the replication setting data instance.
 *
 * @param sourceSystem the source system
 * @param modeValue the mode value
 * @param nonEmptyRDFGroup indicates whether to pass CONSISTENCY_EXEMPT flag or not
 *            CONSISTENCY_EXEMPT does not need to be set if the RDF group is empty
 *            CONSISTENCY_EXEMPT should only be specified if the devices in the RDF group are in ASYNC mode
 * @param formatVolumeFlagNeeded
 * @return the replication setting data instance
 */
private CIMInstance getReplicationSettingDataInstance(final StorageSystem sourceSystem, int modeValue, boolean nonEmptyRDFGroup, boolean formatVolumeFlagNeeded) throws Exception {
    CIMInstance modifiedInstance = null;
    CIMObjectPath replicationSettingCapabilities = cimPath.getReplicationServiceCapabilitiesPath(sourceSystem);
    int replicationType = Mode.ASYNCHRONOUS.getMode() == modeValue ? ASYNC_MIRROR_REMOTE_REPLICATION_TYPE : SYNC_MIRROR_REMOTE_REPLICATION_TYPE;
    CIMArgument[] inArgs = helper.getReplicationSettingDataInstance(replicationType);
    CIMArgument[] outArgs = new CIMArgument[5];
    helper.invokeMethod(sourceSystem, replicationSettingCapabilities, "GetDefaultReplicationSettingData", inArgs, outArgs);
    for (CIMArgument<?> outArg : outArgs) {
        if (null == outArg) {
            continue;
        }
        if (outArg.getName().equalsIgnoreCase(DEFAULT_INSTANCE)) {
            CIMInstance repInstance = (CIMInstance) outArg.getValue();
            if (null != repInstance) {
                List<CIMProperty<?>> propList = new ArrayList<CIMProperty<?>>();
                if (Mode.ASYNCHRONOUS.getMode() == modeValue && nonEmptyRDFGroup) {
                    CIMProperty<?> existingProp = repInstance.getProperty(EMC_CONSISTENCY_EXEMPT);
                    CIMProperty<?> prop = null;
                    if (existingProp == null) {
                        // ConsistencyExempt property is now part of the smi-s standard. Available in providers 8.0+ (VMAX3 arrays)
                        // EMCConsistencyExempt property in ReplicationSettingData is removed
                        existingProp = repInstance.getProperty(CONSISTENCY_EXEMPT);
                        prop = new CIMProperty<Object>(CONSISTENCY_EXEMPT, existingProp.getDataType(), true);
                    } else {
                        prop = new CIMProperty<Object>(EMC_CONSISTENCY_EXEMPT, existingProp.getDataType(), true);
                    }
                    propList.add(prop);
                }
                // Use force flag only if the RDF Group is not empty AND if the source volume doesn't have any data on it.
                // Through ViPR only if its change virtual pool operation, the source volume will have data, hence
                // formatVolumeFlagNeeded flag will be set to false only during ChangeVirtualPool
                log.info("NonEmptyRDFGroup : {}, formatFlagNeeded {} ", nonEmptyRDFGroup, formatVolumeFlagNeeded);
                if (nonEmptyRDFGroup && Mode.ACTIVE.getMode() == modeValue && formatVolumeFlagNeeded) {
                    log.info("Adding format flag to replication Group Instance...");
                    // NOTE: Format flag will wipe out the data.
                    // he FORMAT property is not available as part of the default Replication Instance.
                    // We will be on our own adding this property..
                    CIMProperty<?> formatData = new CIMProperty<Object>(FORMAT, BOOLEAN_T, true);
                    List<CIMProperty<?>> dupPropList = new ArrayList<CIMProperty<?>>();
                    dupPropList.addAll(Arrays.asList(repInstance.getProperties()));
                    dupPropList.add(formatData);
                    CIMInstance duplicateRepInstance = new CIMInstance(repInstance.getObjectPath(), dupPropList.toArray(new CIMProperty<?>[] {}));
                    // Re-assigning
                    repInstance = duplicateRepInstance;
                }
                // Set target supplier to Implementation Decides so that the supplied targets can be used
                CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(IMPLEMENTATION_DECIDES));
                propList.add(targetElementSupplier);
                modifiedInstance = repInstance.deriveInstance(propList.toArray(new CIMProperty<?>[] {}));
                break;
            }
        }
    }
    return modifiedInstance;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) UnsignedInteger16(javax.cim.UnsignedInteger16) CIMProperty(javax.cim.CIMProperty) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 29 with CIMProperty

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

the class SmisCommandHelper method addTargetPoolToArgs.

private void addTargetPoolToArgs(StorageSystem storageSystem, StoragePool pool, List<CIMArgument> args) {
    CIMProperty[] inPoolPropKeys = { _cimProperty.string(CP_INSTANCE_ID, _cimPath.getPoolName(storageSystem, pool.getNativeId())) };
    CIMObjectPath inPoolPath = CimObjectPathCreator.createInstance(pool.getPoolClassName(), _cimConnection.getNamespace(storageSystem), inPoolPropKeys);
    args.add(_cimArgument.reference(CP_TARGET_POOL, inPoolPath));
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath)

Example 30 with CIMProperty

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

the class SmisCommandHelper method setProtocolControllerNativeId.

public void setProtocolControllerNativeId(URI exportMaskURI, CIMObjectPath protocolController) throws Exception {
    ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
    if (protocolController != null) {
        CIMProperty<String> storageGroupID = (CIMProperty<String>) protocolController.getKey(CP_DEVICE_ID);
        exportMask.setNativeId(storageGroupID.getValue());
    } else {
        exportMask.setNativeId(null);
    }
    _dbClient.persistObject(exportMask);
}
Also used : CIMProperty(javax.cim.CIMProperty) ExportMask(com.emc.storageos.db.client.model.ExportMask)

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