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");
}
}
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);
}
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);
}
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);
}
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");
}
Aggregations