Search in sources :

Example 36 with CimConnection

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

the class XIVSmisCommandHelper method validateStorageProviderConnection.

/*
     * Validate connection
     */
public boolean validateStorageProviderConnection(String ipAddress, Integer portNumber) {
    boolean isConnectionValid = false;
    try {
        CimConnection connection = _cimConnection.getConnection(ipAddress, portNumber.toString());
        isConnectionValid = (connection != null && _cimConnection.checkConnectionliveness(connection));
    } catch (IllegalStateException ise) {
        _log.error(ise.getMessage());
    }
    return isConnectionValid;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection)

Example 37 with CimConnection

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

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

the class XIVSmisStorageDevicePostProcessor method processVolumeCreation.

/*
     * (non-Javadoc) Update DB with volume creation output from SMI-S.
     * 
     * @see
     * com.emc.storageos.volumecontroller.impl.smis.job.SmisAbstractCreateVolumeJob
     * #updateStatus
     */
public Set<URI> processVolumeCreation(StorageSystem storageSystem, URI storagePoolURI, List<Volume> volumes, CIMArgument[] outArgs) throws Exception {
    Set<URI> volumeURIs = new HashSet<URI>(volumes.size());
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing volume creation"));
    CimConnection connection = _cimConnection.getConnection(storageSystem);
    WBEMClient client = connection.getCimClient();
    Calendar now = Calendar.getInstance();
    StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
    updateStoragePoolCapacity(client, storagePool);
    StringMap reservationMap = storagePool.getReservedCapacityMap();
    for (Volume volume : volumes) {
        reservationMap.remove(volume.getId().toString());
    }
    _dbClient.persistObject(storagePool);
    CIMObjectPath[] elements = (CIMObjectPath[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_THE_ELEMENTS);
    UnsignedInteger32[] returnCoedes = (UnsignedInteger32[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODES);
    List<Volume> volumesToSave = new ArrayList<Volume>(elements.length);
    if (elements != null && returnCoedes != null) {
        for (int i = 0; i < elements.length; i++) {
            URI volumeId = volumes.get(i).getId();
            Volume volume = _dbClient.queryObject(Volume.class, volumeId);
            volumesToSave.add(volume);
            volumeURIs.add(volumeId);
            boolean isSuccess = false;
            CIMObjectPath volumePath = elements[i];
            if (volumePath != null) {
                CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(IBMSmisConstants.CP_DEVICE_ID);
                if (deviceID != null) {
                    String nativeID = deviceID.getValue();
                    if ((nativeID != null) && (nativeID.length() != 0)) {
                        isSuccess = true;
                        volume.setPool(storagePoolURI);
                        processVolume(volumePath, nativeID, volume, client, logMsgBuilder, now);
                    }
                }
            }
            if (!isSuccess) {
                logMsgBuilder.append("\n");
                logMsgBuilder.append(String.format("Failed to create volume: %s with return code: %s", volumeId, returnCoedes[i].toString()));
                volume.setInactive(true);
            }
        }
    }
    if (!volumesToSave.isEmpty()) {
        _dbClient.persistObject(volumesToSave);
    }
    _log.info(logMsgBuilder.toString());
    return volumeURIs;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) Calendar(java.util.Calendar) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) ArrayList(java.util.ArrayList) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) HashSet(java.util.HashSet)

Example 39 with CimConnection

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

the class XIVSmisStorageDevicePostProcessor method processCloneCreation.

@SuppressWarnings("rawtypes")
public void processCloneCreation(StorageSystem storageSystem, URI volumeURI, CIMArgument[] outArgs, CloneCreateCompleter taskCompleter) throws Exception {
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing clone creation - "));
    CimConnection connection = _cimConnection.getConnection(storageSystem);
    WBEMClient client = connection.getCimClient();
    Volume cloneVolume = _dbClient.queryObject(Volume.class, volumeURI);
    URI poolURI = cloneVolume.getPool();
    StoragePool pool = _dbClient.queryObject(StoragePool.class, poolURI);
    updateStoragePoolCapacity(client, pool);
    StringMap reservationMap = pool.getReservedCapacityMap();
    // remove from reservation map
    reservationMap.remove(cloneVolume.getId().toString());
    _dbClient.persistObject(pool);
    CIMObjectPath cloneVolumePath = (CIMObjectPath) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_TARGET_ELEMENT);
    if (cloneVolumePath != null) {
        // Get the sync volume native device id
        CIMInstance syncVolume = client.getInstance(cloneVolumePath, false, false, null);
        String deviceID = cloneVolumePath.getKey(IBMSmisConstants.CP_DEVICE_ID).getValue().toString();
        String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, IBMSmisConstants.CP_ELEMENT_NAME);
        String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, IBMSmisConstants.CP_NAME);
        cloneVolume.setNativeId(deviceID);
        cloneVolume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, cloneVolume));
        cloneVolume.setLabel(elementName);
        cloneVolume.setDeviceLabel(elementName);
        cloneVolume.setInactive(false);
        cloneVolume.setCreationTime(Calendar.getInstance());
        cloneVolume.setWWN(wwn.toUpperCase());
        cloneVolume.setAlternateName(wwn);
        cloneVolume.setProvisionedCapacity(getProvisionedCapacityInformation(syncVolume));
        cloneVolume.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
        logMsgBuilder.append(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s.", cloneVolumePath.toString(), cloneVolume.getId().toString(), deviceID));
        _dbClient.persistObject(cloneVolume);
        taskCompleter.ready(_dbClient);
    } else {
        cloneVolume.setInactive(true);
        _dbClient.persistObject(cloneVolume);
        ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(volumeURI.toString());
        logMsgBuilder.append(error.getMessage());
        _log.error(logMsgBuilder.toString());
        throw new Exception(error.getMessage());
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException)

Example 40 with CimConnection

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

the class CIMConnectionFactory method deleteStaleSubscriptions.

/**
 * Deletes stale subscriptions
 *
 * @param smisProviderURI {@link String} SMIS Provider's URI for delete stale subscription
 * @return boolean success flag. True means delete stale subscription for the given smisProvider is success, else returns false
 */
public boolean deleteStaleSubscriptions(String smisProviderURI) {
    _log.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    boolean isSuccess = false;
    try {
        _log.debug("smisProviderURI :{}", smisProviderURI);
        CimConnection cimConnection = getSMISProviderConnection(smisProviderURI);
        if (null != cimConnection) {
            _connectionManager.deleteStaleSubscriptions(cimConnection);
            isSuccess = true;
        }
    } catch (Exception e) {
        _log.error("Delete stale subscription for the SMIS provider {} is failed", smisProviderURI);
        _log.error(e.getMessage(), e);
    // throw e;
    }
    _log.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    return isSuccess;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) IOException(java.io.IOException)

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