Search in sources :

Example 71 with Command

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

the class UpdatePackages method handler.

@Handler
public void handler(OpsTarget target) throws OpsException {
    apt.update(target, true);
    List<String> outOfDatePackage = apt.findOutOfDatePackages(target);
    if (!outOfDatePackage.isEmpty()) {
        // Pre-download any out-of-date files; will make any maintenance window smaller
        Command command = Command.build("apt-get --yes --download-only dist-upgrade");
        target.executeCommand(command);
    }
    Deviations.assertEquals(Collections.emptyList(), outOfDatePackage, "Packaged out of date");
}
Also used : Command(org.platformlayer.ops.Command) Handler(org.platformlayer.ops.Handler)

Example 72 with Command

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

the class ZookeeperUtils method sendCommand.

public static ZookeeperResponse sendCommand(OpsTarget target, InetSocketAddress socketAddress, String zkCommand) throws OpsException {
    Command command = Command.build("echo {0} | nc {1} {2}", zkCommand, socketAddress.getAddress().getHostAddress(), socketAddress.getPort());
    ProcessExecution execution = target.executeCommand(command);
    return new ZookeeperResponse(execution.getStdOut());
}
Also used : Command(org.platformlayer.ops.Command) ProcessExecution(org.platformlayer.ops.process.ProcessExecution)

Aggregations

Command (org.platformlayer.ops.Command)72 File (java.io.File)21 Handler (org.platformlayer.ops.Handler)17 OpsException (org.platformlayer.ops.OpsException)16 ProcessExecution (org.platformlayer.ops.process.ProcessExecution)16 CommandEnvironment (org.platformlayer.ops.CommandEnvironment)11 OpsTarget (org.platformlayer.ops.OpsTarget)9 InetAddress (java.net.InetAddress)4 CurlRequest (org.platformlayer.ops.helpers.CurlRequest)4 Md5Hash (com.fathomdb.hash.Md5Hash)3 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)3 Map (java.util.Map)3 FilesystemInfo (org.platformlayer.ops.filesystem.FilesystemInfo)3 ImageFormat (org.platformlayer.ops.images.ImageFormat)3 List (java.util.List)2 Properties (java.util.Properties)2 RequestBuilder (org.openstack.client.common.RequestBuilder)2 AddressModel (org.platformlayer.core.model.AddressModel)2 Tag (org.platformlayer.core.model.Tag)2