use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class XIVSmisCommandHelper method getInitiatorsFromScsiProtocolController.
/**
* Returns a map of normalized port name to port path for the masking.
*
* @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 port name to port path for the container.
*/
public Map<String, CIMObjectPath> getInitiatorsFromScsiProtocolController(StorageSystem storage, CIMObjectPath controllerPath) {
Map<String, CIMObjectPath> initiatorPortPaths = new HashMap<String, CIMObjectPath>();
CloseableIterator<CIMInstance> iterator = null;
try {
WBEMClient client = getConnection(storage).getCimClient();
iterator = client.associatorInstances(controllerPath, CP_SHWID_TO_SPC, CP_STORAGE_HARDWARE_ID, null, null, false, PS_STORAGE_ID);
while (iterator.hasNext()) {
CIMInstance cimInstance = iterator.next();
String initiator = CIMPropertyFactory.getPropertyValue(cimInstance, CP_STORAGE_ID);
initiatorPortPaths.put(Initiator.normalizePort(initiator), cimInstance.getObjectPath());
}
} catch (WBEMException we) {
_log.error("Caught an error while attempting to get initiator list from " + "masking instance", we);
} finally {
if (iterator != null) {
iterator.close();
}
}
return initiatorPortPaths;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class XIVSmisCommandHelper method getCGMembers.
/*
* Returns null if CG doesn't exist, or members of the CG
*/
public Set<String> getCGMembers(StorageSystem storage, CIMObjectPath cgPath) throws Exception {
Set<String> members = new HashSet<String>();
CIMInstance cgPathInstance = checkExists(storage, cgPath, false, false);
if (cgPathInstance == null) {
return null;
}
CloseableIterator<CIMObjectPath> assocVolNamesIter = null;
try {
assocVolNamesIter = getAssociatorNames(storage, cgPath, null, IBMSmisConstants.CIM_STORAGE_VOLUME, null, null);
while (assocVolNamesIter.hasNext()) {
CIMObjectPath assocVolPath = assocVolNamesIter.next();
String deviceId = assocVolPath.getKeyValue(IBMSmisConstants.CP_DEVICE_ID).toString();
// may have a timing issue, sometimes vol is returned, but is gone from CG
members.add(deviceId);
}
} finally {
if (assocVolNamesIter != null) {
assocVolNamesIter.close();
}
}
return members;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class XIVSmisCommandHelper method checkExists.
/**
* This method is a wrapper for the getInstance. If the object is not found,
* it returns a null value instead of throwing an exception.
*
* @param storage
* [required] - StorageSystem object to which an SMI-S connection
* would be made
* @param objectPath
* [required]
* @param propagated
* [required]
* @param includeClassOrigin
* [required]
* @return CIMInstance object that represents the existing object
* @throws Exception
*/
public CIMInstance checkExists(StorageSystem storage, Volume volume, boolean propagated, boolean includeClassOrigin) throws Exception {
CIMInstance instance = null;
CIMObjectPath objectPath = _cimPath.getBlockObjectPath(storage, volume);
try {
if (objectPath != null) {
_log.debug(String.format("checkExists(storage=%s, objectPath=%s, propagated=%s, includeClassOrigin=%s)", storage.getSerialNumber(), objectPath.toString(), String.valueOf(propagated), String.valueOf(includeClassOrigin)));
instance = getInstance(storage, objectPath, propagated, includeClassOrigin, null);
}
} catch (WBEMException e) {
// it's okay, we want to return null for this method
if (e.getID() != WBEMException.CIM_ERR_NOT_FOUND) {
throw e;
}
} catch (Exception e) {
_log.error("checkExists call encountered an exception", e);
throw e;
}
return instance;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevice method doRemoveFromConsistencyGroup.
@Override
public void doRemoveFromConsistencyGroup(final StorageSystem storage, final URI consistencyGroupId, final List<URI> blockObjects, final TaskCompleter taskCompleter) throws DeviceControllerException {
BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
try {
// check if the consistency group already exists
String groupName = _helper.getConsistencyGroupName(consistencyGroup, storage);
CIMObjectPath cgPath = _cimPath.getConsistencyGroupPath(storage, groupName);
CIMInstance cgPathInstance = _helper.checkExists(storage, cgPath, false, false);
if (cgPathInstance != null) {
String[] blockObjectIds = _helper.getBlockObjectNativeIds(blockObjects);
removeVolumesFromCG(storage, consistencyGroup, cgPath, blockObjectIds);
}
// remove any references to the consistency group
List<BlockObject> objectsToSave = new ArrayList<BlockObject>();
for (URI blockObjectURI : blockObjects) {
BlockObject blockObject = BlockObject.fetch(_dbClient, blockObjectURI);
if (blockObject != null) {
if (blockObject.getConsistencyGroup() != null) {
blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
}
objectsToSave.add(blockObject);
}
_dbClient.persistObject(objectsToSave);
taskCompleter.ready(_dbClient);
} catch (DeviceControllerException e) {
taskCompleter.error(_dbClient, e);
} catch (Exception e) {
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId()), e.getMessage()));
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevice method doFindHostHLUs.
/**
* {@inheritDoc}
*/
@Override
public Map<URI, List<Integer>> doFindHostHLUs(StorageSystem storage, Collection<URI> initiatorURIs) throws DeviceControllerException {
Map<URI, List<Integer>> initiatorToHLUMap = new HashMap<URI, List<Integer>>();
for (URI initiatorURI : initiatorURIs) {
List<Integer> initiatorHLUs = new ArrayList<Integer>();
initiatorToHLUMap.put(initiatorURI, initiatorHLUs);
Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
final String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
CloseableIterator<CIMInstance> scsiPCInstances = null;
CloseableIterator<CIMInstance> pcforseunitInstances = null;
try {
String query = String.format("Select * From %s Where ElementName=\"%s\"", IBMSmisConstants.CP_STORAGE_HARDWARE_ID, normalizedPortName);
CIMObjectPath pcHwdIDPath = CimObjectPathCreator.createInstance(IBMSmisConstants.CP_STORAGE_HARDWARE_ID, Constants.IBM_NAMESPACE, null);
List<CIMInstance> hwidInstances = _helper.executeQuery(storage, pcHwdIDPath, query, "WQL");
if (null != hwidInstances && !hwidInstances.isEmpty()) {
CIMObjectPath hwidObjectPath = hwidInstances.get(0).getObjectPath();
scsiPCInstances = _helper.getAssociatorInstances(storage, hwidObjectPath, null, IBMSmisConstants.CP_SCSI_PROTOCOL_CONTROLLER, IBMSmisConstants.CP_COLLECTION, IBMSmisConstants.CP_MEMBER, SmisConstants.PS_ELEMENT_NAME);
while (null != scsiPCInstances && scsiPCInstances.hasNext()) {
CIMInstance scsiPCInstance = scsiPCInstances.next();
CIMObjectPath scsiPCObjectPath = scsiPCInstance.getObjectPath();
pcforseunitInstances = _helper.getReferenceInstances(storage, scsiPCObjectPath, IBMSmisConstants.CP_PROTOCOLCONTROLLER_FOR_SEUNIT, null, new String[] { IBMSmisConstants.DEVICE_NUMBER });
while (null != pcforseunitInstances && pcforseunitInstances.hasNext()) {
CIMInstance instance = pcforseunitInstances.next();
final String deviceNumber = CIMPropertyFactory.getPropertyValue(instance, IBMSmisConstants.DEVICE_NUMBER);
if (null != deviceNumber && !deviceNumber.isEmpty()) {
initiatorHLUs.add(Integer.parseInt(deviceNumber));
}
}
_log.info("HLU list for Initiator Port {} : {}", normalizedPortName, initiatorHLUs);
}
}
} catch (WBEMException e) {
DeviceControllerException.exceptions.smis.hluRetrievalFailed("Error occured during retrieval of HLUs for a Host", e);
} finally {
if (scsiPCInstances != null) {
scsiPCInstances.close();
}
if (pcforseunitInstances != null) {
pcforseunitInstances.close();
}
}
}
return initiatorToHLUMap;
}
Aggregations