use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class PlatformLayerTestContext method cleanup.
public void cleanup() throws IOException, OpsException {
while (!ownedItems.isEmpty()) {
ItemBase item = ownedItems.remove(ownedItems.size() - 1);
JobData deleteJob = deleteItem(item);
System.out.println("Deleted " + item.getKey() + " jobId=" + deleteJob.getJobId());
waitForDeleted(item);
}
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class LinkHelpers method buildLinkTargetProperties.
// public InetAddressChooser inetAddressChooser = InetAddressChooser.preferIpv6();
public Map<String, String> buildLinkTargetProperties(LinkConsumer consumer, List<Link> links) throws OpsException {
Map<String, String> config = Maps.newHashMap();
if (links != null) {
for (Link link : links) {
ItemBase item = platformLayer.getItem(link.getTarget());
LinkTarget linkTarget = providers.toInterface(item, LinkTarget.class);
Map<String, String> linkTargetConfig = buildLinkTargetConfiguration(consumer, link.name, linkTarget);
config.putAll(linkTargetConfig);
}
}
return config;
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class IpsecInstall method addChildren.
@Override
protected void addChildren() throws OpsException {
addChild(PackageDependency.build("racoon"));
addChild(SimpleFile.build(getClass(), new File("/etc/racoon/racoon.conf")));
// addChild(SimpleFile.build(getClass(), new File("/etc/racoon/psk.txt")));
addChild(SimpleFile.build(getClass(), new File("/etc/ipsec-tools.conf")));
addChild(IpsecBootstrap.class);
ItemBase model = OpsContext.get().getInstance(ItemBase.class);
String uuid = platformLayerClient.getOrCreateUuid(model).toString();
// TODO: Rationalize between our complicated version that can open cloud ports, and this streamlined version
for (Transport transport : Transport.all()) {
{
IptablesFilterEntry allowIKE = addChild(IptablesFilterEntry.class);
allowIKE.port = 500;
allowIKE.protocol = Protocol.Udp;
allowIKE.ruleKey = transport.getKey() + "-ike-" + uuid;
allowIKE.transport = transport;
}
{
// TODO: Do we want to open NAT-T (4500?)
IptablesFilterEntry allowEsp = addChild(IptablesFilterEntry.class);
allowEsp.protocol = Protocol.Esp;
allowEsp.ruleKey = transport.getKey() + "-esp-" + uuid;
allowEsp.transport = transport;
}
// AH iptables allow doesn't seem to work
// AllowProtocol allowAh = addChild(AllowProtocol.class);
// allowAh.protocol = Protocol.Ah;
// allowAh.uuid = "ah-" + uuid;
{
IptablesFilterPolicy allowPolicy = addChild(IptablesFilterPolicy.class);
allowPolicy.direction = Direction.In;
allowPolicy.policy = "ipsec";
allowPolicy.ruleKey = transport.getKey() + "-ipsec-" + uuid;
allowPolicy.transport = transport;
}
}
addChild(ManagedService.build("racoon"));
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class ForEach method processDataItems.
private boolean processDataItems(Object controller, List<ItemBase> dataItems, ItemBase machineItem, Machine machine, OpsTarget target) {
boolean failed = false;
for (ItemBase dataItem : dataItems) {
try {
// Execute the children in a scope
BindingScope scope = BindingScope.push(machine, target, machineItem, dataItem);
try {
OpsContext opsContext = OpsContext.get();
OperationRecursor.doRecurseChildren(opsContext, controller);
} finally {
scope.pop();
}
} catch (OpsException e) {
failed = true;
log.warn("Error updating machine: " + machine + " with item " + dataItem, e);
}
}
return failed;
}
use of org.platformlayer.core.model.ItemBase in project platformlayer by platformlayer.
the class TagFromChildren method handler.
@Handler
public void handler() throws OpsException {
if (OpsContext.isConfigure()) {
for (OwnedItem<?> childServer : parentController.getChildren(OwnedItem.class)) {
ItemBase server = childServer.getItem();
if (server == null) {
// Right now, we have to go through a retry cycle
throw new OpsException("Child server not ready");
}
List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(server.getTags(), port);
if (endpoints.isEmpty()) {
// TODO: Cope in future e.g. if we only need one of two in a cluster
throw new OpsException("Child server not ready");
}
for (EndpointInfo endpoint : endpoints) {
platformLayer.addTag(parentItem.getKey(), endpoint.toTag());
}
}
}
}
Aggregations