use of org.platformlayer.ops.images.direct.DirectImageStore 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);
}
}
Aggregations