use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method getCIMClient.
/**
* Creates a new WEBClient for a given IP, based on AccessProfile
*
* @param accessProfile
* : AccessProfile for the providers
* @throws WBEMException
* : if WBEMException while creating the WBEMClient
* @throws SMIPluginException
* @return WBEMClient : initialized instance of WBEMClientCIMXML
*/
private static WBEMClient getCIMClient(AccessProfile accessProfile) throws SMIPluginException {
WBEMClient cimClient = null;
try {
final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
CimConnection cxn = connectionFactory.getConnection(accessProfile.getIpAddress(), accessProfile.getProviderPort());
if (cxn == null) {
throw new SMIPluginException(String.format("Not able to get CimConnection to SMISProvider %s on port %s", accessProfile.getIpAddress(), accessProfile.getProviderPort()), SMIPluginException.ERRORCODE_NO_WBEMCLIENT);
}
cimClient = cxn.getCimClient();
if (null == cimClient) {
throw new SMIPluginException("Not able to get CIMOM client", SMIPluginException.ERRORCODE_NO_WBEMCLIENT);
}
} catch (final IllegalStateException ex) {
_logger.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
}
return cimClient;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class SmisCommandHelper method getInstances.
/**
* This is a wrapper for the WBEMClient enumerateInstances method.
*
* @param storage
* - StorageArray reference, will be used to lookup SMI-S connection
* @param namespace
* - Namespace to use
* @param className
* - Name of the class on the provider to query
* @param deep
* - If true, this specifies that, for each returned Instance of the Class, all
* properties of the Instance must be present (subject to constraints imposed by the
* other parameters), including any which were added by subclassing the specified
* Class. If false, each returned Instance includes only properties defined for the
* specified Class in path.
* @param localOnly
* - If true, only elements values that were instantiated in the instance is
* returned.
* @param includeClassOrigin
* - The class origin attribute is the name of the class that first defined the
* property. If true, the class origin attribute will be present for each property on
* all returned CIMInstances. If false, the class origin will not be present.
* @param propertyList
* - An array of property names used to filter what is contained in the instances
* returned. Each instance returned only contains elements for the properties of the
* names specified. Duplicate and invalid property names are ignored and the request
* is otherwise processed normally. An empty array indicates that no properties
* should be returned. A null value indicates that all properties should be returned.
* @return - CloseableIterator of CIMInstance values representing the instances of the specified
* class.
* @throws Exception
*/
public CloseableIterator<CIMInstance> getInstances(StorageSystem storage, String namespace, String className, boolean deep, boolean localOnly, boolean includeClassOrigin, String[] propertyList) throws Exception {
CloseableIterator<CIMInstance> cimInstances;
CimConnection connection = _cimConnection.getConnection(storage);
WBEMClient client = connection.getCimClient();
String classKey = namespace + className;
CIMObjectPath cimObjectPath = CIM_OBJECT_PATH_HASH_MAP.get(classKey);
if (cimObjectPath == null) {
cimObjectPath = CimObjectPathCreator.createInstance(className, namespace);
CIM_OBJECT_PATH_HASH_MAP.putIfAbsent(classKey, cimObjectPath);
}
cimInstances = client.enumerateInstances(cimObjectPath, deep, localOnly, includeClassOrigin, propertyList);
return cimInstances;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class SmisCommandHelper method checkConnectionliveness.
public boolean checkConnectionliveness(StorageSystem storageDevice) {
boolean isLive = false;
try {
CimConnection connection = getConnection(storageDevice);
WBEMClient client = connection.getCimClient();
// Call the provider to get computer systems.
client.enumerateInstanceNames(_cop);
isLive = true;
} catch (Exception wbemEx) {
_log.error("Invalid connection found for Provider: {}", storageDevice.getActiveProviderURI());
}
return isLive;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class IBMCIMObjectPathFactory method executeQuery.
/**
* Executes query
*
* @param storageSystem
* @param query
* @param queryLanguage
* @return list of matched instances
*/
public List<CIMInstance> executeQuery(StorageSystem storageSystem, CIMObjectPath objectPath, String query, String queryLanguage) {
CloseableIterator<CIMInstance> iterator = null;
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
_log.info(String.format("Executing query: %s, objectPath: %s, query language: %s", query, objectPath, queryLanguage));
List<CIMInstance> instanceList = new ArrayList<CIMInstance>();
try {
iterator = client.execQuery(objectPath, query, queryLanguage);
while (iterator.hasNext()) {
CIMInstance instance = iterator.next();
instanceList.add(instance);
}
} catch (WBEMException we) {
_log.error("Caught an error while attempting to execute query and process query result. Query: " + query, we);
} finally {
if (iterator != null) {
iterator.close();
}
}
return instanceList;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class XIVExportOperations method addVolumesUsingSMIS.
private void addVolumesUsingSMIS(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("{} addVolumes START...", storage.getLabel());
try {
_log.info("addVolumes: Export mask id: {}", exportMaskURI);
_log.info("addVolumes: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
// request asked for
if (initiatorList != null) {
_log.info("addVolumes: initiators impacted: {}", Joiner.on(',').join(initiatorList));
}
CIMArgument[] inArgs = _helper.getExposePathsInputArguments(storage, exportMaskURI, volumeURIHLUs, null);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, _cimPath.getControllerConfigSvcPath(storage), IBMSmisConstants.EXPOSE_PATHS, inArgs, outArgs);
CIMObjectPath[] protocolControllers = _cimPath.getProtocolControllersFromOutputArgs(outArgs);
CimConnection cimConnection = _helper.getConnection(storage);
ExportMaskOperationsHelper.populateDeviceNumberFromProtocolControllers(_dbClient, cimConnection, exportMaskURI, volumeURIHLUs, protocolControllers, taskCompleter);
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_log.error("Unexpected error: addVolumes failed.", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("addVolumes", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("{} addVolumes END...", storage.getLabel());
}
Aggregations