use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class DCNMDialog method getFabricIds.
/**
* Get the list of Vsan Ids.
*
* @return List<String>
* @throws Exception
*/
public List<String> getFabricIds() throws Exception {
// A set is used because in the case of a disconnected network the same Vsan can
// show up twice. Conerted to list at end.
Set<String> fabricIds = new HashSet<String>();
List<Zoneset> zonesets = new ArrayList<Zoneset>();
CIMObjectPath path = CimObjectPathCreator.createInstance("Cisco_Vsan", _namespace);
CloseableIterator<CIMInstance> vsanIt = null;
try {
vsanIt = _client.enumerateInstances(path, false, true, true, null);
while (vsanIt.hasNext()) {
String vsanId = null;
CIMInstance vsanIns = vsanIt.next();
CIMProperty prop = vsanIns.getProperty("OtherIdentifyingInfo");
String[] idinfoValue = (String[]) prop.getValue();
if (idinfoValue.length == 2 && idinfoValue[0].equals("Fabric")) {
vsanId = idinfoValue[1];
}
if (vsanId != null) {
fabricIds.add(vsanId);
}
}
} finally {
if (vsanIt != null) {
vsanIt.close();
}
}
List<String> alist = new ArrayList<String>();
alist.addAll(fabricIds);
return alist;
}
use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class BaseSANCIMObject method cimStringProperty.
protected String cimStringProperty(CIMInstance ins, String field) {
CIMProperty prop = ins.getProperty(field);
if (prop == null) {
return null;
}
Object obj = prop.getValue();
if (obj == null) {
return null;
}
return obj.toString();
}
use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.
the class BrocadeNetworkSMIS method getLogicalToPhysicalSwitcheMap.
/**
* get Logical switches to physical switch map
* @param client an instance of WBEMClient
* @return a map of logical to physical switch name
* @throws WBEMException
*/
public HashMap<String, String> getLogicalToPhysicalSwitcheMap(WBEMClient client) throws WBEMException {
HashMap<String, String> switchMap = new HashMap<>();
CIMObjectPath path = new CIMObjectPath(null, null, null, _namespace, _Brocade_SwitchPCS, null);
CloseableIterator<CIMInstance> it = null;
try {
it = client.enumerateInstances(path, false, true, true, null);
while (it.hasNext()) {
CIMInstance ins = it.next();
String parentName = cimStringProperty(ins, _Parent);
String childName = cimStringProperty(ins, _Child);
_log.debug("Brocade Switch: Parent : {} - Child : {} )", parentName, childName);
CIMProperty[] props = ins.getProperties();
for (int i = 0; i < props.length; i++) {
_log.debug("Switch property : " + props[i].getName() + ": value : " + props[i].getValue());
}
CIMInstance parentObject = client.getInstance(new CIMObjectPath(parentName), true, true, null);
CIMInstance childObject = client.getInstance(new CIMObjectPath(childName), true, true, null);
parentName = cimStringProperty(parentObject, _element_name);
childName = cimStringProperty(childObject, _element_name);
switchMap.put(childName, parentName);
_log.info("Brocade Switch: Logical Switch : " + childName + " In (" + parentName + ")");
}
} finally {
if (it != null) {
it.close();
}
}
return switchMap;
}
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 MetaVolumeTypeProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
CIMObjectPath metaVolumePath = getObjectPathfromCIMArgument(_args);
if (metaVolumePath == null) {
_logger.info(String.format("MetaVolumePath is null."));
} else {
_logger.info(String.format("Processing EMC_Meta for meta volume: %s", metaVolumePath));
UnManagedVolume preExistingVolume = null;
String isMetaVolume = "true";
String nativeGuid;
// Check if storage volume exists in db (the method is called from re-discovery context).
nativeGuid = getVolumeNativeGuid(metaVolumePath);
Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
if (null == storageVolume || storageVolume.getInactive()) {
// Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(metaVolumePath);
_logger.debug("Meta volume nativeguid :" + nativeGuid);
preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
if (null == preExistingVolume) {
_logger.debug("Volume Info Object not found :" + nativeGuid);
return;
}
isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
} else {
_logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
isMetaVolume = storageVolume.getIsComposite().toString();
}
if (isMetaVolume.equalsIgnoreCase("false")) {
_logger.error(String.format("MetaVolumeTypeProcessor called for regular volume: %s", nativeGuid));
return;
}
final Iterator<?> it = (Iterator<?>) resultObj;
if (it.hasNext()) {
final CIMObjectPath symmMetaPath = (CIMObjectPath) it.next();
_logger.debug(String.format("Processing EMC_Meta: %s", symmMetaPath));
CIMInstance cimMeta = client.getInstance(symmMetaPath, false, false, STRIPE_EXTENTS_NUMBER);
CIMProperty stripeLengthProperty = cimMeta.getProperty(SmisConstants.CP_EXTENT_STRIPE_LENGTH);
Long stripeLength = Long.valueOf(stripeLengthProperty.getValue().toString());
String metaVolumeType;
if (stripeLength < 1) {
_logger.error(String.format("Stripe length for EMC_Meta is less than 1: %s", stripeLength));
return;
} else if (stripeLength == 1) {
// this is concatenated meta volume
_logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is concatenated.", stripeLength));
metaVolumeType = Volume.CompositionType.CONCATENATED.toString();
} else {
// this is striped meta volume
_logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is striped.", stripeLength));
metaVolumeType = Volume.CompositionType.STRIPED.toString();
}
_logger.info(String.format("Meta volume: %s, type: %s", metaVolumePath, metaVolumeType));
if (null == preExistingVolume) {
// storage volume update
storageVolume.setCompositionType(metaVolumeType);
// persist volume in db
dbClient.persistObject(storageVolume);
} else {
// unmanaged volume update
StringSet metaVolumeTypeSet = new StringSet();
metaVolumeTypeSet.add(metaVolumeType);
preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_VOLUME_TYPE.toString(), metaVolumeTypeSet);
// for this volume.
if (Volume.CompositionType.STRIPED.toString().equalsIgnoreCase(metaVolumeType)) {
URI storageSystemUri = preExistingVolume.getStorageSystemUri();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemUri);
if (DiscoveredDataObject.Type.vmax.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
_logger.info("Check matched vpool list for vmax striped meta volume and remove fastExpansion vpools.");
StringSet matchedVirtualPools = preExistingVolume.getSupportedVpoolUris();
if (matchedVirtualPools != null && !matchedVirtualPools.isEmpty()) {
_logger.debug("Matched Pools :" + Joiner.on("\t").join(matchedVirtualPools));
StringSet newMatchedPools = new StringSet();
boolean needToReplace = false;
for (String vPoolUriStr : matchedVirtualPools) {
URI vPoolUri = new URI(vPoolUriStr);
VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, vPoolUri);
// null check since supported vPool list in UnManagedVolume may contain inactive vPool
if (virtualPool != null && !virtualPool.getFastExpansion()) {
newMatchedPools.add(vPoolUriStr);
} else {
needToReplace = true;
}
}
if (needToReplace) {
matchedVirtualPools.replace(newMatchedPools);
_logger.info("Replaced VPools : {}", Joiner.on("\t").join(preExistingVolume.getSupportedVpoolUris()));
}
}
}
}
// persist volume in db
dbClient.updateAndReindexObject(preExistingVolume);
}
}
}
} catch (Exception e) {
_logger.error("Processing meta volume type information failed :", e);
}
}
Aggregations