Search in sources :

Example 11 with Handler

use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.

the class GitCheckout method handler.

@Handler
public void handler(OpsTarget target) throws OpsException {
    if (OpsContext.isConfigure()) {
        if (target.getFilesystemInfoFile(targetDir) != null) {
            log.warn("Directory already exists; skipping clone (should we update?)");
        } else {
            File checkoutDir = targetDir.getParentFile();
            Command command = Command.build("cd {0}; git clone {1}", checkoutDir, source);
            command.setTimeout(TimeSpan.FIVE_MINUTES);
            target.executeCommand(command);
        }
    }
}
Also used : Command(org.platformlayer.ops.Command) File(java.io.File) Handler(org.platformlayer.ops.Handler)

Example 12 with Handler

use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.

the class MysqlServerBootstrap method handler.

@Handler
public void handler() throws OpsException {
    MysqlServer model = OpsContext.get().getInstance(MysqlServer.class);
    MysqlTarget mysql = new MysqlTarget("localhost", "root", model.rootPassword);
    if (!mysql.canLogin()) {
        mysql = new MysqlTarget("localhost", "root", MysqlServerController.DEFAULT_BOOTSTRAP_PASSWORD);
        // Clean up the users table
        mysql.execute("delete from mysql.user where user='';");
        mysql.execute("update mysql.user set host='%' where user='root' and host='localhost';");
        mysql.execute("delete from mysql.user where user='root' and host<>'%';");
        mysql.execute("flush privileges;");
        mysql.changePassword(model.rootPassword);
    }
}
Also used : MysqlServer(org.platformlayer.service.mysql.model.MysqlServer) Handler(org.platformlayer.ops.Handler)

Example 13 with Handler

use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.

the class GreTunnel method handler.

@Handler
public void handler(OpsTarget target) throws OpsException {
    // ip tunnel add netb mode gre remote 184.173.172.26 local 209.105.243.38 ttl 255
    Command addTunnel = Command.build("ip tunnel add {0} mode gre remote {1} local {2} ttl 255", tunnelName, remoteTunnelAddress, localTunnelAddress);
    target.executeCommand(addTunnel);
    // ip addr add fdfd:fdfd:fdfd:1::/64 dev netb
    Command tunnelAddAddress = Command.build("ip addr add {0} dev {1}", localPrivateAddress, tunnelName);
    target.executeCommand(tunnelAddAddress);
    // ip route add fdfd:fdfd:fdfd:1::/64 dev netb
    Command tunnelAddRoute = Command.build("ip route add {0} dev {1}", remotePrivateNetwork, tunnelName);
    target.executeCommand(tunnelAddRoute);
    Command tunnelUp = Command.build("ip link set {0} up", tunnelName);
    target.executeCommand(tunnelUp);
}
Also used : Command(org.platformlayer.ops.Command) Handler(org.platformlayer.ops.Handler)

Example 14 with Handler

use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.

the class DnsServerBootstrap method handler.

@Handler
public void handler(OpsTarget target) throws OpsException {
    for (DnsZone record : platformLayer.listItems(DnsZone.class)) {
        ZoneFile dnsFile = dns.buildDnsFile(record);
        dns.upload(target, dnsFile);
    }
}
Also used : DnsZone(org.platformlayer.service.dns.model.DnsZone) Handler(org.platformlayer.ops.Handler)

Example 15 with Handler

use of org.platformlayer.ops.Handler in project platformlayer by platformlayer.

the class GerritBootstrap method handler.

@Handler
public void handler(OpsTarget target) throws OpsException, IOException {
    File canary = new File(template.getDataDir(), "bin/gerrit.sh");
    if (target.getFilesystemInfoFile(canary) == null) {
        if (OpsContext.isConfigure()) {
            File dataDir = template.getDataDir();
            Command command = Command.build("java");
            command.addLiteral("-jar").addFile(template.getInstallWarFile());
            command.addLiteral("init");
            command.addLiteral("--no-auto-start");
            command.addLiteral("--batch");
            command.addLiteral("-d").addFile(dataDir);
            target.executeCommand(command);
        }
    }
// DROP TABLE contributor_agreements;
// DROP TABLE account_agreements;
// DROP TABLE account_group_agreements;
// ALTER TABLE accounts DROP COLUMN display_patch_sets_in_reverse_order;
// ALTER TABLE accounts DROP COLUMN display_person_name_in_review_category;
// ALTER TABLE tracking_ids DROP COLUMN tracking_id;
// ALTER TABLE account_groups DROP COLUMN owner_group_id;
// ALTER TABLE account_groups DROP COLUMN external_name;
}
Also used : Command(org.platformlayer.ops.Command) File(java.io.File) Handler(org.platformlayer.ops.Handler)

Aggregations

Handler (org.platformlayer.ops.Handler)58 File (java.io.File)21 Command (org.platformlayer.ops.Command)17 OpsException (org.platformlayer.ops.OpsException)17 OpsTarget (org.platformlayer.ops.OpsTarget)17 Tag (org.platformlayer.core.model.Tag)8 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)5 SshKey (org.platformlayer.ops.helpers.SshKey)5 Machine (org.platformlayer.ops.Machine)4 PublicKey (java.security.PublicKey)3 Action (org.platformlayer.core.model.Action)3 EndpointInfo (org.platformlayer.core.model.EndpointInfo)3 ItemBase (org.platformlayer.core.model.ItemBase)3 Tags (org.platformlayer.core.model.Tags)3 MachineCreationRequest (org.platformlayer.ops.MachineCreationRequest)3 Map (java.util.Map)2 OpenstackComputeClient (org.openstack.client.common.OpenstackComputeClient)2 SecurityGroup (org.openstack.model.compute.SecurityGroup)2 Server (org.openstack.model.compute.Server)2 PlatformLayerClientException (org.platformlayer.PlatformLayerClientException)2