Package org.jclouds.openstack.nova.v2_0.domain

Examples of org.jclouds.openstack.nova.v2_0.domain.KeyPair$ConcreteBuilder


   }

   public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
      for (String zoneId : api.getConfiguredZones()) {
         KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
         KeyPair createdKeyPair = null;
         try {
            createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
            assertNotNull(createdKeyPair);

            KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME);
            assertEquals(keyPair.getName(), createdKeyPair.getName());
            assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint());
            assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey());
         } finally {
            if (createdKeyPair != null) {
               keyPairApi.delete(KEYPAIR_NAME);
            }
         }
View Full Code Here


      }

      Optional<String> privateKey = Optional.absent();
      if (templateOptions.getKeyPairName() != null) {
         options.keyPairName(templateOptions.getKeyPairName());
         KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
         if (keyPair != null && keyPair.getPrivateKey() != null) {
            privateKey = Optional.of(keyPair.getPrivateKey());
            credentialsBuilder.privateKey(privateKey.get());
         }
      }

      String zoneId = template.getLocation().getId();
View Full Code Here

      boolean keyPairExtensionPresent = novaApi.getKeyPairExtensionForZone(zone).isPresent();
      if (templateOptions.shouldGenerateKeyPair()) {
         checkArgument(keyPairExtensionPresent,
                  "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
         KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create()
                  .sharedNameForGroup(group)));
         keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
         templateOptions.keyPairName(keyPair.getName());
      } else if (templateOptions.getKeyPairName() != null) {
         checkArgument(keyPairExtensionPresent,
                  "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
         if (templateOptions.getLoginPrivateKey() != null) {
            String pem = templateOptions.getLoginPrivateKey();
            KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName())
                     .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
            keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
         }
      }

      boolean securityGroupExtensionPresent = novaApi.getSecurityGroupExtensionForZone(zone).isPresent();
      List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
View Full Code Here

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

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

      options.userData(templateOptions.getUserData());

      Optional<String> privateKey = Optional.absent();
      if (templateOptions.getKeyPairName() != null) {
         options.keyPairName(templateOptions.getKeyPairName());       
         KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
         if (keyPair != null && keyPair.getPrivateKey() != null) {
            privateKey = Optional.of(keyPair.getPrivateKey());
            credentialsBuilder.privateKey(privateKey.get());
         }
      }

      String zoneId = template.getLocation().getId();
View Full Code Here

      checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
            zoneId);

      logger.debug(">> creating keyPair zone(%s) prefix(%s)", zoneId, prefix);

      KeyPair keyPair = null;
      while (keyPair == null) {
         try {
            keyPair = api.get().create(namingConvention.createWithoutPrefix().uniqueNameForGroup(prefix));
         } catch (IllegalStateException e) {

         }
      }

      logger.debug("<< created keyPair(%s)", keyPair.getName());
      return keyPair;
   }
View Full Code Here

   public void testCreateAndDeleteKeyPair() throws Exception {
      final String KEYPAIR_NAME = "testkp";
      for (String zoneId : api.getConfiguredZones()) {
         KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
         KeyPair keyPair = null;
         try {
            keyPair = keyPairApi.create(KEYPAIR_NAME);
            assertNotNull(keyPair);
         } finally {
            if (keyPair != null) {
View Full Code Here

      final String KEYPAIR_NAME = "testkp";
      final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";

      for (String zoneId : api.getConfiguredZones()) {
         KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
         KeyPair keyPair = null;
         try {
            keyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
            assertNotNull(keyPair);
         } finally {
            if (keyPair != null) {
View Full Code Here

      boolean keyPairExtensionPresent = novaApi.getKeyPairExtensionForZone(zone).isPresent();
      if (templateOptions.shouldGenerateKeyPair()) {
         checkArgument(keyPairExtensionPresent,
                  "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
         KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create()
                  .sharedNameForGroup(group)));
         keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
         templateOptions.keyPairName(keyPair.getName());
      } else if (templateOptions.getKeyPairName() != null) {
         checkArgument(keyPairExtensionPresent,
                  "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
         if (templateOptions.getLoginPrivateKey() != null) {
            String pem = templateOptions.getLoginPrivateKey();
            KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName())
                     .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
            keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
         }
      }

      boolean securityGroupExtensionPresent = novaApi.getSecurityGroupExtensionForZone(zone).isPresent();
      List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.KeyPair$ConcreteBuilder

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.