Package org.jclouds.openstack.nova.v2_0.extensions

Examples of org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi


public class CreateUniqueKeyPairTest {

   @Test
   public void testApply() throws UnknownHostException {
      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);
     
      expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);

      replay(api, keyApi);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here


   }

   @Test
   public void testApplyWithIllegalStateException() throws UnknownHostException {
      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);
      @SuppressWarnings("unchecked")
      final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);

      KeyPair pair = createMock(KeyPair.class);

      expect(api.getKeyPairExtensionForZone("zone")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

      expect(uniqueIdSupplier.get()).andReturn("1");
      expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
      expect(uniqueIdSupplier.get()).andReturn("2");
      expect(keyApi.create("group-2")).andReturn(pair);

      replay(api, keyApi, uniqueIdSupplier);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here

public class CreateUniqueKeyPairTest {

   @Test
   public void testApply() throws UnknownHostException {
      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);
     
      expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);

      replay(api, keyApi);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here

   }

   @Test
   public void testApplyWithIllegalStateException() throws UnknownHostException {
      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);
      @SuppressWarnings("unchecked")
      final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);

      KeyPair pair = createMock(KeyPair.class);

      expect(api.getKeyPairExtensionForZone("zone")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

      expect(uniqueIdSupplier.get()).andReturn("1");
      expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
      expect(uniqueIdSupplier.get()).andReturn("2");
      expect(keyApi.create("group-2")).andReturn(pair);

      replay(api, keyApi, uniqueIdSupplier);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here

      Optional<? extends KeyPairApi> keyPairApiExtension = novaApi.getKeyPairExtensionForZone(ZONE);

      if (keyPairApiExtension.isPresent()) {
         System.out.format("  Key Pair Extension Present%n");

         KeyPairApi keyPairApi = keyPairApiExtension.get();

         for (KeyPair keyPair: keyPairApi.list()) {
            System.out.format("    %s%n", keyPair.getName());
         }
      }
   }
View Full Code Here

    * Create a public key in the cloud and write the private key file to the local working directory.
    */
   private KeyPair createKeyPair() throws IOException {
      System.out.format("  Create Key Pair%n");

      KeyPairApi keyPairApi = novaApi.getKeyPairExtensionForZone(ZONE).get();
      KeyPair keyPair = keyPairApi.create(NAME);

      Files.write(keyPair.getPrivateKey(), keyPairFile, UTF_8);

      System.out.format("    Wrote %s%n", keyPairFile.getAbsolutePath());

View Full Code Here

    * Delete the public key in the cloud and the local private key.
    */
   private void deleteKeyPair(KeyPair keyPair) {
      System.out.format("  Delete Key Pair%n");

      KeyPairApi keyPairApi = novaApi.getKeyPairExtensionForZone(ZONE).get();
      keyPairApi.delete(keyPair.getName());

      if (keyPairFile.delete()) {
         System.out.format("    Deleted %s%n", keyPairFile.getAbsolutePath());
      }
      else {
View Full Code Here

public class CreateUniqueKeyPairTest {

   @Test
   public void testApply() throws UnknownHostException {
      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);

      expect(api.getKeyPairApi("region")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);

      replay(api, keyApi);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here

   }

   @Test
   public void testApplyWithIllegalStateException() throws UnknownHostException {
      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);
      @SuppressWarnings("unchecked")
      final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);

      KeyPair pair = createMock(KeyPair.class);

      expect(api.getKeyPairApi("region")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();

      expect(uniqueIdSupplier.get()).andReturn("1");
      expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
      expect(uniqueIdSupplier.get()).andReturn("2");
      expect(keyApi.create("group-2")).andReturn(pair);

      replay(api, keyApi, uniqueIdSupplier);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here

      ImageApi imageApi = api.getImageApiForZone(zoneId);
      return Iterables.getLast(imageApi.list().concat()).getId();
   }

   protected String flavorRefForZone(String zoneId) {
      FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
      return DEFAULT_FLAVOR_ORDERING.min(flavorApi.listInDetail().concat()).getId();
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi

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.