use of com.iwave.ext.windows.winrm.WinRMTarget in project coprhd-controller by CoprHD.
the class WindowsHostDiscoveryAdapter method createWindowsSystem.
public static WindowsSystemWinRM createWindowsSystem(Host host) {
boolean ssl = (host.getUseSSL() != null) ? host.getUseSSL() : false;
int port = (host.getPortNumber() != null) ? host.getPortNumber() : (ssl ? WinRMTarget.DEFAULT_HTTPS_PORT : WinRMTarget.DEFAULT_HTTP_PORT);
WinRMTarget target = new WinRMTarget(host.getHostName(), port, ssl, host.getUsername(), host.getPassword());
return new WindowsSystemWinRM(target);
}
use of com.iwave.ext.windows.winrm.WinRMTarget in project coprhd-controller by CoprHD.
the class WindowsHostConnectionValidator method validateConnection.
@Override
public boolean validateConnection(HostParam hostParam, Host existingHost) {
HostType hostType = HostType.valueOf(hostParam.getType());
if (getType().equals(hostType) == false) {
throw new IllegalStateException(String.format("Invalid HostType [%s]", hostParam.getType()));
}
String password = hostParam.getPassword();
if (password == null && existingHost != null) {
password = existingHost.getPassword();
}
List<URI> authProviderIds = dbClient.queryByType(AuthnProvider.class, true);
List<AuthnProvider> authProviders = dbClient.queryObject(AuthnProvider.class, authProviderIds);
KerberosUtil.initializeKerberos(authProviders);
WinRMTarget target = new WinRMTarget(hostParam.getHostName(), hostParam.getPortNumber(), hostParam.getUseSsl(), hostParam.getUserName(), password);
WindowsSystemWinRM cli = new WindowsSystemWinRM(target);
try {
cli.listDiskDrives();
return true;
} catch (Exception e) {
log.error(String.format("Error Validating Host %s", hostParam.getName()), e);
}
return false;
}
Aggregations