Search in sources :

Example 46 with WBEMException

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

the class SmisCommandHelper method executeQuery.

/**
 * Executes query for component of a given storage system (volume, pool, etc...)
 *
 * @param storageSystem
 * @param query
 * @param queryLanguage
 * @return
 * @throws WBEMException
 */
public List<CIMInstance> executeQuery(StorageSystem storageSystem, String query, String queryLanguage) throws WBEMException {
    CloseableIterator<CIMInstance> iterator = null;
    CimConnection connection = _cimConnection.getConnection(storageSystem);
    WBEMClient client = connection.getCimClient();
    CIMObjectPath objectPath = _cimPath.getStorageSystem(storageSystem);
    _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 will attempting to execute query and process query result. Query: " + query, we);
    } finally {
        closeCIMIterator(iterator);
    }
    return instanceList;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 47 with WBEMException

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

the class SmisCommandHelper method arraySupports.

public boolean arraySupports(StorageSystem storage, int operation) {
    boolean result = false;
    CIMArgument[] out = new CIMArgument[5];
    try {
        invokeMethod(storage, _cimPath.getReplicationServiceCapabilitiesPath(storage), GET_SUPPORTED_OPERATIONS, getSupportedOperationsForSnapshot(), out);
        Object value = _cimPath.getFromOutputArgs(out, SUPPORTED_OPERATIONS);
        if (value != null) {
            UnsignedInteger16[] supported = (UnsignedInteger16[]) value;
            for (UnsignedInteger16 it : supported) {
                if (it.intValue() == operation) {
                    result = true;
                    break;
                }
            }
        }
    } catch (WBEMException e) {
        _log.error("arraySupportsDissolve exception: ", e);
    }
    return result;
}
Also used : BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) WBEMException(javax.wbem.WBEMException) UnsignedInteger16(javax.cim.UnsignedInteger16) CIMArgument(javax.cim.CIMArgument)

Example 48 with WBEMException

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

the class SmisCommandHelper method checkVolumeAssociatedWithAnyFASTSG.

/**
 * Check if volume is associated with any FAST SG, irrespective of MVs.
 *
 * @param volNativeId the volume native id
 * @param storage the storage system
 * @return true, if successful
 * @throws WBEMException
 */
public boolean checkVolumeAssociatedWithAnyFASTSG(String volNativeId, StorageSystem storage) throws WBEMException {
    CloseableIterator<CIMInstance> sgInstanceIr = null;
    try {
        _log.info("Trying to find if volume {} is associated with any FAST managed SG", volNativeId);
        CIMObjectPath volumePath = _cimPath.getVolumePath(storage, volNativeId);
        sgInstanceIr = getAssociatorInstances(storage, volumePath, null, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), null, null, SmisConstants.PS_V3_STORAGE_GROUP_PROPERTIES);
        while (sgInstanceIr.hasNext()) {
            CIMInstance sgInstance = sgInstanceIr.next();
            String gpNameFound = (String) sgInstance.getPropertyValue(SmisConstants.CP_ELEMENT_NAME);
            _log.info("Volume {} available in SG {}", volNativeId, gpNameFound);
            String fastSetting = getVMAX3FastSettingAssociatedWithVolumeGroup(sgInstance);
            if (!Constants.NONE.equalsIgnoreCase(fastSetting)) {
                _log.info("Volume {} available in other FAST SG {}. EMCFastSetting {}", volNativeId, gpNameFound, fastSetting);
                return true;
            }
        }
    } catch (WBEMException we) {
        _log.error("Find volume associated with any FAST SG failed", we);
        throw we;
    } finally {
        if (null != sgInstanceIr) {
            sgInstanceIr.close();
        }
    }
    _log.info("No FAST SG found associated for volume {}", volNativeId);
    return false;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 49 with WBEMException

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

the class SmisCommandHelper method getInstance.

public CIMInstance getInstance(StorageSystem storage, CIMObjectPath objectPath, boolean propagated, boolean includeClassOrigin, String[] propertyList) throws WBEMException {
    CIMInstance cimInstance = null;
    CimConnection connection = _cimConnection.getConnection(storage);
    WBEMClient client = connection.getCimClient();
    try {
        cimInstance = client.getInstance(objectPath, propagated, includeClassOrigin, propertyList);
    } catch (WBEMException we) {
        throw we;
    }
    return cimInstance;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 50 with WBEMException

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

the class SmisCommandHelper method getVolumeGroupBasedOnSLO.

/**
 * Finds the storage group based on SLO
 *
 * @param forProvider
 *            The storage provider where the query executes
 * @param storageSystem
 *            The reference to storage system
 * @param slo
 *            The slo name for the fast setting
 * @param workload
 *            The workload name for the fast setting
 * @param srp
 *            The srp name for the fast setting
 *
 * @return returns volumeGroupPath if found else null
 */
public CIMObjectPath getVolumeGroupBasedOnSLO(StorageSystem forProvider, StorageSystem storageSystem, String slo, String workload, String srp) {
    CIMObjectPath volumeGroupObjectPath = null;
    StringBuffer fastSettingName = new StringBuffer();
    fastSettingName = fastSettingName.append(slo).append(Constants._plusDelimiter).append(workload).append(Constants._plusDelimiter).append(srp);
    try {
        Map<CIMObjectPath, Set<String>> groupPaths = findAnySLOStorageGroupsCanBeReUsed(forProvider, storageSystem, fastSettingName.toString(), false);
        for (CIMObjectPath groupPath : groupPaths.keySet()) {
            Set<String> groupVolumes = groupPaths.get(groupPath);
            if (groupVolumes == null || (groupVolumes != null && groupVolumes.size() < 4000)) {
                volumeGroupObjectPath = groupPath;
                break;
            }
        }
    } catch (WBEMException e) {
        _log.info(storageSystem.getSystemType() + " Problem when trying to look for existing storage group for SLO " + fastSettingName.toString(), e);
        throw new DeviceControllerException(e);
    }
    return volumeGroupObjectPath;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

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