Search in sources :

Example 16 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class ValidateVolumeIdentity method validate.

@Override
public boolean validate() throws Exception {
    getLogger().setLog(log);
    for (Volume volume : volumes) {
        CIMObjectPath volumePath = getCimPath().getBlockObjectPath(system, volume);
        CimConnection connection = getHelper().getConnection(system);
        WBEMClient cimClient = connection.getCimClient();
        CIMInstance instance = cimClient.getInstance(volumePath, false, false, PROP_KEYS);
        checkForDifferences(instance, volume);
    }
    return getLogger().hasErrors();
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance)

Example 17 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class SmisCreateMaskingViewJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    _log.info("Updating status of SmisCreateMaskingViewJob");
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            CimConnection cimConnection = jobContext.getCimConnectionFactory().getConnection(storageSystem);
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            List<CIMObjectPath> maskingViews = new ArrayList<CIMObjectPath>();
            iterator = client.associatorNames(getCimJob(), null, SYMM_LUNMASKINGVIEW, null, null);
            while (iterator.hasNext()) {
                CIMObjectPath cimObjectPath = iterator.next();
                maskingViews.add(cimObjectPath);
                ExportMask mask = dbClient.queryObject(ExportMask.class, _exportMaskURI);
                // necessary for future reference to the MV.
                if (mask != null) {
                    String deviceId = cimObjectPath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                    mask.setNativeId(deviceId);
                    dbClient.persistObject(mask);
                    ExportOperationContext.insertContextOperation(getTaskCompleter(), VmaxExportOperationContext.OPERATION_CREATE_MASKING_VIEW, mask.getMaskName());
                }
            }
            // Now perform RP protection tagging, if required, on the storage group
            if (storageSystem.getUsingSmis80()) {
                _log.info("Set RP tag on all volumes within SG for 8.0.3 Providers");
                enableRecoverPointTagOn803(dbClient, client, storageSystem, jobContext);
            } else {
                _log.info("Set RP tag on SG for 4.6.2 Providers");
                enableRecoverPointTag(dbClient, client, _deviceGroupMaskingPath);
            }
            // Now set the HLU on the volume URIs, if they haven't been set by user.
            ExportMaskOperationsHelper.setHLUFromProtocolControllers(dbClient, cimConnection, _exportMaskURI, _volumeURIHLUs, maskingViews, getTaskCompleter());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisCreateMaskingViewJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during masking view create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
        if (iterator != null) {
            iterator.close();
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 18 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class SmisMaskingViewAddVolumeJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    _log.info("Updating status of SmisMaskingViewAddVolumeJob");
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            CimConnection cimConnection = jobContext.getCimConnectionFactory().getConnection(storageSystem);
            List<URI> volumeUriList = new ArrayList<URI>();
            // Now perform RP protection tagging, if required for the
            // objects being added.
            SmisCommandHelper helper = jobContext.getSmisCommandHelper();
            for (VolumeURIHLU volumeUriHlu : _volumeURIHLUs) {
                BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, volumeUriHlu.getVolumeURI());
                if (bo != null && bo instanceof Volume) {
                    Volume volume = (Volume) bo;
                    if (volume != null && volume.checkForRp()) {
                        List<CIMObjectPath> volumePathList = new ArrayList<CIMObjectPath>();
                        volumePathList.add(helper.getVolumeMember(storageSystem, volume));
                        helper.setRecoverPointTag(storageSystem, volumePathList, true);
                    }
                }
                volumeUriList.add(volumeUriHlu.getVolumeURI());
            }
            // for proper roll back , that is volume removal, if exception is thrown during update
            if (_newCreatedGroup != null) {
                helper.setHostIOLimits(cimConnection.getCimClient(), _newCreatedGroup, _volumeURIHLUs);
            }
            String[] volumeNames = ExportMaskUtils.getBlockObjectAlternateNames(volumeUriList, dbClient);
            CIMObjectPath[] volumes = _cimPath.getVolumePaths(storageSystem, volumeNames);
            _log.info("{} volumes processed for HLU updation", volumes.length);
            // Now set the HLU on the volume URIs, if they haven't been set// by user.
            ExportMaskOperationsHelper.setHLUFromProtocolControllersOnAddVolume(dbClient, cimConnection, _exportMaskURI, _volumeURIHLUs, volumes, getTaskCompleter());
        }
    } catch (WBEMException e) {
        _log.error(String.format("updateHostIOLimits failed - new created group: %s", _newCreatedGroup.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        getTaskCompleter().error(dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisMaskingViewAddVolumeJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during add volume to masking view job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 19 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection 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 20 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection 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)

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