Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.Template


      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      final ComputeService computeService =
        computeServiceContext.getComputeService();

      final Template template = BootstrapTemplate.build(clusterSpec, computeService,
        statementBuilder, entry.getKey());

      Future<Set<? extends NodeMetadata>> nodesFuture = executorService.submit(
          new StartupProcess(
              clusterSpec.getClusterName(),
View Full Code Here


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

    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)));
View Full Code Here

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

    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)));
View Full Code Here

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

    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)));
View Full Code Here

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


    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
View Full Code Here

        Image image = new ImageBuilder().providerId("ec2").name("test").id("testId").location(location)
              .uri(URI.create("http://node")).operatingSystem(OperatingSystem.builder().description("op").build())
              .description("description").status(Image.Status.AVAILABLE).defaultCredentials(loginCredentials).build();
        Hardware hardware = new HardwareBuilder().providerId("ec2").name("test").id("testId").location(location)
              .uri(URI.create("http://node")).ram(1).hypervisor("xen").build();
        Template template = new TemplateImpl(image, hardware, location, TemplateOptions.NONE);
        throw new RunNodesException("tag" + id, num, template, nodes, executionExceptions, failedNodes);
      }
      return nodes;
    }
View Full Code Here

    if (((instanceType = iaas.getProperty("instanceType")) != null)) {

      templateBuilder.hardwareId(instanceType);
    }

    Template template = templateBuilder.build();

    // if you wish to auto assign IPs, instance spawning call should be
    // blocking, but if you
    // wish to assign IPs manually, it can be non-blocking.
    // is auto-assign-ip mode or manual-assign-ip mode?
    boolean blockUntilRunning = Boolean.parseBoolean(iaas
        .getProperty("autoAssignIp"));
    template.getOptions().as(TemplateOptions.class)
        .blockUntilRunning(blockUntilRunning);

    // this is required in order to avoid creation of additional security
    // groups by Jclouds.
    template.getOptions().as(TemplateOptions.class)
        .inboundPorts(new int[] {});

    if (iaas.getProperty("securityGroups") != null) {
      template.getOptions()
          .as(NovaTemplateOptions.class)
          .securityGroupNames(
              iaas.getProperty("securityGroups").split(
                  CloudControllerConstants.ENTRY_SEPARATOR));
    }

    if (iaas.getProperty(CloudControllerConstants.PAYLOAD_FOLDER) != null) {
      template.getOptions()
          .as(NovaTemplateOptions.class)
          .userData(
              ComputeServiceBuilderUtil.getUserData(CarbonUtils
                  .getCarbonHome()
                  + File.separator
                  + iaas.getProperty(CloudControllerConstants.PAYLOAD_FOLDER)));
    }

    if (iaas.getProperty("keyPair") != null) {
      template.getOptions().as(NovaTemplateOptions.class)
          .keyPairName(iaas.getProperty("keyPair"));
    }

    // set Template
    iaas.setTemplate(template);
View Full Code Here

      // set instance type eg: m1.large
      templateBuilder.hardwareId(iaas.getProperty("instanceType"));
    }

    // build the Template
    Template template = templateBuilder.build();

    // if you wish to auto assign IPs, instance spawning call should be
    // blocking, but if you
    // wish to assign IPs manually, it can be non-blocking.
    // is auto-assign-ip mode or manual-assign-ip mode?
    boolean blockUntilRunning = Boolean.parseBoolean(iaas
        .getProperty("autoAssignIp"));
    template.getOptions().as(TemplateOptions.class)
        .blockUntilRunning(blockUntilRunning);

    // this is required in order to avoid creation of additional security
    // groups by jclouds.
    template.getOptions().as(TemplateOptions.class)
        .inboundPorts(new int[] {});

    // set EC2 specific options
    if (iaas.getProperty("subnetId") != null) {
      template.getOptions().as(AWSEC2TemplateOptions.class)
          .subnetId(iaas.getProperty("subnetId"));
    }

    if (iaas.getProperty("availabilityZone") != null) {
      template.getOptions().as(AWSEC2TemplateOptions.class)
          .placementGroup(iaas.getProperty("availabilityZone"));
    }

    if (iaas.getProperty("securityGroups") != null) {
      template.getOptions()
          .as(AWSEC2TemplateOptions.class)
          .securityGroups(
              iaas.getProperty("securityGroups").split(
                  CloudControllerConstants.ENTRY_SEPARATOR));

    }

    if (iaas.getProperty(CloudControllerConstants.PAYLOAD_FOLDER) != null) {
      template.getOptions()
          .as(AWSEC2TemplateOptions.class)
          .userData(
              ComputeServiceBuilderUtil.getUserData(CarbonUtils
                  .getCarbonHome()
                  + File.separator
                  + iaas.getProperty(CloudControllerConstants.PAYLOAD_FOLDER)));
    }

    if (iaas.getProperty("keyPair") != null) {
      template.getOptions().as(AWSEC2TemplateOptions.class)
          .keyPair(iaas.getProperty("keyPair"));
    }

    // set Template
    iaas.setTemplate(template);
