Search in sources :

Example 96 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class IBMCIMObjectPathFactory method getSyncObject.

/**
 * Return IBMTSDS_StorageSynchronized instance referenced by the given
 * BlockObject.
 *
 * @param storage
 * @param subject
 * @return CIMObjectPath
 */
public CIMObjectPath getSyncObject(StorageSystem storage, BlockObject subject) {
    CloseableIterator<CIMObjectPath> syncReference = null;
    CIMObjectPath syncObjectPath = NULL_IBM_CIM_OBJECT_PATH;
    try {
        CIMObjectPath subjectPath = getBlockObjectPath(storage, subject);
        syncReference = _cimConnection.getConnection(storage).getCimClient().referenceNames(subjectPath, CP_STORAGE_SYNCHRONIZED, null);
        if (syncReference != null) {
            while (syncReference.hasNext()) {
                syncObjectPath = syncReference.next();
                if (syncObjectPath != null) {
                    break;
                }
            }
        }
    } catch (WBEMException e) {
        _log.warn(String.format("Trying to find syncObject for %s failed", subject.getId()));
    } finally {
        if (syncReference != null) {
            syncReference.close();
        }
    }
    return syncObjectPath;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException)

Example 97 with WBEMException

use of javax.wbem.WBEMException 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 98 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method checkExists.

/**
 * 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]
 * @param propertyList
 *            - An array of property names used to filter what is contained in the instances
 *            returned.
 * @return CIMInstance object that represents the existing object
 * @throws Exception
 */
private CIMInstance checkExists(StorageSystem storage, CIMObjectPath objectPath, boolean propagated, boolean includeClassOrigin, String[] propertyList) throws Exception {
    CIMInstance instance = null;
    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, propertyList);
        }
    } 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;
}
Also used : WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException)

Example 99 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method getInstance.

/*
     * Return CIM instance of the given object path.
     */
public CIMInstance getInstance(StorageSystem storage, CIMObjectPath objectPath, boolean propagated, boolean includeClassOrigin, String[] propertyList) throws Exception {
    CimConnection connection = _cimConnection.getConnection(storage);
    WBEMClient client = connection.getCimClient();
    // CTRL-9069 workaround CIM_BAD_REQUEST error
    CIMInstance instance = null;
    int retryCount = 0;
    while (true) {
        try {
            _log.info("Calling getInstance, attempt {}", retryCount);
            instance = client.getInstance(objectPath, propagated, includeClassOrigin, propertyList);
        } catch (WBEMException e) {
            if (CIM_BAD_REQUEST.equals(e.getMessage())) {
                if (retryCount < CIM_MAX_RETRY_COUNT) {
                    _log.warn("Encountered 'request-not-well-formed' error. Retry...");
                    retryCount++;
                    try {
                        Thread.sleep(CIM_RETRY_WAIT_INTERVAL);
                    } catch (InterruptedException ie) {
                        _log.warn("Thread: " + Thread.currentThread().getName() + " interrupted.");
                        throw e;
                    }
                    continue;
                }
                _log.warn("Exhausted {} retries", CIM_MAX_RETRY_COUNT);
            }
            // other WBEMException, or reach the max retry count
            throw e;
        }
        // no exception
        break;
    }
    return instance;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 100 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class XIVSmisCommandHelper method getVolumesFromScsiProtocolController.

/**
 * Returns a map of the volume WWNs to their HLU values for a masking
 * container on the array.
 *
 * @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 the volume WWNs to their HLU values for an instance of
 *         LunMasking container on the array.
 */
public Map<String, Integer> getVolumesFromScsiProtocolController(StorageSystem storage, CIMObjectPath controllerPath) {
    Map<String, Integer> wwnToHLU = new HashMap<String, Integer>();
    CloseableIterator<CIMInstance> iterator = null;
    CloseableIterator<CIMInstance> protocolControllerForUnitIter = null;
    try {
        Map<String, Integer> deviceIdToHLU = new HashMap<String, Integer>();
        WBEMClient client = getConnection(storage).getCimClient();
        protocolControllerForUnitIter = client.referenceInstances(controllerPath, CIM_PROTOCOL_CONTROLLER_FOR_UNIT, null, false, PS_DEVICE_NUMBER);
        while (protocolControllerForUnitIter.hasNext()) {
            CIMInstance pcu = protocolControllerForUnitIter.next();
            CIMObjectPath pcuPath = pcu.getObjectPath();
            CIMProperty<CIMObjectPath> dependentVolumePropery = (CIMProperty<CIMObjectPath>) pcuPath.getKey(CP_DEPENDENT);
            CIMObjectPath dependentVolumePath = dependentVolumePropery.getValue();
            String deviceId = dependentVolumePath.getKey(CP_DEVICE_ID).getValue().toString();
            String deviceNumber = CIMPropertyFactory.getPropertyValue(pcu, CP_DEVICE_NUMBER);
            Integer decimalHLU = (int) Long.parseLong(deviceNumber, 16);
            deviceIdToHLU.put(deviceId, decimalHLU);
        }
        iterator = client.associatorInstances(controllerPath, null, CP_STORAGE_VOLUME, null, null, false, PS_NAME);
        while (iterator.hasNext()) {
            CIMInstance cimInstance = iterator.next();
            String deviceId = cimInstance.getObjectPath().getKey(CP_DEVICE_ID).getValue().toString();
            String wwn = CIMPropertyFactory.getPropertyValue(cimInstance, CP_NAME);
            wwnToHLU.put(wwn.toUpperCase(), deviceIdToHLU.get(deviceId));
        }
    } catch (WBEMException we) {
        _log.error("Caught an error will attempting to get volume list from " + "masking instance", we);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
        if (protocolControllerForUnitIter != null) {
            protocolControllerForUnitIter.close();
        }
    }
    return wwnToHLU;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Aggregations

WBEMException (javax.wbem.WBEMException)122 CIMObjectPath (javax.cim.CIMObjectPath)90 CIMInstance (javax.cim.CIMInstance)63 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 CIMArgument (javax.cim.CIMArgument)52 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)38 ArrayList (java.util.ArrayList)29 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)27 Volume (com.emc.storageos.db.client.model.Volume)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 WBEMClient (javax.wbem.client.WBEMClient)19 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 HashSet (java.util.HashSet)15 URI (java.net.URI)13 HashMap (java.util.HashMap)13 BlockObject (com.emc.storageos.db.client.model.BlockObject)10 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)9 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)8