use of org.platformlayer.service.aptcache.model.AptCacheService 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.service.aptcache.model.AptCacheService in project platformlayer by platformlayer.
the class AptCacheServiceController method addChildren.
@Override
protected void addChildren() throws OpsException {
AptCacheService model = OpsContext.get().getInstance(AptCacheService.class);
// TODO: Create endpoint with default port; maybe default to closed?
// model.dnsName
InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
instance.hostPolicy.allowRunInContainer = true;
addChild(instance);
instance.addChild(PackageDependency.build("squid3"));
instance.addChild(SimpleFile.build(getClass(), new File("/etc/squid3/squid.conf")));
instance.addChild(ManagedService.build("squid3"));
// instance.addChild(CollectdCollector.build());
{
PublicEndpoint endpoint = injected(PublicEndpoint.class);
endpoint.publicPort = PORT;
endpoint.backendPort = PORT;
endpoint.dnsName = model.dnsName;
endpoint.tagItem = model.getKey();
endpoint.parentItem = model.getKey();
instance.addChild(endpoint);
}
}
use of org.platformlayer.service.aptcache.model.AptCacheService in project platformlayer by platformlayer.
the class ITAptCacheService method testCreateAndDeleteItem.
@Test
public void testCreateAndDeleteItem() throws Exception {
String id = random.randomAlphanumericString(8);
AptCacheService aptCache = new AptCacheService();
aptCache.dnsName = id + ".test.platformlayer.org";
aptCache = putItem(id, aptCache);
aptCache = waitForHealthy(aptCache);
InetSocketAddress socketAddress = getUniqueEndpoint(aptCache);
Assert.assertFalse(isPortOpen(socketAddress));
openFirewall(aptCache, AptCacheServiceController.PORT);
Assert.assertTrue(isPortOpen(socketAddress));
// TODO: Make endpoint http://<ip>:<port>/ ???
// String httpUrl = "http://" + socketAddress.getAddress().getHostAddress() + ":" + socketAddress.getPort();
String html = testProxy(socketAddress, "http://www.google.com/");
Assert.assertTrue(html.contains("Search the world"));
deleteItem(aptCache);
}
Aggregations