Search in sources :

Example 1 with HostType

use of com.emc.storageos.db.client.model.Host.HostType in project coprhd-controller by CoprHD.

the class HostConnectionValidator method isHostConnectionValid.

public static boolean isHostConnectionValid(HostParam hostParam, Host existingHost) {
    HostType hostType = HostType.valueOf(hostParam.getType());
    HostConnectionValidator hostConnectionValidator = validators.get(hostType);
    if (hostConnectionValidator != null) {
        return hostConnectionValidator.validateConnection(hostParam, existingHost);
    }
    return true;
}
Also used : HostType(com.emc.storageos.db.client.model.Host.HostType)

Example 2 with HostType

use of com.emc.storageos.db.client.model.Host.HostType in project coprhd-controller by CoprHD.

the class HpuxHostConnectionValidator 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();
    }
    HpuxSystem cli = new HpuxSystem(hostParam.getHostName(), hostParam.getPortNumber(), hostParam.getUserName(), password);
    try {
        cli.listIPInterfaces();
        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) HpuxSystem(com.emc.hpux.HpuxSystem)

Example 3 with HostType

use of com.emc.storageos.db.client.model.Host.HostType 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)

Example 4 with HostType

use of com.emc.storageos.db.client.model.Host.HostType in project coprhd-controller by CoprHD.

the class LinuxHostConnectionValidator 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();
    }
    LinuxSystemCLI cli = new LinuxSystemCLI(hostParam.getHostName(), hostParam.getPortNumber(), hostParam.getUserName(), password);
    try {
        cli.listMountPoints();
        return true;
    } catch (Exception e) {
        log.error(String.format("Error Validating Host %s", hostParam.getName()), e);
    }
    return false;
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) HostType(com.emc.storageos.db.client.model.Host.HostType)

Aggregations

HostType (com.emc.storageos.db.client.model.Host.HostType)4 HpuxSystem (com.emc.hpux.HpuxSystem)1 AuthnProvider (com.emc.storageos.db.client.model.AuthnProvider)1 LinuxSystemCLI (com.iwave.ext.linux.LinuxSystemCLI)1 WindowsSystemWinRM (com.iwave.ext.windows.WindowsSystemWinRM)1 WinRMTarget (com.iwave.ext.windows.winrm.WinRMTarget)1 URI (java.net.URI)1