Package org.platformlayer.instances.model

Examples of org.platformlayer.instances.model.PersistentInstance


    return request;
  }

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

    {
      // Add tag with instance id to persistent instance (very helpful for DNS service!)

      Tagger tagger = injected(Tagger.class);
      tagger.platformLayerKey = model.getKey();
      tagger.tagChangesProvider = new OpsProvider<TagChanges>() {

        @Override
        public TagChanges get() throws OpsException {
          Machine machine = OpsContext.get().getInstance(Machine.class);

          if (machine == null) {
            if (OpsContext.isDelete()) {
              return null;
            }

            throw new OpsException("No machine in scope");
          }

          TagChanges changeTags = new TagChanges();
          changeTags.addTags.add(Tag.INSTANCE_KEY.build(machine.getKey()));
          platformLayer.changeTags(model.getKey(), changeTags, null);
          return changeTags;
        }
      };
      addChild(tagger);
    }
View Full Code Here


  public void doOperation() throws OpsException, IOException {
    ItemBase item = ops.getInstance(ItemBase.class);

    Tag parentTag = Tag.buildParentTag(item.getKey());

    PersistentInstance persistentInstanceTemplate = buildPersistentInstanceTemplate();

    persistentInstanceTemplate.getTags().add(parentTag);

    // Set during doOperation
    Machine machine = null;
    PersistentInstance persistentInstance = null;
    InstanceBase instance = null;
    OpsTarget target = null;

    persistentInstance = getOrCreate(parentTag, persistentInstanceTemplate);
View Full Code Here

      recipeTemplate.setKey(PlatformLayerKey.fromId(recipeId));
    }

    DiskImageRecipe recipe = imageFactory.getOrCreateRecipe(recipeTemplate);

    PersistentInstance persistentInstanceTemplate = new PersistentInstance();

    persistentInstanceTemplate.setDnsName(dnsName);
    persistentInstanceTemplate.setSshPublicKey(SshKeys.serialize(sshKey.getKeyPair().getPublic()));
    persistentInstanceTemplate.setSecurityGroup(securityGroup);
    persistentInstanceTemplate.setMinimumRam(minimumMemoryMb);
    persistentInstanceTemplate.setCloud(cloud);
    persistentInstanceTemplate.setHostPolicy(hostPolicy);
    persistentInstanceTemplate.setRecipe(recipe.getKey());

    String id = dnsName;
    if (Strings.isNullOrEmpty(id)) {
      id = UUID.randomUUID().toString();
    }
    persistentInstanceTemplate.setKey(PlatformLayerKey.fromId(id));

    for (int publicPort : publicPorts) {
      persistentInstanceTemplate.getPublicPorts().add(publicPort);
    }
    return persistentInstanceTemplate;
  }
View Full Code Here

    return persistentInstanceTemplate;
  }

  PersistentInstance getOrCreate(Tag tag, PersistentInstance persistentInstance) throws PlatformLayerClientException,
      OpsException {
    PersistentInstance foundPersistentInstance = instanceSupervisor.findPersistentInstance(tag);

    if (!OpsContext.isDelete()) {
      // We always PUT it (should be idempotent)
      // if (foundPersistentInstance == null) {
      PersistentInstance created = platformLayer.putItemByTag(persistentInstance, tag);
      foundPersistentInstance = created;
      // }

      // if (foundPersistentInstance == null) {
      // // String imageId = imageFactory.getOrCreateImage(recipe);
View Full Code Here

TOP

Related Classes of org.platformlayer.instances.model.PersistentInstance

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.