refreshNetwork();
Set<String> networkNames = new HashSet<String>();
networkNames.addAll(networkList);
Set<String> portGroupNames = new HashSet<String>();
for (String networkName : networkNames) {
VcNetwork vcNetwork = getNetworkByName(networkName);
if (vcNetwork == null) {
throw VcProviderException.NETWORK_NOT_FOUND(networkName);
}
portGroupNames.add(vcNetwork.getName());
}
List<String> noNetworkHosts = new ArrayList<String>();
for (com.vmware.bdd.spectypes.VcCluster cluster : clusters) {
List<VcHost> hosts = getHostsByClusterName(cluster.getName());
for (VcHost vcHost : hosts) {
// check each host has all the networks
List<VcNetwork> vcNetworks = vcHost.getNetworks();
List<String> hostNetworkNames = new ArrayList<String>();
for (VcNetwork vcNetwork : vcNetworks) {
hostNetworkNames.add(vcNetwork.getName());
}
if (!hostNetworkNames.containsAll(portGroupNames)) {
logger.info("host" + vcHost.getName() + " has networks " + vcNetworks
+ " does not have target network " + portGroupNames);
noNetworkHosts.add(vcHost.getName());