Search in sources :

Example 1 with WinRMTarget

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);
}
Also used : WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM) WinRMTarget(com.iwave.ext.windows.winrm.WinRMTarget)

Example 2 with WinRMTarget

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;
}
Also used : HostType(com.emc.storageos.db.client.model.Host.HostType) WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM) AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider) WinRMTarget(com.iwave.ext.windows.winrm.WinRMTarget) URI(java.net.URI)

Aggregations

WindowsSystemWinRM (com.iwave.ext.windows.WindowsSystemWinRM)2 WinRMTarget (com.iwave.ext.windows.winrm.WinRMTarget)2 AuthnProvider (com.emc.storageos.db.client.model.AuthnProvider)1 HostType (com.emc.storageos.db.client.model.Host.HostType)1 URI (java.net.URI)1