Package org.jclouds.compute.options

Examples of org.jclouds.compute.options.TemplateOptions


      TemplateOptions options = new AbiquoTemplateOptions();
      assertEquals(options.as(AbiquoTemplateOptions.class), options);
   }

   public void testOverrideCores() {
      TemplateOptions options = new AbiquoTemplateOptions().overrideCores(5);
      assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideCores(), Integer.valueOf(5));
   }


      TemplateOptions options = new AbiquoTemplateOptions().overrideCores(5);
      assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideCores(), Integer.valueOf(5));
   }

   public void testOverrideRam() {
      TemplateOptions options = new AbiquoTemplateOptions().overrideRam(2048);
      assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideRam(), Integer.valueOf(2048));
   }

      TemplateOptions options = new AbiquoTemplateOptions().overrideRam(2048);
      assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideRam(), Integer.valueOf(2048));
   }

   public void testVncPassword() {
      TemplateOptions options = new AbiquoTemplateOptions().vncPassword("foo");
      assertEquals(options.as(AbiquoTemplateOptions.class).getVncPassword(), "foo");
   }

                .locationId(config.getLocation());

        int[] extraPorts = parseExtraPorts(config.getExtraPorts());
        int[] inboundPorts = mergePorts(DEFAULT_PORTS, extraPorts);

        TemplateOptions options = new EC2TemplateOptions()
                .as(EC2TemplateOptions.class).inboundPorts(inboundPorts)
                .blockOnComplete(false)
                .runAsRoot(config.isRunAsRoot());

        if (useConfiguredKeyPair(config)) {
            options.as(EC2TemplateOptions.class).keyPair(config.getKeyPair());
        }

        template.options(options);

        Set<? extends NodeMetadata> tag = computeService.createNodesInGroup(config.getTagPrefix() + id, 1, template.build());

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);
    TemplateOptions templateOptions = mock(TemplateOptions.class);
   
    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.getContext()).thenReturn(serviceContext);
    when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);
    TemplateOptions templateOptions = mock(TemplateOptions.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.getContext()).thenReturn(serviceContext);
    when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);
    TemplateOptions templateOptions = mock(TemplateOptions.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.getContext()).thenReturn(serviceContext);
    when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));

      InstanceApi instanceClient = view.unwrapApi(EC2Api.class)
               .getInstanceApi().get();

      String group = this.group + "o";

      TemplateOptions options = client.templateOptions();

      options.as(EC2TemplateOptions.class).securityGroups(group);
      options.as(EC2TemplateOptions.class).clientToken(Integer.toHexString(random.nextInt(65536 * 1024)));

      String startedId = null;
      try {
         cleanupExtendedStuffInRegion(null, securityGroupClient, keyPairClient, group);

         // create a security group that allows ssh in so that our scripts later
         // will work
         securityGroupClient.createSecurityGroupInRegion(null, group, group);
         securityGroupClient.authorizeSecurityGroupIngressInRegion(null, group, IpProtocol.TCP, 22, 22, "0.0.0.0/0");

         // create a keypair to pass in as well
         KeyPair result = keyPairClient.createKeyPairInRegion(null, group);
         options.as(EC2TemplateOptions.class).keyPair(result.getKeyName());
        
         // pass in the private key, so that we can run a script with it
         assert result.getKeyMaterial() != null : result;
         options.overrideLoginPrivateKey(result.getKeyMaterial());
        
         // an arbitrary command to run
         options.runScript(Statements.exec("find /usr"));
        
         Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
         NodeMetadata first = Iterables.get(nodes, 0);
         assert first.getCredentials() != null : first;
         assert first.getCredentials().identity != null : first;

         Properties overrides = setupProperties();
         overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true");

         context = createView(overrides, setupModules());

         TemplateOptions options = client.templateOptions();

         options.blockOnPort(22, 300);
         options.inboundPorts(22);

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

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

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.