Search in sources :

Example 31 with CimConnection

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;
}
Also used : CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) WBEMClient(javax.wbem.client.WBEMClient)

Example 32 with CimConnection

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;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance)

Example 33 with CimConnection

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;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)

Example 34 with CimConnection

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;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) ArrayList(java.util.ArrayList) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 35 with CimConnection

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());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) CIMArgument(javax.cim.CIMArgument)

Aggregations

CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)45 WBEMException (javax.wbem.WBEMException)24 WBEMClient (javax.wbem.client.WBEMClient)24 CIMObjectPath (javax.cim.CIMObjectPath)20 CIMInstance (javax.cim.CIMInstance)16 IOException (java.io.IOException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 ArrayList (java.util.ArrayList)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 ConnectionManagerException (com.emc.storageos.cimadapter.connections.ConnectionManagerException)9 Volume (com.emc.storageos.db.client.model.Volume)8 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)8 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)6 CIMArgument (javax.cim.CIMArgument)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 URI (java.net.URI)5 BlockObject (com.emc.storageos.db.client.model.BlockObject)4 StoragePool (com.emc.storageos.db.client.model.StoragePool)4 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)3 ExportMask (com.emc.storageos.db.client.model.ExportMask)3