Search in sources :

Example 1 with OpenstackInstance

use of org.platformlayer.service.cloud.openstack.model.OpenstackInstance in project platformlayer by platformlayer.

the class OpenstackInstanceController method addChildren.

@Override
protected void addChildren() throws OpsException {
    final OpenstackInstance model = OpsContext.get().getInstance(OpenstackInstance.class);
    CloudInstanceMapper instance;
    {
        instance = injected(CloudInstanceMapper.class);
        instance.instance = model;
        addChild(instance);
    }
    {
        OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {

            @Override
            public TagChanges get() {
                OpenstackComputeMachine machine = OpsContext.get().getInstance(OpenstackComputeMachine.class);
                TagChanges tagChanges = new TagChanges();
                tagChanges.addTags.add(Tag.INSTANCE_KEY.build(model.getKey()));
                tagChanges.addTags.addAll(machine.buildAddressTags());
                return tagChanges;
            }
        };
        instance.addChild(Tagger.build(model, tagChanges));
    }
// Note: We can't bootstrap an instance, because we can't log in to it,
// because the public key is not our service's public key
// if (model.publicPorts != null) {
// for (int publicPort : model.publicPorts) {
// PublicPorts publicPortForward = injected(PublicPorts.class);
// publicPortForward.port = publicPort;
// publicPortForward.backendItem = model;
// kvm.addChild(publicPortForward);
// }
// }
}
Also used : OpsProvider(org.platformlayer.ops.OpsProvider) OpenstackInstance(org.platformlayer.service.cloud.openstack.model.OpenstackInstance) TagChanges(org.platformlayer.core.model.TagChanges) OpenstackComputeMachine(org.platformlayer.service.cloud.openstack.ops.openstack.OpenstackComputeMachine)

Example 2 with OpenstackInstance

use of org.platformlayer.service.cloud.openstack.model.OpenstackInstance in project platformlayer by platformlayer.

the class OpenstackPublicEndpointController method addChildren.

// @Inject
// ImageFactory imageFactory;
//
@Override
protected void addChildren() throws OpsException {
    final OpenstackPublicEndpoint model = OpsContext.get().getInstance(OpenstackPublicEndpoint.class);
    OpenstackInstance instance = client.getItem(model.instance, OpenstackInstance.class);
    CloudInstanceMapper instanceMapper;
    {
        instanceMapper = injected(CloudInstanceMapper.class);
        instanceMapper.instance = instance;
        addChild(instanceMapper);
    }
    final EnsureFirewallIngress ingress;
    {
        ingress = injected(EnsureFirewallIngress.class);
        ingress.model = model;
        instanceMapper.addChild(ingress);
    }
    {
        OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {

            @Override
            public TagChanges get() {
                TagChanges tagChanges = new TagChanges();
                String address = ingress.getPublicAddress();
                if (Strings.isNullOrEmpty(address)) {
                    throw new IllegalStateException();
                }
                EndpointInfo endpoint = new EndpointInfo(address, model.publicPort);
                tagChanges.addTags.add(endpoint.toTag());
                return tagChanges;
            }
        };
        Tagger tagger = injected(Tagger.class);
        tagger.platformLayerKey = model.getKey();
        tagger.tagChangesProvider = tagChanges;
        instanceMapper.addChild(tagger);
        Tagger tagInstance = injected(Tagger.class);
        tagInstance.platformLayerKey = null;
        tagInstance.platformLayerKey = model.instance;
        tagInstance.tagChangesProvider = tagChanges;
        instanceMapper.addChild(tagInstance);
    }
}
Also used : EndpointInfo(org.platformlayer.core.model.EndpointInfo) OpsProvider(org.platformlayer.ops.OpsProvider) OpenstackPublicEndpoint(org.platformlayer.service.cloud.openstack.model.OpenstackPublicEndpoint) Tagger(org.platformlayer.ops.tagger.Tagger) OpenstackInstance(org.platformlayer.service.cloud.openstack.model.OpenstackInstance) TagChanges(org.platformlayer.core.model.TagChanges)

Example 3 with OpenstackInstance

use of org.platformlayer.service.cloud.openstack.model.OpenstackInstance in project platformlayer by platformlayer.

the class OpenstackCloudController method buildInstanceTemplate.

@Override
public InstanceBase buildInstanceTemplate(MachineCreationRequest request) {
    OpenstackInstance rawMachine = new OpenstackInstance();
    rawMachine.minimumMemoryMb = request.minimumMemoryMB;
    rawMachine.hostname = request.hostname;
    return rawMachine;
}
Also used : OpenstackInstance(org.platformlayer.service.cloud.openstack.model.OpenstackInstance)

Aggregations

OpenstackInstance (org.platformlayer.service.cloud.openstack.model.OpenstackInstance)3 TagChanges (org.platformlayer.core.model.TagChanges)2 OpsProvider (org.platformlayer.ops.OpsProvider)2 EndpointInfo (org.platformlayer.core.model.EndpointInfo)1 Tagger (org.platformlayer.ops.tagger.Tagger)1 OpenstackPublicEndpoint (org.platformlayer.service.cloud.openstack.model.OpenstackPublicEndpoint)1 OpenstackComputeMachine (org.platformlayer.service.cloud.openstack.ops.openstack.OpenstackComputeMachine)1