Search in sources :

Example 1 with ESightServiceImpl

use of com.huawei.esight.service.ESightServiceImpl 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;
}
Also used : ESightServiceImpl(com.huawei.esight.service.ESightServiceImpl) EsightException(com.huawei.esight.exception.EsightException) ESightService(com.huawei.esight.service.ESightService) ResourceConfig(com.integrien.alive.common.adapter3.config.ResourceConfig) IdentifierCredentialProperties(com.integrien.alive.common.adapter3.IdentifierCredentialProperties)

Aggregations

EsightException (com.huawei.esight.exception.EsightException)1 ESightService (com.huawei.esight.service.ESightService)1 ESightServiceImpl (com.huawei.esight.service.ESightServiceImpl)1 IdentifierCredentialProperties (com.integrien.alive.common.adapter3.IdentifierCredentialProperties)1 ResourceConfig (com.integrien.alive.common.adapter3.config.ResourceConfig)1