View Full Code Here

    // set image id specified
    templateBuilder.imageId(iaas.getImage());

    // build the Template
    Template template = templateBuilder.build();

    // if you wish to auto assign IPs, instance spawning call should be
    // blocking, but if you
    // wish to assign IPs manually, it can be non-blocking.
    // is auto-assign-ip mode or manual-assign-ip mode? - default mode is
    // non-blocking
    boolean blockUntilRunning = Boolean.parseBoolean(iaas
        .getProperty("autoAssignIp"));
    template.getOptions().as(TemplateOptions.class)
        .blockUntilRunning(blockUntilRunning);

    // this is required in order to avoid creation of additional security
    // groups by Jclouds.
    template.getOptions().as(TemplateOptions.class)
        .inboundPorts(22, 80, 8080, 443, 8243);

    template.getOptions().as(VCloudTemplateOptions.class)
        .ipAddressAllocationMode(IpAddressAllocationMode.POOL);

    // set Template
    iaas.setTemplate(template);
  }
View Full Code Here

  public void setDynamicPayload(IaasProvider iaasInfo) {

    // in VCloud case we need to run a script
    if (iaasInfo.getTemplate() != null && iaasInfo.getPayload() != null) {

      Template template = iaasInfo.getTemplate();
      String script = "";
      String launchParams = "", key = "";

      // open the zip file stream
      ZipInputStream stream = new ZipInputStream(
          new ByteArrayInputStream(iaasInfo.getPayload()));

      try {

        // now iterate through each item in the stream. The get next
        // entry call will return a ZipEntry for each file in the
        // stream
        ZipEntry entry;
        while ((entry = stream.getNextEntry()) != null) {
          StringWriter writer = new StringWriter();
          IOUtils.copy(stream, writer);

          if (entry.getName().contains("launch-params")) {
            launchParams = writer.toString();
          } else if (entry.getName().contains("id_rsa")) {
            key = writer.toString();
          }

        }
      } catch (IOException e) {
        log.error(e.getMessage(), e);
      } finally {
        // we must always close the zip file.
        try {
          stream.close();
        } catch (IOException e) {

          log.error("failed to close the ZIP stream", e);
        }
      }

      script = "mkdir /var/lib/cloud && mkdir /var/lib/cloud/instance && mkdir /var/lib/cloud/instance/payload && "
          + "echo \""
          + launchParams
          + "\" > /var/lib/cloud/instance/payload/launch-params && "
          + "echo \""
          + key
          + "\" > /var/lib/cloud/instance/payload/id_rsa && "
          + "cd /opt/ && "
          + "chmod 755 wso2-openstack-init.sh && "
          + "./wso2-openstack-init.sh";

      template.getOptions()
          .overrideLoginUser(iaasInfo.getProperty("loginUser"))
          .overrideLoginPassword(
              iaasInfo.getProperty("loginPassword"))
          .runScript(script);
    }
View Full Code Here

TOP

Related Classes of org.jclouds.compute.domain.Template

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.