use of org.platformlayer.ops.OpaqueMachine in project platformlayer by platformlayer.
the class DirectCloudUtils method toTarget.
public OpsTarget toTarget(DirectHost host) throws OpsException {
NetworkPoint address = NetworkPoint.forPublicHostname(host.host);
Machine hostMachine = new OpaqueMachine(address);
OpsTarget hostTarget = hostMachine.getTarget(service.getSshKey());
return hostTarget;
}
use of org.platformlayer.ops.OpaqueMachine in project platformlayer by platformlayer.
the class DirectTarget method doRecurseOperation.
@Override
public void doRecurseOperation() throws OpsException {
Machine machine = new OpaqueMachine(address);
OpsTarget target = machine.getTarget(sshKey);
BindingScope scope = BindingScope.push(machine, target);
try {
OpsContext opsContext = OpsContext.get();
OperationRecursor.doRecurseChildren(opsContext, this);
} finally {
scope.pop();
}
}
use of org.platformlayer.ops.OpaqueMachine 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.OpaqueMachine 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.OpaqueMachine in project platformlayer by platformlayer.
the class DirectHostController method getCasStore.
@Override
public CasStore getCasStore() throws OpsException {
// TODO: Getting the IP like this is evil
NetworkPoint targetAddress;
// if (host.getIpv6() != null) {
// IpRange ipv6Range = IpV6Range.parse(host.getIpv6());
// targetAddress = NetworkPoint.forPublicHostname(ipv6Range.getGatewayAddress());
// } else {
targetAddress = NetworkPoint.forPublicHostname(model.host);
// }
Machine machine = new OpaqueMachine(targetAddress);
OpsTarget machineTarget = machine.getTarget(sshKeys.findOtherServiceKey(new ServiceType("machines-direct")));
CasStoreInfo casStoreOptions = new CasStoreInfo(true);
FilesystemCasStore store = new FilesystemCasStore(casStoreOptions, new OpsCasTarget(machineTarget));
return store;
}
Aggregations