Package org.platformlayer.core.model

Examples of org.platformlayer.core.model.PlatformLayerKey


        }
      }

      if (best == null) {
        // We should be owned by the recipe
        PlatformLayerKey recipeKey = template.getRecipeId();
        if (recipeKey != null) {
          template.getTags().add(Tag.buildParentTag(recipeKey));
        }

        best = platformLayer.putItem(template);
View Full Code Here


  }

  public CloudImage getOrCreateImageId(MachineProvider targetCloud, List<ImageFormat> formats,
      DiskImageRecipe recipeTemplate) throws OpsException {
    DiskImageRecipe recipeItem = getOrCreateRecipe(recipeTemplate);
    PlatformLayerKey recipeKey = recipeItem.getKey();

    return getOrCreateImageId(targetCloud, formats, recipeKey);
  }
View Full Code Here

    imageTemplate.setFormat(formats.get(0).name());
    imageTemplate.setRecipeId(recipeKey);
    String id = "image-" + recipeKey.getItemId().getKey();
    imageTemplate.setKey(PlatformLayerKey.fromId(id));

    PlatformLayerKey cloudKey = targetCloud.getModel().getKey();
    imageTemplate.setCloud(cloudKey);

    DiskImage image = getOrCreateImage(imageTemplate);
    return getImageInfo(image);
  }
View Full Code Here

    List<String> assignedInstanceIds = instanceTags.findAll(Tag.ASSIGNED);
    if (assignedInstanceIds.isEmpty()) {
      if (createInstance && !OpsContext.isDelete()) {
        MachineCreationRequest request = buildMachineCreationRequest();

        PlatformLayerKey instanceKey = instance.getKey();
        request.tags.add(Tag.buildParentTag(instanceKey));

        PublicKey servicePublicKey = service.getSshKey().getKeyPair().getPublic();
        Instance created = computeClient.createInstance(cloud, request, servicePublicKey);
View Full Code Here

  public <T extends ItemBase> T getItem(String id, Class<T> itemClass) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(itemClass, new Class[] {});

    PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, new ManagedItemId(id), itemClass,
        client.listServices(true));
    return client.getItem(key, itemClass);
  }
View Full Code Here

  }

  public <T extends ItemBase> JobData deleteItem(T item) throws IOException, OpsException {
    TypedPlatformLayerClient client = getTypedClient();

    PlatformLayerKey key = item.getKey();
    return client.deleteItem(key);
  }
View Full Code Here

  }

  public <T extends ItemBase> JobData doAction(T item, Action action) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    PlatformLayerKey key = item.getKey();
    return client.doAction(key, action);
  }
View Full Code Here

  }

  public JobData waitForJobComplete(JobData job, TimeSpan timeout) throws OpsException, IOException {
    TypedPlatformLayerClient client = getTypedClient();

    PlatformLayerKey jobKey = job.key;

    long startedAt = System.currentTimeMillis();

    while (true) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        throw new IllegalStateException("Interrupted", e);
      }

      if (timeout != null && timeout.hasTimedOut(startedAt)) {
        throw new OpsException("Timeout waiting for job completion");
      }

      // TODO: We really need a "get job status" function
      JobData found = null;
      for (JobData candidate : client.listJobs().getJobs()) {
        if (jobKey.equals(candidate.getJobKey())) {
          found = candidate;
        }
      }

      if (found == null) {
        // Assume completed?
        throw new IllegalStateException("Job not found in job list");
      }

      JobExecutionList executions = client.listJobExecutions(job.getJobKey().getItemIdString());
      JobExecutionData foundExecution = null;
      for (JobExecutionData candidate : executions) {
        if (jobKey.equals(candidate.getJobKey())) {
          foundExecution = candidate;
        }
      }

      if (foundExecution == null) {
View Full Code Here

    }

    if (addTagToManaged && !OpsContext.isDelete()) {
      // Add tag with instance id to persistent instance (very helpful for
      // DNS service!)
      PlatformLayerKey machineKey = machine.getKey();
      platformLayer.addTag(item.getKey(), Tag.INSTANCE_KEY.build(machineKey));
    }

    SshKey sshKey = service.getSshKey();
    if (machine != null) {
View Full Code Here

    {
      X500Principal subject = buildX500(keyId, owner);
      KeyPair keyPair = RsaUtils.generateRsaKeyPair();

      PlatformLayerKey createdPath = ca.createSignedKey(owner, keyId, subject, keyPair);
      ItemBase createdModel = platformLayer.getItem(createdPath);
      ManagedSecretKey created = providers.toInterface(createdModel, ManagedSecretKey.class);
      return created;
    }
View Full Code Here

TOP

Related Classes of org.platformlayer.core.model.PlatformLayerKey

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.