Package org.jclouds.aws.ec2.compute.functions

Examples of org.jclouds.aws.ec2.compute.functions.RunningInstanceToNodeMetadata$FindImageForInstance


            Lists.<Object> newArrayList("us-east-1",
            "us-east-1a",
            "ami-voo",
            1,
            5,
            new AWSRunInstancesOptions().withKernelId("kernelId").enableMonitoring()
                  .withSecurityGroups("group1", "group2")));

      assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
      assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
      assertPayloadEquals(
View Full Code Here


      this.createPlacementGroupIfNeeded = createPlacementGroupIfNeeded;
      this.importExistingKeyPair = importExistingKeyPair;
   }

   public AWSRunInstancesOptions execute(String region, String group, Template template) {
      AWSRunInstancesOptions instanceOptions = AWSRunInstancesOptions.class
            .cast(super.execute(region, group, template));

      String placementGroupName = template.getHardware().getId().startsWith("cc") ? createNewPlacementGroupUnlessUserSpecifiedOtherwise(
            region, group, template.getOptions()) : null;

      if (placementGroupName != null)
         instanceOptions.inPlacementGroup(placementGroupName);

      AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
      if (awsTemplateOptions.isMonitoringEnabled())
         instanceOptions.enableMonitoring();
      if (awsTemplateOptions.getIAMInstanceProfileArn() != null)
         instanceOptions.withIAMInstanceProfileArn(awsTemplateOptions.getIAMInstanceProfileArn());
      if (awsTemplateOptions.getIAMInstanceProfileName() != null)
         instanceOptions.withIAMInstanceProfileName(awsTemplateOptions.getIAMInstanceProfileName());

      return instanceOptions;
   }
View Full Code Here

   }

   @Override
   protected void addSecurityGroups(String region, String group, Template template, RunInstancesOptions instanceOptions) {
      AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
      AWSRunInstancesOptions awsInstanceOptions = AWSRunInstancesOptions.class.cast(instanceOptions);

      String subnetId = awsTemplateOptions.getSubnetId();
      boolean associatePublicIpAddress = awsTemplateOptions.isPublicIpAddressAssociated();
      if (subnetId != null) {
          if(associatePublicIpAddress){
              AWSRunInstancesOptions.class.cast(instanceOptions).associatePublicIpAddressAndSubnetId(subnetId);
              if (awsTemplateOptions.getGroupIds().size() > 0)
                 awsInstanceOptions.withSecurityGroupIdsForNetworkInterface(awsTemplateOptions.getGroupIds());
          }else{
              AWSRunInstancesOptions.class.cast(instanceOptions).withSubnetId(subnetId);
              if (awsTemplateOptions.getGroupIds().size() > 0)
                 awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
          }
      } else {
          if (awsTemplateOptions.getGroupIds().size() > 0)
             awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
         super.addSecurityGroups(region, group, template, instanceOptions);
      }
   }
View Full Code Here

         AWSEC2TemplateOptions awsOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
         LaunchSpecification spec = AWSRunInstancesOptions.class.cast(instanceOptions).getLaunchSpecificationBuilder()
               .imageId(template.getImage().getProviderId()).availabilityZone(zone).subnetId(awsOptions.getSubnetId())
               .iamInstanceProfileArn(awsOptions.getIAMInstanceProfileArn())
               .iamInstanceProfileName(awsOptions.getIAMInstanceProfileName()).build();
         RequestSpotInstancesOptions options = awsOptions.getSpotOptions();
         if (logger.isDebugEnabled())
            logger.debug(">> requesting %d spot instances region(%s) price(%f) spec(%s) options(%s)", count, region,
                     spotPrice, spec, options);
         return ImmutableSet.<RunningInstance> copyOf(transform(client.getSpotInstanceServices()
               .requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter));
View Full Code Here

         LaunchSpecification spec = AWSRunInstancesOptions.class.cast(instanceOptions).getLaunchSpecificationBuilder()
               .imageId(template.getImage().getProviderId()).availabilityZone(zone).subnetId(awsOptions.getSubnetId())
                 .publicIpAddressAssociated(awsOptions.isPublicIpAddressAssociated())
               .iamInstanceProfileArn(awsOptions.getIAMInstanceProfileArn())
               .iamInstanceProfileName(awsOptions.getIAMInstanceProfileName()).build();
         RequestSpotInstancesOptions options = awsOptions.getSpotOptions();
         if (logger.isDebugEnabled())
            logger.debug(">> requesting %d spot instances region(%s) price(%f) spec(%s) options(%s)", count, region,
                     spotPrice, spec, options);
         return ImmutableSet.<RunningInstance> copyOf(transform(client.getSpotInstanceApi().get()
               .requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter));
View Full Code Here

   @Override
   @BeforeClass(groups = { "integration", "live" })
   public void setupContext() {
      super.setupContext();
      client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi();
      availableTester = retry(new PlacementGroupAvailable(client), 60, 1, SECONDS);
      deletedTester = retry(new PlacementGroupDeleted(client), 60, 1, SECONDS);
   }
View Full Code Here

   @BeforeClass(groups = { "integration", "live" })
   public void setupContext() {
      super.setupContext();
      client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi();
      availableTester = retry(new PlacementGroupAvailable(client), 60, 1, SECONDS);
      deletedTester = retry(new PlacementGroupDeleted(client), 60, 1, SECONDS);
   }
View Full Code Here

   @Override
   @BeforeClass(groups = { "integration", "live" })
   public void setupContext() {
      super.setupContext();
      client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi();
      activeTester = retry(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, SECONDS);
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   @Test
   public void testWhenInstancesPresentSingleCall() {

      AWSEC2Client client = createMock(AWSEC2Client.class);
      AWSInstanceClient instanceClient = createMock(AWSInstanceClient.class);
      Function<SpotInstanceRequest, AWSRunningInstance> converter = createMock(Function.class);

      expect(client.getInstanceServices()).andReturn(instanceClient);
     
      // avoid imatcher fail.  if you change this, be sure to check multiple jres
      expect(instanceClient.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn(
            Set.class.cast(ImmutableSet.of(Reservation.<AWSRunningInstance> builder().region("us-east-1")
                  .instances(ImmutableSet.of(instance1, instance2)).build())));

      replay(client, instanceClient, converter);
View Full Code Here

            .build();

   @Test
   public void testApply() {
      AWSEC2Client client = createMock(AWSEC2Client.class);
      AWSKeyPairClient keyClient = createMock(AWSKeyPairClient.class);

      expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce();

      expect(keyClient.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andReturn(pair);

      replay(client);
      replay(keyClient);

      ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client);
View Full Code Here

TOP

Related Classes of org.jclouds.aws.ec2.compute.functions.RunningInstanceToNodeMetadata$FindImageForInstance

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.