Package org.platformlayer.service.cloud.direct.model

Examples of org.platformlayer.service.cloud.direct.model.DirectInstance


            // Refresh item to pick up new tags
            backendItem = platformLayerClient.getItem(backendItem.getKey(), DirectInstance.class);

            PlatformLayerCloudMachine instanceMachine = (PlatformLayerCloudMachine) instanceHelpers
                .getMachine(backendItem);
            DirectInstance instance = (DirectInstance) instanceMachine.getInstance();
            List<InetAddress> addresses = Tag.NETWORK_ADDRESS.find(instance);
            InetAddress address = InetAddressChooser.preferIpv4().choose(addresses);
            if (address == null) {
              throw new IllegalStateException();
            }
View Full Code Here


  PlatformLayerHelpers platformLayerClient;

  @Override
  protected void addChildren() throws OpsException {
    DirectPublicEndpoint model = OpsContext.get().getInstance(DirectPublicEndpoint.class);
    DirectInstance directInstance = platformLayerClient.getItem(model.instance, DirectInstance.class);

    {
      DirectPublicPorts publicPorts = injected(DirectPublicPorts.class);
      publicPorts.backendItem = directInstance;
      publicPorts.tagItems.add(directInstance);
View Full Code Here

      for (String assigned : candidate.getModel().getTags().findAll(Tag.ASSIGNED)) {
        PlatformLayerKey instanceKey = PlatformLayerKey.parse(assigned);

        // TODO: Avoid 1+N
        DirectInstance instance = platformLayer.getItem(instanceKey);
        if (instance == null) {
          // TODO: Warn?
          throw new IllegalStateException();
        }

        switch (instance.getState()) {
        case DELETE_REQUESTED:
        case DELETED:
          continue;
        }
View Full Code Here

    throw new UnsupportedOperationException();
  }

  @Override
  public InstanceBase buildInstanceTemplate(MachineCreationRequest request) {
    DirectInstance directMachine = new DirectInstance();

    directMachine.minimumMemoryMb = request.minimumMemoryMB;
    directMachine.hostname = request.hostname;

    return directMachine;
View Full Code Here

      for (String assigned : candidate.getModel().getTags().findAll(Tag.ASSIGNED)) {
        PlatformLayerKey instanceKey = PlatformLayerKey.parse(assigned);

        // TODO: Avoid 1+N
        DirectInstance instance = platformLayer.getItem(instanceKey);
        if (instance == null) {
          // TODO: Warn?
          throw new IllegalStateException();
        }

        switch (instance.getState()) {
        case DELETE_REQUESTED:
        case DELETED:
          continue;
        }
View Full Code Here

  public void handler() throws OpsException, IOException {
  }

  @Override
  protected void addChildren() throws OpsException {
    final DirectInstance model = OpsContext.get().getInstance(DirectInstance.class);

    CloudInstanceMapper instance;
    {
      instance = injected(CloudInstanceMapper.class);
      instance.instance = OpsContext.get().getInstance(DirectInstance.class);
      addChild(instance);
    }

    instance.addChild(ManagedDirectory.build(getInstanceDir(), "700"));

    // TODO: If we're not going to assign an IPV4 redirect, we might not need this
    final Provider<AddressModel> address4;
    {
      NetworkAddressPoolAssignment provider = instance.addChild(NetworkAddressPoolAssignment.class);
      provider.holder = model.getKey();
      provider.poolProvider = DirectCloudUtils.getPrivateAddressPool4();

      address4 = provider;
    }

    final Provider<AddressModel> address6;
    {
      NetworkAddressPoolAssignment provider = instance.addChild(NetworkAddressPoolAssignment.class);
      provider.holder = model.getKey();
      provider.poolProvider = directCloudHelpers.getAddressPool6();

      address6 = provider;
    }

    // {
    // NetworkTunDevice tun = injected(NetworkTunDevice.class);
    // tun.interfaceName = getEthernetDeviceName();
    // tun.bridgeName = Providers.getProperty(assignNetworkAddress, "bridge");
    // instance.addChild(tun);
    // }

    {
      DownloadImage download = injected(DownloadImage.class);
      download.imageFile = new File(getInstanceDir(), "rootfs");
      download.recipeKey = model.recipeId;
      download.imageFormats = Collections.singletonList(ImageFormat.Tar);
      instance.addChild(download);
    }

    {
      LxcBootstrap bootstrap = injected(LxcBootstrap.class);
      bootstrap.address4 = address4;
      bootstrap.address6 = address6;
      bootstrap.lxcId = id;
      bootstrap.instanceDir = instanceDir;

      try {
        bootstrap.sshPublicKey = OpenSshUtils.readSshPublicKey(model.sshPublicKey);
      } catch (IOException e) {
        throw new OpsException("Error deserializing SSH key", e);
      }

      bootstrap.hostname = model.hostname;

      instance.addChild(bootstrap);
    }

    InstanceScript script;
    {
      script = instance.addChild(InstanceScript.class);
      script.filePath = new File(DirectHostController.LXC_INSTANCE_DIR, id);

      String key = "lxc-" + id;
      script.key = key;

      script.addresses.add(address4);
      script.addresses.add(address6);

      // script.hostPrimaryInterface = hostModel.publicInterface;

      Command command = Command.build("lxc-start");
      command.addLiteral("--name").addQuoted(id);
      script.launchInstanceCommand = command;
    }

    {
      // ManagedSupervisordInstance service = instance.addChild(ManagedSupervisordInstance.class);
      StandardService service = instance.addChild(StandardService.class);
      script.configure(model, service);
    }

    {
      OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
        @Override
        public TagChanges get() {
          TagChanges tagChanges = new TagChanges();

          tagChanges.addTags.add(Tag.INSTANCE_KEY.build(model.getKey()));

          AddressModel ipv4 = address4.get();
          AddressModel ipv6 = address6.get();

          if (ipv4 != null) {
View Full Code Here

      kvmInstance.addresses.add(address4);
      kvmInstance.addresses.add(address6);
    }

    {
      final DirectInstance model = OpsContext.get().getInstance(DirectInstance.class);

      OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
        @Override
        public TagChanges get() {
          TagChanges tagChanges = new TagChanges();

          tagChanges.addTags.add(Tag.INSTANCE_KEY.build(model.getKey()));

          AddressModel ipv4 = address4.get();
          AddressModel ipv6 = address6.get();

          tagChanges.addTags.add(Tag.NETWORK_ADDRESS.build(ipv4));
View Full Code Here

TOP

Related Classes of org.platformlayer.service.cloud.direct.model.DirectInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.