use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.
the class WindowsHostDiscoveryAdapter method findCluster.
protected URI findCluster(Host host) {
WindowsSystemWinRM system = createWindowsSystem(host);
try {
if (system.isClustered()) {
Map<String, List<MSClusterNetworkInterface>> clusterToNetworkInterfaces = system.getClusterToNetworkInterfaces();
String clusterName = WindowsClusterUtils.findWindowsClusterHostIsIn(host.getHostName(), clusterToNetworkInterfaces);
if (clusterName == null) {
if (clusterToNetworkInterfaces.size() == 1) {
clusterName = clusterToNetworkInterfaces.keySet().iterator().next();
} else if (clusterToNetworkInterfaces.isEmpty()) {
warn("Host '%s' appears to be clustered, but cannot find any cluster interfaces", host.getHostName());
return NullColumnValueGetter.getNullURI();
} else {
warn("Host '%s' is configured in multiple clusters %s, cannot determine primary cluster by network interface", host.getHostName(), clusterToNetworkInterfaces.keySet());
return NullColumnValueGetter.getNullURI();
}
}
List<String> clusterIpAddresses = WindowsClusterUtils.getClusterIpAddresses(clusterToNetworkInterfaces.get(clusterName));
// Find the cluster by address
URI cluster = findClusterByAddresses(host, host.getTenant(), HostType.Windows, clusterIpAddresses);
if (cluster != null) {
updateClusterName(cluster, clusterName);
return cluster;
}
// Find the cluster by name
cluster = findClusterByName(host.getTenant(), clusterName);
if (cluster != null) {
// Ensure the cluster is empty before using it or if host already belongs to this cluster
if (Iterables.isEmpty(getModelClient().hosts().findByCluster(cluster, true)) || (!NullColumnValueGetter.isNullURI(host.getCluster()) && host.getCluster().toString().equals(cluster.toString()))) {
updateClusterName(cluster, clusterName);
return cluster;
}
// Log a warning
warn("Host '%s' is in a cluster named '%s' which could not be matched by address. " + "An existing non-empty ViPR cluster exists with the same name; " + "manual cluster assignment required", host.getHostName(), clusterName);
return NullColumnValueGetter.getNullURI();
}
// No cluster matched by address or name, create a new one
return createNewCluster(host.getTenant(), clusterName);
}
// Host is not currently in a Windows Cluster
return NullColumnValueGetter.getNullURI();
} catch (WinRMException e) {
throw new RuntimeException(e);
}
}
use of com.iwave.ext.windows.WindowsSystemWinRM 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.WindowsSystemWinRM in project coprhd-controller by CoprHD.
the class MountBlockVolumeHelper method createHelpers.
public static List<MountBlockVolumeHelper> createHelpers(List<WindowsSystemWinRM> windowsSystems, long volumeCapacityInBytes) {
List<MountBlockVolumeHelper> helpers = Lists.newArrayList();
for (WindowsSystemWinRM windowsSystem : windowsSystems) {
WindowsSupport windowsSupport = new WindowsSupport(windowsSystem);
MountBlockVolumeHelper mountBlockVolumeHelper = new MountBlockVolumeHelper(windowsSupport, volumeCapacityInBytes);
BindingUtils.bind(mountBlockVolumeHelper, ExecutionUtils.currentContext().getParameters());
helpers.add(mountBlockVolumeHelper);
}
return helpers;
}
use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.
the class UnmountBlockVolumeHelper method createHelpers.
public static List<UnmountBlockVolumeHelper> createHelpers(URI hostId, List<WindowsSystemWinRM> windowsSystems) {
List<UnmountBlockVolumeHelper> helpers = Lists.newArrayList();
for (WindowsSystemWinRM windowsSystem : windowsSystems) {
WindowsSupport windowsSupport = new WindowsSupport(windowsSystem);
UnmountBlockVolumeHelper unmountBlockVolumeHelper = new UnmountBlockVolumeHelper(hostId, windowsSupport);
BindingUtils.bind(unmountBlockVolumeHelper, ExecutionUtils.currentContext().getParameters());
helpers.add(unmountBlockVolumeHelper);
}
return helpers;
}
use of com.iwave.ext.windows.WindowsSystemWinRM 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