Search in sources :

Example 11 with NetworkPoint

use of org.platformlayer.ops.networks.NetworkPoint in project platformlayer by platformlayer.

the class CollectdModelBuilder method getCollectdServer.

@Deprecated
public String getCollectdServer() throws OpsException {
    Iterable<CollectdService> collectdServices = platformLayer.listItems(CollectdService.class);
    for (CollectdService collectdService : collectdServices) {
        // TODO: Use DNS name when it works
        NetworkPoint target = network.getNetworkPoint(collectdService);
        if (target != null) {
            NetworkPoint targetNetworkPoint = NetworkPoint.forTargetInContext();
            InetAddress address = target.findBestAddress(targetNetworkPoint, InetAddressChooser.preferIpv6());
            if (address != null) {
                return address.getHostAddress();
            }
        }
    }
    log.warn("Unable to find collectd server; defaulting to 127.0.0.1");
    return "127.0.0.1";
}
Also used : InetAddress(java.net.InetAddress) CollectdService(org.platformlayer.service.collectd.model.CollectdService) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint)

Aggregations

NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)11 Machine (org.platformlayer.ops.Machine)6 ItemBase (org.platformlayer.core.model.ItemBase)3 InetAddress (java.net.InetAddress)2 List (java.util.List)2 InetAddressChooser (org.platformlayer.InetAddressChooser)2 OpaqueMachine (org.platformlayer.ops.OpaqueMachine)2 OpsException (org.platformlayer.ops.OpsException)2 OpsTarget (org.platformlayer.ops.OpsTarget)2 SimpleLinkConsumer (org.platformlayer.ops.uses.SimpleLinkConsumer)2 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 CasStoreInfo (org.platformlayer.cas.CasStoreInfo)1 Link (org.platformlayer.core.model.Link)1 ServiceType (org.platformlayer.ids.ServiceType)1 OpsCasTarget (org.platformlayer.ops.cas.OpsCasTarget)1 FilesystemCasStore (org.platformlayer.ops.cas.filesystem.FilesystemCasStore)1 Transport (org.platformlayer.ops.firewall.Transport)1 IptablesFilterEntry (org.platformlayer.ops.firewall.scripts.IptablesFilterEntry)1