Package org.jclouds.aws.ec2.features

Examples of org.jclouds.aws.ec2.features.AWSKeyPairApi


            LoginCredentials.builder().user("foo").privateKey(CREDENTIALS.credential).build());
      KeyPair keyPair = new KeyPair(region, group, "//TODO", null, null);

      // setup expectations
      expect(
            strategy.importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group,
                  CREDENTIALS.credential))).andReturn(keyPair);
      expect(
            strategy.credentialsMap.put(new RegionAndName(region, group),
                  keyPair.toBuilder().keyMaterial(CREDENTIALS.credential).build())).andReturn(null);
View Full Code Here


      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();

      KeyPair keyPair = new KeyPair(region, "jclouds#" + group, "fingerprint", null, null);

      // setup expectations
      expect(strategy.importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group, "ssh-rsa")))
            .andReturn(keyPair);
      expect(strategy.credentialsMap.put(new RegionAndName(region, group), keyPair)).andReturn(null);

      // replay mocks
      replayStrategy(strategy);
View Full Code Here

      for (String region : Region.DEFAULT_REGIONS) {
         SortedSet<SpotInstanceRequest> allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceServices()
                  .describeSpotInstanceRequestsInRegion(region));
         assertNotNull(allResults);
         if (allResults.size() >= 1) {
            SpotInstanceRequest request = allResults.last();
            SortedSet<SpotInstanceRequest> result = ImmutableSortedSet.copyOf(client.getSpotInstanceServices()
                     .describeSpotInstanceRequestsInRegion(region, request.getId()));
            assertNotNull(result);
            SpotInstanceRequest compare = result.last();
            assertEquals(compare, request);
         }
      }

   }
View Full Code Here

      for (SpotInstanceRequest request : requests)
         verifySpotInstance(request);
   }

   private void verifySpotInstance(SpotInstanceRequest request) {
      SpotInstanceRequest spot = refresh(request);
      assertNotNull(spot);
      assertEquals(spot, request);
      assert activeTester.apply(request) : refresh(request);
      System.out.println(System.currentTimeMillis() - start);
      spot = refresh(request);
      assert spot.getInstanceId() != null : spot;
      instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(spot.getRegion(),
               spot.getInstanceId())));
      assertEquals(instance.getSpotInstanceRequestId(), spot.getId());
   }
View Full Code Here

   @Override
   public RunningInstance getRunningInstanceInRegion(String region, String id) {
      if (id.indexOf("sir-") != 0)
         return super.getRunningInstanceInRegion(region, id);
      SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(
               region, id));
      if (spot.getState() == SpotInstanceRequest.State.ACTIVE)
         return super.getRunningInstanceInRegion(region, spot.getInstanceId());
      else
         return spotConverter.apply(spot);
   }
View Full Code Here

    String ec2Msg = " ec2. Region: " + region + " - Key Pair Name: ";

    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
   
    AWSKeyPairApi keyPairApi = context.unwrapApi(AWSEC2Api.class).getKeyPairApiForRegion(region).get();

    KeyPair keyPair = keyPairApi.importKeyPairInRegion(region, keyPairName, publicKey);
   
    if (keyPair != null) {

      iaasInfo.getTemplate().getOptions().as(AWSEC2TemplateOptions.class)
          .keyPair(keyPair.getKeyName());
View Full Code Here

            .build();

   @Test
   public void testApply() {
      AWSEC2Api client = createMock(AWSEC2Api.class);
      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

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

      replay(client);
      replay(keyApi);

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

   }

   @Test
   public void testApplyWithIllegalStateExceptionReturnsExistingKey() {
      AWSEC2Api client = createMock(AWSEC2Api.class);
      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
               new IllegalStateException());
      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.of(pair));

      replay(client);
      replay(keyApi);

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

   }

   @Test
   public void testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound() {
      AWSEC2Api client = createMock(AWSEC2Api.class);
      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
               new IllegalStateException());
      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of());
      expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow(
               new IllegalStateException());
      expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.<KeyPair> of(pair));

      replay(client);
      replay(keyApi);

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

            .build();

   @Test
   public void testApply() {
      AWSEC2Api client = createMock(AWSEC2Api.class);
      AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class);

      expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

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

      replay(client);
      replay(keyApi);

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

TOP

Related Classes of org.jclouds.aws.ec2.features.AWSKeyPairApi

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.