Search in sources :

Example 1 with KvmInstance

use of org.platformlayer.service.cloud.direct.ops.kvm.KvmInstance in project platformlayer by platformlayer.

the class DirectInstanceController method addChildren.

@Override
protected void addChildren() throws OpsException {
    HostPolicy hostPolicy = model.hostPolicy;
    if (hostPolicy == null) {
        hostPolicy = new HostPolicy();
    }
    if (hostPolicy.allowRunInContainer) {
        // TODO: The variable initialization probably doesn't belong here
        LxcInstanceController lxc = injected(LxcInstanceController.class);
        String id = model.getId();
        lxc.id = id;
        lxc.instanceDir = new File(DirectCloudUtils.LXC_BASE_DIR, id);
        lxc.minimumMemoryMB = model.minimumMemoryMb;
        addChild(lxc);
        if (model.publicPorts != null) {
            log.info("Ignoring model.publicPorts: " + model.publicPorts);
        // for (int publicPort : model.publicPorts) {
        // PublicPorts publicPortForward = injected(PublicPorts.class);
        // publicPortForward.publicPort = publicPort;
        // publicPortForward.backendPort = publicPort;
        // publicPortForward.backendItem = model;
        // lxc.addChild(publicPortForward);
        // }
        }
    } else {
        // TODO: The variable initialization probably doesn't belong here
        KvmInstance kvm = injected(KvmInstance.class);
        String id = model.getId();
        kvm.id = id;
        kvm.instanceDir = new File(DirectCloudUtils.KVM_BASE_DIR, id);
        kvm.owner = model.getKey();
        kvm.minimumMemoryMB = model.minimumMemoryMb;
        kvm.recipeId = model.recipeId;
        try {
            kvm.sshPublicKey = OpenSshUtils.readSshPublicKey(model.sshPublicKey);
        } catch (IOException e) {
            throw new OpsException("Error deserializing SSH key", e);
        }
        addChild(kvm);
        // TODO: Remove this... it's only supposed to be a hint
        if (model.publicPorts != null) {
            for (int publicPort : model.publicPorts) {
                throw new UnsupportedOperationException();
            //
            // PublicPorts publicPortForward = injected(PublicPorts.class);
            // publicPortForward.publicPort = publicPort;
            // publicPortForward.backendItem = model;
            // kvm.addChild(publicPortForward);
            }
        }
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) KvmInstance(org.platformlayer.service.cloud.direct.ops.kvm.KvmInstance) HostPolicy(org.platformlayer.core.model.HostPolicy) IOException(java.io.IOException) File(java.io.File) LxcInstanceController(org.platformlayer.service.cloud.direct.ops.lxc.LxcInstanceController)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 HostPolicy (org.platformlayer.core.model.HostPolicy)1 OpsException (org.platformlayer.ops.OpsException)1 KvmInstance (org.platformlayer.service.cloud.direct.ops.kvm.KvmInstance)1 LxcInstanceController (org.platformlayer.service.cloud.direct.ops.lxc.LxcInstanceController)1