if (host == null || zone == null || iaasInfo == null) {
String msg = "Host or Zone or IaaSProvider is null: host: " + host + " - zone: " +
zone + " - IaaSProvider: " + iaasInfo;
log.error(msg);
throw new InvalidHostException(msg);
}
ComputeServiceContext context = iaasInfo.getComputeService().getContext();
RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
HostAggregateApi hostApi = nova.getApi().getHostAggregateExtensionForZone(zone).get();
for (HostAggregate hostAggregate : hostApi.list()) {
for (String configuredHost : hostAggregate.getHosts()) {
if (host.equalsIgnoreCase(configuredHost)) {
if (log.isDebugEnabled()) {
log.debug("Found a matching host: " + host);
}
return true;
}
}
}
String msg = "Invalid host: " + host +" in the zone: "+zone+ " and of the iaas: "+iaasInfo.getType();
log.error(msg);
throw new InvalidHostException(msg);
}