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;
}
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));
}
}
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;
}
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));
}
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);
}
Aggregations