use of org.platformlayer.ops.OpsTarget in project platformlayer by platformlayer.
the class BackupDirectory method doBackup.
@Handler(BackupAction.class)
public void doBackup() throws OpsException, IOException {
OpsContext opsContext = OpsContext.get();
// Machine machine = opsContext.getInstance(Machine.class);
OpsTarget target = opsContext.getInstance(OpsTarget.class);
BackupContext backup = backups.getContext();
DirectoryBackup request = new DirectoryBackup();
request.target = target;
request.rootDirectory = backupRoot;
request.exclude.addAll(this.excludes);
backup.doBackup(request);
backup.add(new BackupItem(itemKey, FORMAT, request.objectName));
}
use of org.platformlayer.ops.OpsTarget in project platformlayer by platformlayer.
the class RawTargetController method handler.
@Handler
public void handler(RawTarget rawTarget) throws OpsException, IOException {
OpaqueMachine machine = new OpaqueMachine(NetworkPoint.forPublicHostname(rawTarget.host));
SshKey serviceSshKey = service.getSshKey();
OpsTarget target = machine.getTarget(serviceSshKey);
// TODO: We have a bootstrapping problem here!!
PublicKey sshPublicKey = service.getSshKey().getKeyPair().getPublic();
SshAuthorizedKey.ensureSshAuthorization(target, "root", sshPublicKey);
}
use of org.platformlayer.ops.OpsTarget in project platformlayer by platformlayer.
the class ImageStoreController method getImageStore.
@Override
public org.platformlayer.ops.images.ImageStore getImageStore() throws OpsException {
String endpoint = model.getTags().findUnique("endpoint");
if (endpoint == null) {
log.warn("ImageStore not yet active: " + model);
return null;
}
URI url;
try {
url = new URI(endpoint);
} catch (URISyntaxException e) {
throw new OpsException("Cannot parse endpoint: " + endpoint, e);
}
if (url.getScheme().equals("ssh")) {
String myAddress = url.getHost();
Machine machine = new OpaqueMachine(NetworkPoint.forPublicHostname(myAddress));
// This is nasty; we're in the context of another service here...
SshKey sshKey = sshKeys.findOtherServiceKey(new ServiceType("imagestore"));
OpsTarget target = machine.getTarget("imagestore", sshKey.getKeyPair());
DirectImageStore directImageStore = OpsContext.get().getInjector().getInstance(DirectImageStore.class);
directImageStore.connect(target);
return directImageStore;
} else {
throw new OpsException("Unknown protocol for endpoint: " + endpoint);
}
}
use of org.platformlayer.ops.OpsTarget in project platformlayer by platformlayer.
the class MysqlTarget method changePassword.
public void changePassword(Secret newPassword) throws OpsException {
OpsTarget target = getOpsTarget();
Command command = Command.build("mysqladmin");
command.addQuoted("--user=", username);
command.addQuoted("--host=", hostname);
command.addQuoted("--password=", password);
command.addLiteral("password");
command.addQuoted(newPassword);
target.executeCommand(command);
password = newPassword;
}
use of org.platformlayer.ops.OpsTarget in project platformlayer by platformlayer.
the class MysqlTarget method execute.
public ProcessExecution execute(String sql, String maskedSql) throws OpsException {
OpsTarget target = getOpsTarget();
Command command = Command.build("mysql");
command.addQuoted("--user=", username);
command.addQuoted("--host=", hostname);
command.addQuoted("--password=", password);
command.addArgument(Argument.buildQuoted("--execute=", sql).setMasked("--execute=" + Command.MASKED));
return target.executeCommand(command);
}
Aggregations