Search in sources :

Example 1 with NetworkPoint

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

the class HttpProxyHelper method findHttpProxies.

public List<String> findHttpProxies(OpsTarget target, URI uri) throws OpsException {
    List<String> proxies = Lists.newArrayList();
    for (ProviderOf<HttpProxyController> httpProxyProvider : providerHelper.listItemsProviding(HttpProxyController.class)) {
        ItemBase item = httpProxyProvider.getItem();
        if (item.getState() != ManagedItemState.ACTIVE) {
            continue;
        }
        HttpProxyController httpProxy = httpProxyProvider.get();
        NetworkPoint forNetworkPoint = NetworkPoint.forTarget(target);
        String url = httpProxy.getUrl(httpProxyProvider.getItem(), forNetworkPoint, uri);
        if (url == null) {
            log.info("Could not get URL for proxy: " + item);
        } else {
            proxies.add(url);
        }
    }
    return proxies;
}
Also used : ItemBase(org.platformlayer.core.model.ItemBase) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint)

Example 2 with NetworkPoint

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

the class ZookeeperInstanceModel method getCluster.

public Cluster getCluster() throws OpsException {
    Cluster cluster = new Cluster();
    for (ZookeeperServer server : getClusterServers()) {
        // TODO: Do keys need to be sequential
        ClusterServer model = new ClusterServer();
        model.key = server.clusterId;
        // TODO: What do we do about machines that don't yet have an ip?
        NetworkPoint targetNetworkPoint = NetworkPoint.forPublicInternet();
        Machine sourceMachine = instances.getMachine(server);
        String address = sourceMachine.getNetworkPoint().getBestAddress(targetNetworkPoint);
        model.ip = address;
        model.dnsName = ZookeeperUtils.buildDnsName(server);
        cluster.servers.add(model);
    }
    return cluster;
}
Also used : ZookeeperServer(org.platformlayer.service.zookeeper.model.ZookeeperServer) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine)

Example 3 with NetworkPoint

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

the class DirectCloudUtils method toTarget.

public OpsTarget toTarget(DirectHost host) throws OpsException {
    NetworkPoint address = NetworkPoint.forPublicHostname(host.host);
    Machine hostMachine = new OpaqueMachine(address);
    OpsTarget hostTarget = hostMachine.getTarget(service.getSshKey());
    return hostTarget;
}
Also used : OpsTarget(org.platformlayer.ops.OpsTarget) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine) OpaqueMachine(org.platformlayer.ops.OpaqueMachine)

Example 4 with NetworkPoint

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

the class AptCacheServiceController method getUrl.

@Override
public String getUrl(Object modelObject, NetworkPoint forNetworkPoint, URI uri) throws OpsException {
    AptCacheService model = (AptCacheService) modelObject;
    if (model.getState() != ManagedItemState.ACTIVE) {
        log.info("Cache not active; returning null URL");
        return null;
    }
    // {
    // // By DNS
    // String dnsName = aptCacheService.getDnsName();
    // String address = "http://" + dnsName + ":3128/";
    // proxies.add(address);
    // }
    //
    // {
    // By IP
    NetworkPoint networkPoint = network.findNetworkPoint(model);
    if (networkPoint == null) {
        log.info("Machine not found for cache; returning null URL");
        return null;
    }
    String address = "http://" + networkPoint.getBestAddress(forNetworkPoint) + ":3128/";
    return address;
}
Also used : AptCacheService(org.platformlayer.service.aptcache.model.AptCacheService) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint)

Example 5 with NetworkPoint

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

the class DiskImageController method waitForAddress.

private Machine waitForAddress(final Machine machine) throws OpsException {
    try {
        final NetworkPoint myNetworkPoint = NetworkPoint.forMe();
        List<InetAddress> addresses = machine.getNetworkPoint().findAddresses(myNetworkPoint);
        if (!addresses.isEmpty()) {
            return machine;
        }
        return TimeoutPoll.poll(TimeSpan.FIVE_MINUTES, TimeSpan.TEN_SECONDS, new PollFunction<Machine>() {

            @Override
            public Machine call() throws Exception {
                Machine refreshed = cloud.refreshMachine(machine);
                List<InetAddress> addresses = refreshed.getNetworkPoint().findAddresses(myNetworkPoint);
                if (!addresses.isEmpty()) {
                    return refreshed;
                }
                return null;
            }
        });
    } catch (ExecutionException e) {
        throw new OpsException("Error while waiting for address", e);
    } catch (TimeoutException e) {
        throw new OpsException("Timeout while waiting for address", e);
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) List(java.util.List) ProcessExecutionException(org.platformlayer.ops.process.ProcessExecutionException) ExecutionException(java.util.concurrent.ExecutionException) InetAddress(java.net.InetAddress) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine) TimeoutException(java.util.concurrent.TimeoutException) ProcessExecutionException(org.platformlayer.ops.process.ProcessExecutionException) OpsException(org.platformlayer.ops.OpsException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

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