Examples of InstanceTemplate


Examples of org.apache.whirr.service.ClusterSpec.InstanceTemplate

    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,3 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "60% hadoop-datanode+hadoop-tasktracker");
    ClusterSpec expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    List<InstanceTemplate> templates = expectedClusterSpec.getInstanceTemplates();
    InstanceTemplate t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    InstanceTemplate t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));
  }
View Full Code Here

Examples of org.apache.whirr.service.ClusterSpec.InstanceTemplate

    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,3 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "100 hadoop-namenode+hadoop-jobtracker,60 hadoop-datanode+hadoop-tasktracker");
    ClusterSpec expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    List<InstanceTemplate> templates = expectedClusterSpec.getInstanceTemplates();
    InstanceTemplate t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    InstanceTemplate t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));
   
    conf.setProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
    expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    templates = expectedClusterSpec.getInstanceTemplates();
    t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));

    conf.addProperty("whirr.instance-templates-minumum-number-of-instances", "1 hadoop-datanode+hadoop-tasktracker");
    expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    templates = expectedClusterSpec.getInstanceTemplates();
    t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));

    conf.setProperty("whirr.instance-templates-minimum-number-of-instances", "3 hadoop-datanode+hadoop-tasktracker");
    expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    templates = expectedClusterSpec.getInstanceTemplates();
    t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(3));
  }
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

      InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, insert,
              CREATE_INSTANCE_RESPONSE).getInstanceApiForProject("myproject");

      InstanceTemplate options = InstanceTemplate.builder().forMachineType("n1-standard-1")
              .addNetworkInterface(URI.create("https://www.googleapis" +
                      ".com/compute/v1beta13/projects/myproject/networks/default"));

      assertEquals(api.createInZone("test-1", options, "us-central1-a"), new ParseOperationTest().expected());
   }
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

              .payload(payloadFromResource("/operation.json")).build();

      InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, insert, insertInstanceResponse).getInstanceApiForProject("myproject");

      InstanceTemplate options = InstanceTemplate.builder().forMachineType("n1-standard-1")
              .addNetworkInterface(URI.create("https://www.googleapis" +
                      ".com/compute/v1beta13/projects/myproject/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
              .description("desc")
              .image(URI.create("https://www.googleapis" +
                      ".com/compute/v1beta13/projects/google/images/gcel-12-04-v20121106"))
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

   /**
    * {@inheritDoc}
    */
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
      InstanceTemplate template = (InstanceTemplate) checkNotNull(postParams.get("template"), "template");
      template.name(checkNotNull(postParams.get("name"), "name").toString());
      template.zone(zonesToURI.apply((String) checkNotNull(postParams.get("zone"), "zone")));

      if (template.getMachineTypeName() != null) {
         template.machineType(machineTypesToURI.apply(template.getMachineTypeName()));
      }
      template.zone((String) null);
      template.machineType((String) null);
      return bindToRequest(request, template);
   }
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

      GoogleComputeEngineTemplateOptions options = GoogleComputeEngineTemplateOptions.class.cast(template.getOptions()).clone();
      checkState(options.getNetwork().isPresent(), "network was not present in template options");
      Hardware hardware = checkNotNull(template.getHardware(), "hardware must be set");
      URI machineType = checkNotNull(hardware.getUri(), "hardware uri must be set");

      InstanceTemplate instanceTemplate = InstanceTemplate.builder()
              .forMachineType(machineType);

      if (options.isEnableNat()) {
         instanceTemplate.addNetworkInterface(options.getNetwork().get(), Type.ONE_TO_ONE_NAT);
      } else {
         instanceTemplate.addNetworkInterface(options.getNetwork().get());
      }

      LoginCredentials credentials = getFromImageAndOverrideIfRequired(template.getImage(), options);

      ImmutableMap.Builder<String, String> metadataBuilder = metatadaFromTemplateOptions.apply(options);
      instanceTemplate.metadata(metadataBuilder.build());
      instanceTemplate.tags(options.getTags());
      instanceTemplate.serviceAccounts(options.getServiceAccounts());
      instanceTemplate.image(checkNotNull(template.getImage().getUri(), "image URI is null"));

      Operation operation = api.getInstanceApiForProject(userProject.get())
              .createInZone(name, instanceTemplate, template.getLocation().getId());

      if (options.shouldBlockUntilRunning()) {
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

   /**
    * {@inheritDoc}
    */
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
      InstanceTemplate template = (InstanceTemplate) checkNotNull(postParams.get("template"), "template");
      template.name(checkNotNull(postParams.get("name"), "name").toString());

      if (template.getMachineTypeName() != null) {
         template.machineType(machineTypesToURI.apply(template.getMachineTypeName()));
      }
      template.machineType((String) null);
      return bindToRequest(request, template);
   }
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

                                      true));
      }

      disks.addAll(options.getDisks());

      InstanceTemplate instanceTemplate = InstanceTemplate.builder()
              .forMachineType(hardware.getUri());

      if (options.isEnableNat()) {
         instanceTemplate.addNetworkInterface(options.getNetwork().get(), Type.ONE_TO_ONE_NAT);
      } else {
         instanceTemplate.addNetworkInterface(options.getNetwork().get());
      }

      instanceTemplate.disks(disks);

      LoginCredentials credentials = getFromImageAndOverrideIfRequired(template.getImage(), options);

      ImmutableMap.Builder<String, String> metadataBuilder = metatadaFromTemplateOptions.apply(options);

      metadataBuilder.put(GCE_IMAGE_METADATA_KEY, template.getImage().getUri().toString());

      if (!options.shouldKeepBootDisk()) {
         metadataBuilder.put(GCE_DELETE_BOOT_DISK_METADATA_KEY, Boolean.TRUE.toString());
      }

      instanceTemplate.metadata(metadataBuilder.build());
      instanceTemplate.serviceAccounts(options.getServiceAccounts());

      final InstanceApi instanceApi = api.getInstanceApiForProject(userProject.get());
      final String zone = template.getLocation().getId();
      Operation operation = instanceApi.createInZone(name, zone, instanceTemplate);
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

              TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
              requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, insert,
              CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject");

      InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
              .addNetworkInterface(URI.create("https://www.googleapis" +
                      ".com/compute/v1/projects/myproject/global/networks/default"));

      assertEquals(api.createInZone("test-1", "us-central1-a", options), new ParseOperationTest().expected());
   }
View Full Code Here

Examples of org.jclouds.googlecomputeengine.domain.InstanceTemplate

      InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE),
              TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
              requestForScopes(COMPUTE_SCOPE),
              TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApiForProject("myproject");

      InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
              .addNetworkInterface(URI.create("https://www.googleapis" +
                      ".com/compute/v1/projects/myproject/global/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
              .description("desc")
              .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE,
                      create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.