use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class PlatformLayerCloudHelpers method findMachines.
public List<InstanceBase> findMachines(Tag tag) throws OpsException {
if (!Objects.equal(tag.getKey(), Tag.PARENT.getKey())) {
throw new IllegalArgumentException();
}
List<InstanceBase> machines = Lists.newArrayList();
boolean showDeleted = false;
PlatformLayerKey parent = PlatformLayerKey.parse(tag.getValue());
for (ItemBase item : platformLayer.listChildrenTyped(parent, showDeleted)) {
if (item instanceof InstanceBase) {
machines.add((InstanceBase) item);
}
}
return machines;
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class ScheduleController method handler.
@Handler
public void handler() throws OpsException {
if (OpsContext.isConfigure()) {
String key = model.getKey().getUrl();
PlatformLayerKey target = model.targetItem;
PlatformLayerEndpointInfo endpoint = platformLayer.getEndpointInfo(target);
JobSchedule schedule = model.schedule;
Action action = model.action;
actionScheduler.putJob(key, endpoint, schedule, target, action);
}
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class WordpressServiceController method addChildren.
@Override
protected void addChildren() throws OpsException {
WordpressService model = OpsContext.get().getInstance(WordpressService.class);
InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
// instance.minimumMemoryMb = 2048;
addChild(instance);
instance.addChild(PackageDependency.build("wordpress"));
instance.addChild(ApacheBootstrap.build());
{
PlatformLayerFirewallEntry net = injected(PlatformLayerFirewallEntry.class);
net.destItem = model.databaseItem;
net.port = 3306;
net.uniqueId = getFirewallUniqueId();
PlatformLayerKey sourceKey = model.getKey();
net.sourceItemKey = sourceKey;
instance.addChild(net);
}
WordpressTemplateData templateData = Injection.getInstance(WordpressTemplateData.class);
MysqlConnection mysql = instance.addChild(MysqlConnection.build(model.databaseItem));
mysql.password = model.databasePassword;
{
MysqlDatabase db = injected(MysqlDatabase.class);
db.databaseName = templateData.getDatabaseName();
mysql.addChild(db);
}
{
MysqlUser db = injected(MysqlUser.class);
db.databaseName = templateData.getDatabaseName();
db.databaseUser = templateData.getDatabaseUser();
db.databasePassword = templateData.getDatabasePassword();
mysql.addChild(db);
}
instance.addChild(WordpressBootstrap.build());
instance.addChild(WordpressAdminUser.build());
instance.addChild(WordpressApacheSite.build());
// instance.addChild(CollectdCollector.build());
// TODO: How do we bring up wordpress securely??
// We don't have the tables until we run install.php
// Maybe we could POST to the install.php form
{
PublicEndpoint endpoint = injected(PublicEndpoint.class);
// endpoint.network = null;
endpoint.publicPort = 80;
endpoint.backendPort = 80;
// We expect nginx to front-end us, so we don't put the dnsName
// endpoint.dnsName = model.dnsName;
endpoint.tagItem = model.getKey();
endpoint.parentItem = model.getKey();
instance.addChild(endpoint);
}
instance.addChild(ManagedService.build("apache2"));
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class FederatedPlatformLayerClient method listItems.
@Override
public <T> List<T> listItems(final Class<T> clazz) throws PlatformLayerClientException {
JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(clazz, ManagedItemCollection.class);
PlatformLayerKey path = PlatformLayerClientBase.toKey(jaxbHelper, null, listServices(true));
return doListConcatenationTyped(getChildClients(path), AddHostTyped.wrap(new ListItemsTyped<T>(clazz)));
}
use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.
the class FederatedPlatformLayerClient method mapToChildForCreate.
private MappedPlatformLayerKey mapToChildForCreate(PlatformLayerKey plk) {
if (plk.getItemId() != null) {
throw new IllegalArgumentException();
}
FederationMapping childKey = federationMap.getClientForCreate(plk);
ManagedItemId childItemId;
ChildClient childClient = getClient(childKey);
childItemId = null;
MappedPlatformLayerKey mapped = new MappedPlatformLayerKey();
mapped.child = childClient;
mapped.key = new PlatformLayerKey(childKey.host, childKey.project, plk.getServiceType(), plk.getItemType(), childItemId);
return mapped;
}
Aggregations