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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations