use of com.huawei.esight.service.ESightService in project Server_Management_Plugin_vRealize by Huawei.
the class ESightAdapter method onTest.
/**
* This method is called when presses "Test" button while
* creating/editing an adapter instance.
*
* @param testParam TestParam
* @return boolean
*/
@Override
public boolean onTest(TestParam testParam) {
ResourceConfig adapterInstanceResource = testParam.getAdapterConfig().getAdapterInstResource();
final IdentifierCredentialProperties prop = new IdentifierCredentialProperties(adapterLoggerFactory, adapterInstanceResource);
if (logger.isInfoEnabled()) {
logger.info("Inside onTest method of ESightAdapter class");
}
String empty = "";
String hostIp = prop.getIdentifier(Constant.KEY_SERVER_IP_ADDRESS, empty).trim();
int serverPort = prop.getIntIdentifier(Constant.KEY_ESIGHT_SERVER_PORT, Constant.DEFAULT_ESIGHT_SERVER_PORT);
String username = prop.getCredential(Constant.KEY_ESIGHT_ACCOUNT);
String password = prop.getCredential(Constant.KEY_ESIGHT_CODE);
try {
if (!isValidUrl(hostIp, serverPort)) {
throw new EsightException("invalid host ip");
}
ESightService serviceImpl = new ESightServiceImpl();
String openid = serviceImpl.login(hostIp, serverPort, username, password);
if (openid == null || openid.isEmpty()) {
return false;
}
serviceImpl.logout(openid);
} catch (EsightException e) {
logger.error("Test eSight login failed.", e);
return false;
}
return true;
}
Aggregations