use of org.platformlayer.ops.packages.AsBlock in project platformlayer by platformlayer.
the class DnsResolverModuleBuilder method buildTemplateModel.
@Override
public void buildTemplateModel(Map<String, Object> model) throws OpsException {
List<String> nameservers = Lists.newArrayList();
for (ProviderOf<DnsResolverProvider> entry : providers.listItemsProviding(DnsResolverProvider.class)) {
DnsResolverProvider dnsResolverProvider = entry.get();
List<InetAddress> addresses = dnsResolverProvider.findAddresses(NetworkPoint.forTargetInContext());
for (InetAddress address : addresses) {
nameservers.add(address.getHostAddress());
}
}
if (nameservers.isEmpty()) {
log.warn("No (internal) resolvers found; will set up default public nameservers; reconfigure needed if this changes");
if (usePrivateResolvers) {
OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
AsBlock as = AsBlock.find(target);
if (as != null) {
// We had problems with the SL resolvers...
/*
* if (Objects.equal(AsBlock.SOFTLAYER, as)) { log.warn("Adding private Softlayer resolvers");
* nameservers.add("10.0.80.11"); nameservers.add("10.0.80.12"); }
*
* if (Objects.equal(AsBlock.HETZNER, as)) { log.warn("Adding private Hetzner resolvers");
* nameservers.add("213.133.99.99"); nameservers.add("213.133.100.100");
* nameservers.add("213.133.98.98"); }
*/
}
}
nameservers.add("8.8.8.8");
nameservers.add("8.8.4.4");
nameservers.add("2001:4860:4860::8888");
nameservers.add("2001:4860:4860::8844");
// So a reconfigure is needed!
}
model.put("nameservers", nameservers);
}
use of org.platformlayer.ops.packages.AsBlock in project platformlayer by platformlayer.
the class NetworkPoint method estimateDistance.
public static int estimateDistance(NetworkPoint a, NetworkPoint b) {
if (a.equals(b)) {
return 0;
}
if (a.isPublicAddress() != b.isPublicAddress()) {
// TODO: This is a poor metric. Our metric isn't really rich enough here
return 8;
}
AsBlock asA = AsBlock.find(a.getAddress());
AsBlock asB = AsBlock.find(b.getAddress());
if (asA != null && asB != null) {
if (asA.equals(asB)) {
return 1;
}
if (Objects.equal(asA.getCountry(), asB.getCountry())) {
return 2;
}
}
return 4;
}
Aggregations