Search in sources :

Example 46 with PlatformLayerKey

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);
    }
}
Also used : Action(org.platformlayer.core.model.Action) PlatformLayerEndpointInfo(org.platformlayer.PlatformLayerEndpointInfo) JobSchedule(org.platformlayer.core.model.JobSchedule) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Handler(org.platformlayer.ops.Handler)

Example 47 with PlatformLayerKey

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"));
}
Also used : PlatformLayerFirewallEntry(org.platformlayer.service.network.ops.PlatformLayerFirewallEntry) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) WordpressService(org.platformlayer.service.wordpress.model.WordpressService) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 48 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class FederatedPlatformLayerClient method mapToChild.

private MappedPlatformLayerKey mapToChild(PlatformLayerKey plk) {
    // if (plk.getHost() != null) {
    //
    // }
    ManagedItemId itemId = plk.getItemId();
    if (itemId == null || itemId.isEmpty()) {
        throw new IllegalArgumentException();
    }
    FederationKey host = plk.getHost();
    if (host == null) {
        host = FederationKey.LOCAL;
    }
    ProjectId project = plk.getProject();
    if (project == null) {
        project = defaultProject;
    // project = federationMap.getLocalClient().getProject();
    }
    ChildClient childClient = getClient(new FederationMapping(host, project));
    MappedPlatformLayerKey mapped = new MappedPlatformLayerKey();
    mapped.child = childClient;
    mapped.key = new PlatformLayerKey(host, project, plk.getServiceType(), plk.getItemType(), plk.getItemId());
    return mapped;
// Iterable<ChildClient> childClients = getChildClients(plk);
// ChildClient client = null;
// for (ChildClient childClient : childClients) {
// if (client == null) {
// client = childClient;
// } else {
// throw new IllegalStateException("Multiple clients found");
// }
// }
// return client;
}
Also used : ProjectId(org.platformlayer.ids.ProjectId) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId) FederationKey(org.platformlayer.ids.FederationKey)

Example 49 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class AddTag method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey resolved = path.resolve(getContext());
    TagChanges tagChanges = new TagChanges();
    Tag tag = Tag.build(tagKey, tagValue);
    tagChanges.addTags.add(tag);
    return client.changeTags(resolved, tagChanges, null);
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Tag(org.platformlayer.core.model.Tag) TagChanges(org.platformlayer.core.model.TagChanges)

Example 50 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class DeleteItem method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    JobData jobData = client.deleteItem(key);
    return jobData;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) JobData(org.platformlayer.jobs.model.JobData)

Aggregations

PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)86 PlatformLayerClient (org.platformlayer.PlatformLayerClient)21 OpsException (org.platformlayer.ops.OpsException)16 ItemBase (org.platformlayer.core.model.ItemBase)14 ManagedItemId (org.platformlayer.ids.ManagedItemId)13 UntypedItem (org.platformlayer.common.UntypedItem)10 ProjectId (org.platformlayer.ids.ProjectId)10 Tag (org.platformlayer.core.model.Tag)8 RepositoryException (org.platformlayer.RepositoryException)7 ServiceType (org.platformlayer.ids.ServiceType)7 JobData (org.platformlayer.jobs.model.JobData)7 InstanceBase (org.platformlayer.core.model.InstanceBase)6 ItemType (org.platformlayer.ids.ItemType)6 OpsTarget (org.platformlayer.ops.OpsTarget)6 JaxbHelper (org.platformlayer.xml.JaxbHelper)6 Handler (org.platformlayer.ops.Handler)5 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)4 UntypedItemXml (org.platformlayer.UntypedItemXml)4 FederationKey (org.platformlayer.ids.FederationKey)4 Machine (org.platformlayer.ops.Machine)4