use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class CIMObjectPathCreatorFactory method getVolumePaths.
@Override
public CIMObjectPath[] getVolumePaths(StorageSystem storageDevice, String[] volumeNames) throws Exception {
ArrayList<CIMObjectPath> theElementsList = new ArrayList<CIMObjectPath>();
for (String volumeName : volumeNames) {
CIMProperty[] volumeKeys = { cimPropertyFactory.string(CP_CREATION_CLASS_NAME, prefixWithParamName(STORAGE_VOLUME)), cimPropertyFactory.string(CP_DEVICE_ID, volumeName), cimPropertyFactory.string(CP_SYSTEM_CREATION_CLASS_NAME, prefixWithParamName(STORAGE_SYSTEM)), cimPropertyFactory.string(CP_SYSTEM_NAME, getSystemName(storageDevice)) };
CIMObjectPath volumePath = CimObjectPathCreator.createInstance(prefixWithParamName(STORAGE_VOLUME), cimConnectionFactory.getNamespace(storageDevice), volumeKeys);
theElementsList.add(volumePath);
}
CIMObjectPath[] volArray = {};
volArray = theElementsList.toArray(volArray);
return volArray;
}
use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class ExportProcessor method processResult.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.plugins.common.Processor#processResult(com.emc.storageos.plugins.common.domainmodel.Operation,
* java.lang.Object, java.util.Map)
*/
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
initialize(operation, resultObj, keyMap);
CloseableIterator<CIMInstance> it = null;
EnumerateResponse<CIMInstance> response = null;
List<Initiator> matchedInitiators = new ArrayList<Initiator>();
List<StoragePort> matchedPorts = new ArrayList<StoragePort>();
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
StringSet knownIniSet = new StringSet();
StringSet knownNetworkIdSet = new StringSet();
StringSet knownPortSet = new StringSet();
StringSet knownVolumeSet = new StringSet();
try {
// set lun masking view CIM path
CIMObjectPath path = this.getObjectPathfromCIMArgument(_args, keyMap);
UnManagedExportMask mask = this.getUnManagedExportMask(path);
mask.setMaskingViewPath(path.toString());
_logger.info("looking at lun masking view: " + path.toString());
CIMInstance lunMaskingView = client.getInstance(path, false, false, null);
if (lunMaskingView != null) {
String maskName = CIMPropertyFactory.getPropertyValue(lunMaskingView, SmisConstants.CP_NAME);
if (maskName != null) {
mask.setMaskName(maskName);
}
_logger.info("set UnManagedExportMask maskName to " + mask.getMaskName());
} else {
_logger.info("lunMaskingView was null");
}
CIMProperty<String> deviceIdProperty = (CIMProperty<String>) path.getKey(SmisConstants.CP_DEVICE_ID);
if (deviceIdProperty != null) {
mask.setNativeId(deviceIdProperty.getValue());
}
_logger.info("set UnManagedExportMask nativeId to " + mask.getNativeId());
// set storage system id
URI systemId = (URI) keyMap.get(Constants.SYSTEMID);
mask.setStorageSystemUri(systemId);
response = (EnumerateResponse<CIMInstance>) resultObj;
processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
while (!response.isEnd()) {
_logger.info("Processing next Chunk");
response = client.getInstancesWithPath(Constants.MASKING_PATH, response.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
}
// CTRL - 8918 - always update the mask with new initiators and volumes.
mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, knownPortSet);
// get zones and store them?
updateZoningMap(mask, matchedInitiators, matchedPorts);
updateVplexBackendVolumes(mask, matchedInitiators);
updateRecoverPointVolumes(mask, matchedInitiators);
} catch (Exception e) {
_logger.error("something failed", e);
} finally {
if (it != null) {
it.close();
}
wrapUp();
if (response != null) {
try {
client.closeEnumeration(Constants.MASKING_PATH, response.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class BlockStatisticsCapabilitiesProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
final Iterator<?> it = (Iterator<?>) resultObj;
// Only 1 entry per each Array always
while (it.hasNext()) {
final CIMInstance queryInstance = (CIMInstance) it.next();
CIMProperty prop = queryInstance.getProperty(Constants.CLOCK_TICK_INTERVAL);
keyMap.put(Constants.CLOCK_TICK_INTERVAL, prop.getValue().toString());
}
} catch (Exception e) {
_logger.error("Failed while processing QueryStatistics :", e);
}
resultObj = null;
}
use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class VnxExportOperations method modifyClarPrivileges.
/**
* Method invokes the SMI-S operation to modify the initiator parameters such as type and failovermode.
*
* @param storage
* [in] - StorageSystem representing the array
* @param initiators
* [in] - An array Initiator objects, whose representation will
* be removed from the array.
* @throws Exception
*/
@SuppressWarnings("rawtypes")
public void modifyClarPrivileges(StorageSystem storage, List<Initiator> initiators) throws Exception {
if (initiators == null || initiators.isEmpty()) {
_log.debug("No initiators ...");
return;
}
_log.info("Start -- modifyClarPrivileges");
List<String> initiatorStrings = new ArrayList<String>();
final String RP_INITIATOR_PREFIX = "500124";
final int RP_INITIATOR_TYPE = 31;
final int RP_INITIATOR_FAILOVERMODE = 4;
final CIMProperty[] RP_CLAR_PRIVILIEGE_CIM_PROPERTY = new CIMProperty[] { new CIMProperty<UnsignedInteger16>(SmisConstants.CP_EMC_INITIATOR_TYPE, CIMDataType.UINT16_T, new UnsignedInteger16(RP_INITIATOR_TYPE)), new CIMProperty<UnsignedInteger16>(SmisConstants.CP_EMC_FAILOVER_MODE, CIMDataType.UINT16_T, new UnsignedInteger16(RP_INITIATOR_FAILOVERMODE)) };
CloseableIterator<CIMInstance> privilegeInstances = null;
for (Initiator initiator : initiators) {
if (initiator.getProtocol().equalsIgnoreCase(Initiator.Protocol.FC.name())) {
initiatorStrings.add(WwnUtils.convertWWN(initiator.getInitiatorNode(), FORMAT.NOMARKERS).toString().concat(WwnUtils.convertWWN(initiator.getInitiatorPort(), FORMAT.NOMARKERS).toString()));
}
}
if (initiatorStrings.isEmpty()) {
_log.info("There are no initiators in the list whose privileges need to be changed.");
return;
}
try {
privilegeInstances = _helper.getClarPrivileges(storage);
while (privilegeInstances.hasNext()) {
CIMInstance existingInstance = privilegeInstances.next();
String initiatorType = CIMPropertyFactory.getPropertyValue(existingInstance, SmisConstants.CP_EMC_INITIATOR_TYPE);
// We are only interested in the RP initiators, so check if the initiators are RP initiators
if (existingInstance.toString().contains(storage.getSerialNumber()) && existingInstance.toString().contains(RP_INITIATOR_PREFIX)) {
for (String initiatorString : initiatorStrings) {
if (existingInstance.toString().contains(initiatorString) && (initiatorType != null && Integer.parseInt(initiatorType) != RP_INITIATOR_TYPE)) {
CIMInstance toUpdate = new CIMInstance(existingInstance.getObjectPath(), RP_CLAR_PRIVILIEGE_CIM_PROPERTY);
_log.info("Modifying -- " + existingInstance.toString());
_helper.modifyInstance(storage, toUpdate, SmisConstants.PS_EMC_CLAR_PRIVILEGE);
break;
}
}
}
}
_log.info("end -- modifyClarPrivileges");
} catch (Exception e1) {
_log.error("Unexpected error: modifyClarPrivileges failed");
throw e1;
} finally {
if (null != privilegeInstances) {
privilegeInstances.close();
}
}
}
use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class VnxExportOperations method findExportMasks.
/**
* This call can be used to look up the passed in initiator/port names and find (if
* any) to which export masks they belong on the 'storage' array.
*
* @param storage
* [in] - StorageSystem object representing the array
* @param initiatorNames
* [in] - Port identifiers (WWPN or iSCSI name)
* @param mustHaveAllPorts
* [in] NOT APPLICABLE FOR VNX
* @return Map of port name to Set of ExportMask URIs
*/
@Override
public Map<String, Set<URI>> findExportMasks(StorageSystem storage, List<String> initiatorNames, boolean mustHaveAllPorts) throws DeviceControllerException {
long startTime = System.currentTimeMillis();
Map<String, Set<URI>> matchingMasks = new HashMap<String, Set<URI>>();
CloseableIterator<CIMInstance> lunMaskingIter = null;
try {
StringBuilder builder = new StringBuilder();
WBEMClient client = _helper.getConnection(storage).getCimClient();
lunMaskingIter = _helper.getClarLunMaskingProtocolControllers(storage);
while (lunMaskingIter.hasNext()) {
CIMInstance instance = lunMaskingIter.next();
String systemName = CIMPropertyFactory.getPropertyValue(instance, SmisConstants.CP_SYSTEM_NAME);
if (!systemName.contains(storage.getSerialNumber())) {
// SMISProvider pointed to by 'storage' system.
continue;
}
String name = CIMPropertyFactory.getPropertyValue(instance, SmisConstants.CP_ELEMENT_NAME);
CIMProperty<String> deviceIdProperty = (CIMProperty<String>) instance.getObjectPath().getKey(SmisConstants.CP_DEVICE_ID);
// Get volumes and initiators for the masking instance
Map<String, Integer> volumeWWNs = _helper.getVolumesFromLunMaskingInstance(client, instance);
List<String> initiatorPorts = _helper.getInitiatorsFromLunMaskingInstance(client, instance);
// Find out if the port is in this masking container
List<String> matchingInitiators = new ArrayList<String>();
for (String port : initiatorNames) {
String normalizedName = Initiator.normalizePort(port);
if (initiatorPorts.contains(normalizedName)) {
matchingInitiators.add(normalizedName);
}
}
builder.append(String.format("%nXM:%s I:{%s} V:{%s}%n", name, Joiner.on(',').join(initiatorPorts), Joiner.on(',').join(volumeWWNs.keySet())));
if (!matchingInitiators.isEmpty()) {
// Look up ExportMask by deviceId/name and storage URI
ExportMask exportMask = ExportMaskUtils.getExportMaskByName(_dbClient, storage.getId(), name);
boolean foundMaskInDb = (exportMask != null);
// then create a new one
if (!foundMaskInDb) {
exportMask = new ExportMask();
exportMask.setMaskName(name);
exportMask.setNativeId(deviceIdProperty.getValue());
exportMask.setStorageDevice(storage.getId());
exportMask.setId(URIUtil.createId(ExportMask.class));
exportMask.setCreatedBySystem(false);
// Grab the storage ports that have been allocated for this
// existing mask and add them.
List<String> storagePorts = _helper.getStoragePortsFromLunMaskingInstance(client, instance);
List<String> storagePortURIs = ExportUtils.storagePortNamesToURIs(_dbClient, storagePorts);
exportMask.setStoragePorts(storagePortURIs);
builder.append(String.format(" ----> SP { %s }\n" + " URI{ %s }\n", Joiner.on(',').join(storagePorts), Joiner.on(',').join(storagePortURIs)));
} else {
// refresh the export mask
refreshExportMask(storage, exportMask);
builder.append('\n');
}
// Update the tracking containers
exportMask.addToExistingVolumesIfAbsent(volumeWWNs);
exportMask.addToExistingInitiatorsIfAbsent(matchingInitiators);
// Update the initiator list to include existing initiators if we know about them.
for (String port : matchingInitiators) {
Initiator existingInitiator = ExportUtils.getInitiator(Initiator.toPortNetworkId(port), _dbClient);
if (existingInitiator != null) {
exportMask.addInitiator(existingInitiator);
exportMask.addToUserCreatedInitiators(existingInitiator);
exportMask.removeFromExistingInitiators(existingInitiator);
}
}
// so, add them to the initiator list and remove them from existing as well.
for (String port : initiatorPorts) {
Initiator existingInitiator = ExportUtils.getInitiator(Initiator.toPortNetworkId(port), _dbClient);
if (existingInitiator != null && !ExportMaskUtils.checkIfDifferentResource(exportMask, existingInitiator)) {
exportMask.addInitiator(existingInitiator);
exportMask.addToUserCreatedInitiators(existingInitiator);
exportMask.removeFromExistingInitiators(existingInitiator);
}
}
// Update the volume list to include existing volumes if know about them.
if (volumeWWNs != null) {
for (String wwn : volumeWWNs.keySet()) {
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeWwnConstraint(wwn.toUpperCase()), results);
if (results != null) {
Iterator<URI> resultsIter = results.iterator();
if (resultsIter.hasNext()) {
Volume volume = _dbClient.queryObject(Volume.class, resultsIter.next());
if (volume != null) {
Integer hlu = volumeWWNs.get(wwn);
if (hlu == null) {
_log.warn(String.format("The HLU for %s could not be found from the provider. Setting this to -1 (Unknown).", wwn));
hlu = -1;
}
exportMask.addVolume(volume.getId(), hlu);
exportMask.removeFromExistingVolumes(volume);
}
}
}
}
}
Set existingInitiators = (exportMask.getExistingInitiators() != null) ? exportMask.getExistingInitiators() : Collections.emptySet();
Set existingVolumes = (exportMask.getExistingVolumes() != null) ? exportMask.getExistingVolumes().keySet() : Collections.emptySet();
builder.append(String.format("XM:%s is matching. " + "EI: { %s }, EV: { %s }", name, Joiner.on(',').join(existingInitiators), Joiner.on(',').join(existingVolumes)));
if (foundMaskInDb) {
ExportMaskUtils.sanitizeExportMaskContainers(_dbClient, exportMask);
_dbClient.updateObject(exportMask);
} else {
_dbClient.createObject(exportMask);
}
for (String it : matchingInitiators) {
Set<URI> maskURIs = matchingMasks.get(it);
if (maskURIs == null) {
maskURIs = new HashSet<URI>();
matchingMasks.put(it, maskURIs);
}
maskURIs.add(exportMask.getId());
}
}
}
_log.info(builder.toString());
} 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: {0}", msg), e);
throw SmisException.exceptions.queryExistingMasksFailure(msg, e);
} finally {
if (lunMaskingIter != null) {
lunMaskingIter.close();
}
long totalTime = System.currentTimeMillis() - startTime;
_log.info(String.format("findExportMasks took %f seconds", (double) totalTime / (double) 1000));
}
return matchingMasks;
}
Aggregations