public void testCreatePreemptibleNodeWithSsd() throws Exception {
    String group = this.group + "ssd";
    try {
      TemplateOptions options = client.templateOptions();

      options.as(GoogleComputeEngineTemplateOptions.class).bootDiskType("pd-ssd").preemptible(true);

      // create a node
      Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
      assertEquals(nodes.size(), 1, "One node should have been created");

      // Verify the disk on the instance is an ssd.
      NodeMetadata node = Iterables.get(nodes, 0);
      GoogleComputeEngineApi api = client.getContext().unwrapApi(GoogleComputeEngineApi.class);
      Instance instance = api.instancesInZone(node.getLocation().getId()).get(node.getName());
      Disk disk =
          api.disksInZone(node.getLocation().getId()).get(toName(instance.disks().get(0).source()));
      assertTrue(disk.type().toString().endsWith("pd-ssd"));
      assertTrue(instance.scheduling().preemptible());

    } finally {
      client.destroyNodesMatching(NodePredicates.inGroup(group));
    }
  }
 @Test
 public void testAs() {
   TemplateOptions options = new GoGridTemplateOptions();
   assertEquals(options.as(GoGridTemplateOptions.class), options);
 }
  @Override
  protected Object doExecute() throws Exception {
    ComputeService service = null;
    try {
      service = getComputeService();
    } catch (Throwable t) {
      System.err.println(t.getMessage());
      return null;
    }

    TemplateBuilder builder = service.templateBuilder();
    builder.any();
    if (smallest) {
      builder.smallest();
    }
    if (fastest) {
      builder.fastest();
    }
    if (biggest) {
      builder.biggest();
    }
    if (locationId != null) {
      builder.locationId(locationId);
    }
    if (imageId != null) {
      builder.imageId(imageId);
    }
    if (hardwareId != null) {
      builder.hardwareId(hardwareId);
    }

    if (osFamily != null) {
      builder.osFamily(OsFamily.fromValue(osFamily));
    }

    if (osVersion != null) {
      builder.osVersionMatches(osVersion);
    }

    TemplateOptions options = service.templateOptions();
    List<Statement> statements = Lists.newLinkedList();

    if (adminAccess) {
      statements.add(AdminAccess.standard());
    }
    if (recipes != null) {
      for (String recipe : recipes) {
        statements.add(recipeManager.createStatement(recipe, group));
      }
    }
    if (ec2SecurityGroups != null) {
      options.as(EC2TemplateOptions.class).securityGroups(ec2SecurityGroups);
    }
    if (ec2KeyPair != null) {
      options.as(EC2TemplateOptions.class).keyPair(ec2KeyPair);
    }
    if (ec2NoKeyPair != null) {
      options.as(EC2TemplateOptions.class).noKeyPair();
    }

    Set<? extends NodeMetadata> metadatas = null;

    if (!statements.isEmpty()) {
      options.runScript(new StatementList(statements));
    }

    try {
      metadatas = service.createNodesInGroup(group, number, builder.options(options).build());
    } catch (RunNodesException ex) {
      System.out.println("Failed to create nodes:" + ex.getMessage());
    }

    if (metadatas != null && !metadatas.isEmpty()) {
      System.out.println("Created nodes:");
      printNodes(service, metadatas, System.out);

      for (NodeMetadata node : metadatas) {
        for (String cacheKey : ServiceHelper.findCacheKeysForService(service)) {
          cacheProvider
              .getProviderCacheForType(Constants.ACTIVE_NODE_CACHE)
              .put(cacheKey, node.getId());
          cacheProvider
              .getProviderCacheForType(Constants.INACTIVE_NODE_CACHE)
              .put(cacheKey, node.getId());
          cacheProvider
              .getProviderCacheForType(Constants.SUSPENDED_NODE_CACHE)
              .put(cacheKey, node.getId());
        }
      }
    }

    return null;
  }