Package org.jclouds.compute.options

Examples of org.jclouds.compute.options.TemplateOptions


   @Override
   public NodeWithInitialCredentials createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
      int count = 1;
      synchronized (this) {
         TemplateOptions options = template.getOptions().clone();

         // if no user is provided we set the pool's user
         if (options.getLoginUser() == null) {
            options.overrideLoginCredentials(LoginCredentials.fromCredentials(checkNotNull(initialCredentialsBuilder
                     .build().getAdminCredentials())));
         }

         logger.info(">> assigning pool node to frontend group %s", group);
         Set<NodeMetadata> backendNodes = getBackendNodes();


   public void setUp() {
      Injector injector = createInjector();
      injector.injectMembers(this);
      this.nodeMeta1 = new NodeMetadataBuilder().id("testmeta1").status(Status.ERROR).build();
      this.nodeMeta2 = new NodeMetadataBuilder().id("testmeta2").status(Status.ERROR).build();
      this.templateOptions = new TemplateOptions().overrideLoginUser("testuser").overrideLoginPassword("testpass")
               .overrideAuthenticateSudo(true).userMetadata("testmetakey", "testmetavalue")
               .overrideLoginPrivateKey("pk").userMetadata("testmetakey2", "testmetavalue2")
               .tags(ImmutableList.of("tag1", "tag2"));
   }

*/
@Test(testName = "JoyentCloudTemplateOptionsTest")
public class JoyentCloudTemplateOptionsTest {

   public void testAs() {
      TemplateOptions options = new JoyentCloudTemplateOptions();
      assertEquals(options.as(JoyentCloudTemplateOptions.class), options);
   }

           
         }

      }, onlySW);

      TemplateOptions options = apiThatCreatesNode.templateOptions().blockUntilRunning(false);
     
      assertTrue(options.as(JoyentCloudTemplateOptions.class).shouldGenerateKey().get());

      NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, options));
     
      assertEquals(node.getCredentials().getPrivateKey(), keyPair.get("private"));
   }

      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) {

      String group = prefix + "cus";

      NodeMetadata node = null;
      try {

         TemplateOptions options = client.templateOptions();
         options.blockOnPort(22, 180);
         options.as(VCloudTemplateOptions.class).customizationScript(script);
         options.as(VCloudTemplateOptions.class).description(group);
         node = getOnlyElement(client.createNodesInGroup(group, 1, options));

         VApp vapp = client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi().getVAppClient().getVApp(
                  node.getUri());
         assertEquals(vapp.getDescription(), group);

public class CloudStackTemplateOptionsTest {
   //TODO: test clone();
  
   @Test
   public void testAs() {
      TemplateOptions options = new CloudStackTemplateOptions();
      assertEquals(options.as(CloudStackTemplateOptions.class), options);
   }

      assertEquals(options.as(CloudStackTemplateOptions.class), options);
   }

   @Test
   public void testDefaultSecurityGroupIds() {
      TemplateOptions options = new CloudStackTemplateOptions();
      assertEquals(options.as(CloudStackTemplateOptions.class).getSecurityGroupIds(), ImmutableSet.of());
   }

      assertEquals(options.as(CloudStackTemplateOptions.class).getSecurityGroupIds(), ImmutableSet.of());
   }

   @Test
   public void testSecurityGroupId() {
      TemplateOptions options = new CloudStackTemplateOptions().securityGroupId("3");
      assertEquals(options.as(CloudStackTemplateOptions.class).getSecurityGroupIds(), ImmutableSet.of("3"));
   }

      assertEquals(options.as(CloudStackTemplateOptions.class).getSecurityGroupIds(), ImmutableSet.of("3"));
   }

   @Test
   public void testSecurityGroupIdStatic() {
      TemplateOptions options = securityGroupId("3");
      assertEquals(options.as(CloudStackTemplateOptions.class).getSecurityGroupIds(), ImmutableSet.of("3"));
   }

TOP

Related Classes of org.jclouds.compute.options.TemplateOptions

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.