Search in sources :

Example 46 with Command

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

the class DirectImageStore method bringToMachine.

@Override
public void bringToMachine(String imageId, OpsTarget destination, File destinationPath) throws OpsException {
    Properties imageProperties = fileStore.readProperties(imageId);
    if (imageProperties == null) {
        throw new OpsException("Image not found: " + imageId);
    }
    File imageFile = getImageFile(imageId, imageProperties);
    if (destination.isSameMachine(target)) {
        Command copyCommand = Command.build("cp {0} {1}", imageFile, destinationPath);
        destination.executeCommand(copyCommand.setTimeout(TimeSpan.FIVE_MINUTES));
    } else {
        PeerToPeerCopy peerToPeerCopy = Injection.getInstance(PeerToPeerCopy.class);
        peerToPeerCopy.copy(target, imageFile, destination, destinationPath);
    // throw new OpsException("SCPing images between machines not yet implemented");
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) Command(org.platformlayer.ops.Command) Properties(java.util.Properties) File(java.io.File)

Example 47 with Command

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

the class AptPackageManager method update.

public void update(OpsTarget target, boolean force) throws OpsException {
    if (!force && !isUpdateNeeded(target)) {
        log.info("apt-get update not needed; won't update");
        return;
    }
    log.info("Updating apt repositories");
    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);
    Command command = Command.build("apt-get --yes update");
    command = command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES);
    executeAptCommand(target, command);
    flushCache(target);
}
Also used : Command(org.platformlayer.ops.Command) CommandEnvironment(org.platformlayer.ops.CommandEnvironment)

Example 48 with Command

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

the class AptPackageManager method upgrade.

public void upgrade(OpsTarget target) throws OpsException {
    CommandEnvironment commandEnvironment = buildEnvironmentWithProxy(target);
    Command command = Command.build("apt-get --yes upgrade");
    target.executeCommand(command.setEnvironment(commandEnvironment).setTimeout(TimeSpan.TEN_MINUTES));
    flushCache(target);
}
Also used : Command(org.platformlayer.ops.Command) CommandEnvironment(org.platformlayer.ops.CommandEnvironment)

Example 49 with Command

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

the class AptPackageManager method addRepositoryKeyUrl.

public void addRepositoryKeyUrl(OpsTarget target, String url) throws OpsException {
    Command command = Command.build("wget -q -O - {0} | apt-key add -", url);
    target.executeCommand(command);
    flushCache(target);
}
Also used : Command(org.platformlayer.ops.Command)

Example 50 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)

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