Search in sources :

Example 21 with CimConnection

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

the class SmisCommandHelper method invokeMethod.

public Object invokeMethod(StorageSystem storageDevice, CIMObjectPath objectPath, String methodName, CIMArgument[] inArgs, CIMArgument[] outArgs) throws WBEMException {
    CimConnection connection = getConnection(storageDevice);
    WBEMClient client = connection.getCimClient();
    int index = 0;
    StringBuilder inputInfoBuffer = new StringBuilder();
    inputInfoBuffer.append("\nSMI-S Provider: ").append(connection.getHost()).append(" -- Attempting invokeMethod ").append(methodName).append(" on\n").append("  objectPath=").append(objectPath.toString()).append(" with arguments: \n");
    if (inArgs != null) {
        for (CIMArgument arg : inArgs) {
            if (arg != null) {
                inputInfoBuffer.append("    inArg[").append(index++).append("]=").append(arg.toString()).append('\n');
            }
        }
    }
    InvokeTestFailure.internalOnlyInvokeSmisTestFailure(methodName, InvokeTestFailure.ARTIFICIAL_FAILURE_015);
    _log.info(inputInfoBuffer.toString());
    long start = System.nanoTime();
    Object obj = client.invokeMethod(objectPath, methodName, inArgs, outArgs);
    String total = String.format("%2.6f", ((System.nanoTime() - start) / 1000000000.0));
    String str = protectedToString(obj);
    StringBuilder outputInfoBuffer = new StringBuilder();
    outputInfoBuffer.append("\nSMI-S Provider: ").append(connection.getHost()).append(" -- Completed invokeMethod ").append(methodName).append(" on\n").append("  objectPath=").append(objectPath.toString()).append("\n  Returned: ").append(str).append(" with output arguments: \n");
    for (CIMArgument arg : outArgs) {
        if (arg != null) {
            str = protectedToString(arg);
            outputInfoBuffer.append("    outArg=").append(str).append('\n');
        }
    }
    outputInfoBuffer.append("  Execution time: ").append(total).append(" seconds.\n");
    _log.info(outputInfoBuffer.toString());
    return obj;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) WBEMClient(javax.wbem.client.WBEMClient) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) CIMArgument(javax.cim.CIMArgument)

Example 22 with CimConnection

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

the class SmisCommandHelper method validateStorageProviderConnection.

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 23 with CimConnection

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

the class SmisCommandHelper method setRecoverPointTagInternal.

/**
 * Method will add or remove the EMCRecoverPointEnabled flag from the device masking group for
 * VMAX.
 *
 * @param deviceGroupPath
 *            [in] - CIMObjectPath referencing the volume
 */
private boolean setRecoverPointTagInternal(StorageSystem storage, List<CIMObjectPath> volumeMemberList, boolean tag) throws Exception {
    boolean tagSet = false;
    try {
        _log.info("Attempting to {} RecoverPoint tag on Volume: {}", tag ? "enable" : "disable", Joiner.on(",").join(volumeMemberList));
        CimConnection connection = _cimConnection.getConnection(storage);
        WBEMClient client = connection.getCimClient();
        if (storage.getUsingSmis80()) {
            CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storage);
            CIMArgument[] inArgs = getRecoverPointInputArguments(storage, volumeMemberList, tag);
            CIMArgument[] outArgs = new CIMArgument[5];
            SmisJob job = null;
            invokeMethodSynchronously(storage, configSvcPath, EMC_SETUNSET_RECOVERPOINT, inArgs, outArgs, job);
        } else {
            for (CIMObjectPath volumeMember : volumeMemberList) {
                CIMInstance toUpdate = new CIMInstance(volumeMember, new CIMProperty[] { _cimProperty.bool(EMC_RECOVERPOINT_ENABLED, tag) });
                _log.debug("Params: " + toUpdate.toString());
                client.modifyInstance(toUpdate, CP_EMC_RECOVERPOINT_ENABLED);
            }
        }
        _log.info(String.format("RecoverPoint tag has been successfully %s Volume", tag ? "applied to" : "removed from"));
        tagSet = true;
    } catch (WBEMException e) {
        if (e.getMessage().contains("is already set to the requested state")) {
            _log.info("Found the volume was already in the proper RecoverPoint tag state");
            tagSet = true;
        } else {
            _log.error(String.format("Encountered an error while trying to %s the RecoverPoint tag", tag ? "enable" : "disable"), e);
        }
    }
    return tagSet;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) CIMObjectPath(javax.cim.CIMObjectPath) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) CIMArgument(javax.cim.CIMArgument)

Example 24 with CimConnection

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

the class ConnectionManager method isConnected.

/**
 * Determines whether or not a connection has already been established for
 * the passed host.
 *
 * @param hostAndPort The name of the host to verify.
 *
 * @return true if a connection has been created for the passed host, false
 *         otherwise.
 *
 * @throws ConnectionManagerException When the passed host is null or blank.
 */
public boolean isConnected(String hostAndPort) throws ConnectionManagerException {
    connectionLock.lock();
    boolean isConnected = false;
    try {
        // Verify the passed host/port is not null or blank.
        if ((hostAndPort == null) || (hostAndPort.length() == 0)) {
            throw new ConnectionManagerException("Passed host/port is null or blank.");
        }
        CimConnection connection = _connections.get(hostAndPort);
        if (connection != null) {
            isConnected = true;
        }
    } finally {
        connectionLock.unlock();
    }
    return isConnected;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection)

Example 25 with CimConnection

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

the class ConnectionManager method getConnection.

/**
 * Returns a reference to the connection for the provider at the passed
 * host and port
 *
 * @param hostAndPort The name of the host/port on which the provider is executing.
 *
 * @return A reference to the provider connection.
 *
 * @throws ConnectionManagerException When the passed host is null or blank.
 */
public CimConnection getConnection(String host, Integer port) throws ConnectionManagerException {
    connectionLock.lock();
    CimConnection connection = null;
    try {
        String hostAndPort = generateConnectionCacheKey(host, port);
        // Verify the passed host/port is not null or blank.
        if ((hostAndPort == null) || (hostAndPort.length() == 0)) {
            throw new ConnectionManagerException("Passed host/port is null or blank.");
        }
        connection = _connections.get(hostAndPort);
        if (connection != null) {
            // Every time the connection is returned, update the last get time
            connectionLastTouch.put(hostAndPort, System.currentTimeMillis());
        }
    } finally {
        connectionLock.unlock();
    }
    return connection;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection)

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