Search in sources :

Example 1 with OpaqueMachine

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;
}
Also used : OpsTarget(org.platformlayer.ops.OpsTarget) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine) OpaqueMachine(org.platformlayer.ops.OpaqueMachine)

Example 2 with OpaqueMachine

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();
    }
}
Also used : OpsTarget(org.platformlayer.ops.OpsTarget) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) OpsContext(org.platformlayer.ops.OpsContext) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) Machine(org.platformlayer.ops.Machine) BindingScope(org.platformlayer.ops.BindingScope)

Example 3 with OpaqueMachine

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);
}
Also used : SshKey(org.platformlayer.ops.helpers.SshKey) OpsTarget(org.platformlayer.ops.OpsTarget) PublicKey(java.security.PublicKey) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) Handler(org.platformlayer.ops.Handler)

Example 4 with OpaqueMachine

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);
    }
}
Also used : SshKey(org.platformlayer.ops.helpers.SshKey) OpsException(org.platformlayer.ops.OpsException) OpsTarget(org.platformlayer.ops.OpsTarget) ServiceType(org.platformlayer.ids.ServiceType) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Machine(org.platformlayer.ops.Machine) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) DirectImageStore(org.platformlayer.ops.images.direct.DirectImageStore)

Example 5 with OpaqueMachine

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;
}
Also used : CasStoreInfo(org.platformlayer.cas.CasStoreInfo) OpsTarget(org.platformlayer.ops.OpsTarget) FilesystemCasStore(org.platformlayer.ops.cas.filesystem.FilesystemCasStore) ServiceType(org.platformlayer.ids.ServiceType) OpaqueMachine(org.platformlayer.ops.OpaqueMachine) OpsCasTarget(org.platformlayer.ops.cas.OpsCasTarget) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint) Machine(org.platformlayer.ops.Machine) OpaqueMachine(org.platformlayer.ops.OpaqueMachine)

Aggregations

OpaqueMachine (org.platformlayer.ops.OpaqueMachine)6 OpsTarget (org.platformlayer.ops.OpsTarget)6 Machine (org.platformlayer.ops.Machine)4 SshKey (org.platformlayer.ops.helpers.SshKey)3 PublicKey (java.security.PublicKey)2 ServiceType (org.platformlayer.ids.ServiceType)2 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 CasStoreInfo (org.platformlayer.cas.CasStoreInfo)1 BindingScope (org.platformlayer.ops.BindingScope)1 Handler (org.platformlayer.ops.Handler)1 OpsContext (org.platformlayer.ops.OpsContext)1 OpsException (org.platformlayer.ops.OpsException)1 OpsCasTarget (org.platformlayer.ops.cas.OpsCasTarget)1 FilesystemCasStore (org.platformlayer.ops.cas.filesystem.FilesystemCasStore)1 DirectImageStore (org.platformlayer.ops.images.direct.DirectImageStore)1