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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations