Package org.jclouds.joyent.cloudapi.v6_5.features

Examples of org.jclouds.joyent.cloudapi.v6_5.features.KeyApi


      Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
      Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
            .of(existingHardware);
      Machine machineToConvert = new ParseCreatedMachineTest().expected();

      MachineInDatacenter machineInDatacenterToConvert = new MachineInDatacenter(machineToConvert, "us-sw-1");

      MachineInDatacenterToNodeMetadata converter = new MachineInDatacenterToNodeMetadata(
            JoyentCloudComputeServiceContextModule.toPortableNodeStatus, locationIndex,
            Suppliers.<Set<? extends Image>> ofInstance(images),
            Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);

      NodeMetadata convertedNodeMetadata = converter.apply(machineInDatacenterToConvert);

      assertEquals(machineInDatacenterToConvert.slashEncode(), convertedNodeMetadata.getId());
      assertEquals(machineToConvert.getId(), convertedNodeMetadata.getProviderId());

      assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.ZONE);
      assertEquals(convertedNodeMetadata.getLocation().getId(), "us-sw-1");
View Full Code Here


      Builder<PackageInDatacenter> builder = ImmutableSet.builder();
      for (final String datacenterId : datacenterIds.get()) {
         builder.addAll(transform(cloudApiApi.getPackageApiForDatacenter(datacenterId).list(),
               new Function<org.jclouds.joyent.cloudapi.v6_5.domain.Package, PackageInDatacenter>() {
                  public PackageInDatacenter apply(org.jclouds.joyent.cloudapi.v6_5.domain.Package arg0) {
                     return new PackageInDatacenter(arg0, datacenterId);
                  }
               }));
      }
      return builder.build();
   }
View Full Code Here

         .diskSizeGb(30720).swapSizeMb(2048).isDefault(true).build();

   @Test
   public void testConversionWhereLocationFound() {

      PackageInDatacenter packageInZoneToConvert = new PackageInDatacenter(packageToConvert, "us-sw-1");

      Hardware converted = new PackageInDatacenterToHardware(locationIndex).apply(packageInZoneToConvert);

      assertEquals(converted.getName(), packageToConvert.getName());
      assertEquals(converted.getId(), packageInZoneToConvert.slashEncode());
      assertEquals(converted.getProviderId(), packageToConvert.getName());
      assertEquals(converted.getLocation(), locationIndex.get().get("us-sw-1"));

      assertEquals(converted.getRam(), packageToConvert.getMemorySizeMb());
View Full Code Here

   }

   @Test(expectedExceptions = IllegalStateException.class)
   public void testConversionWhereLocationNotFound() {

      PackageInDatacenter packageInZoneToConvert = new PackageInDatacenter(packageToConvert, "South");
      new PackageInDatacenterToHardware(locationIndex).apply(packageInZoneToConvert);
   }
View Full Code Here

         .diskSizeGb(30720).swapSizeMb(2048).isDefault(true).build();

   @Test
   public void testConversionWhereLocationFound() {

      PackageInDatacenter packageInZoneToConvert = new PackageInDatacenter(packageToConvert, "us-sw-1");

      Hardware converted = new PackageInDatacenterToHardware(locationIndex).apply(packageInZoneToConvert);

      assertEquals(converted.getName(), packageToConvert.getName());
      assertEquals(converted.getId(), packageInZoneToConvert.slashEncode());
      assertEquals(converted.getProviderId(), packageToConvert.getName());
      assertEquals(converted.getLocation(), locationIndex.get().get("us-sw-1"));

      assertEquals(converted.getRam(), packageToConvert.getMemorySizeMb());
View Full Code Here

   }

   @Test(expectedExceptions = IllegalStateException.class)
   public void testConversionWhereLocationNotFound() {

      PackageInDatacenter packageInZoneToConvert = new PackageInDatacenter(packageToConvert, "South");
      new PackageInDatacenterToHardware(locationIndex).apply(packageInZoneToConvert);
   }
View Full Code Here

         public Map<String, String> get() {
            return keyPair;
         }

      };
      KeyApi keyApi = createMock(KeyApi.class);
      Key key = Key.builder().name("group-foo").key(keyPair.get("public")).build();

      expect(cloudApiApi.getKeyApi()).andReturn(keyApi);

      expect(keyApi.create(key)).andReturn(key);

      replay(cloudApiApi, keyApi);

      CreateUniqueKey parser = new CreateUniqueKey(cloudApiApi, namingConvention, sshKeyPairGenerator);
View Full Code Here

         cleanupOrphanedKeysInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
      }
   }

   private void cleanupOrphanedKeysInZone(Set<String> groups, String datacenterId) {
      KeyApi keyApi = novaApi.getKeyApi();
      for (String group : groups) {
         for (Key key : Iterables.filter(keyApi.list(),
               KeyPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
            DatacenterAndName datacenterAndName = DatacenterAndName.fromDatacenterAndName(datacenterId, key.getName());
            logger.debug(">> deleting key(%s)", datacenterAndName);
            keyApi.delete(key.getName());
            // TODO: test this clear happens
            keyCache.invalidate(datacenterAndName);
            logger.debug("<< deleted key(%s)", datacenterAndName);
         }
View Full Code Here

         public Map<String, String> get() {
            return keyPair;
         }

      };
      KeyApi keyApi = createMock(KeyApi.class);
      Key key = Key.builder().name("group-foo").key(keyPair.get("public")).build();

      expect(cloudApiApi.getKeyApi()).andReturn(keyApi);

      expect(keyApi.create(key)).andReturn(key);

      replay(cloudApiApi, keyApi);

      CreateUniqueKey parser = new CreateUniqueKey(cloudApiApi, namingConvention, sshKeyPairGenerator);
View Full Code Here

         cleanupOrphanedKeysInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
      }
   }

   private void cleanupOrphanedKeysInZone(Set<String> groups, String datacenterId) {
      KeyApi keyApi = novaApi.getKeyApi();
      for (String group : groups) {
         for (Key key : Iterables.filter(keyApi.list(),
               KeyPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
            DatacenterAndName datacenterAndName = DatacenterAndName.fromDatacenterAndName(datacenterId, key.getName());
            logger.debug(">> deleting key(%s)", datacenterAndName);
            keyApi.delete(key.getName());
            // TODO: test this clear happens
            keyCache.invalidate(datacenterAndName);
            logger.debug("<< deleted key(%s)", datacenterAndName);
         }
View Full Code Here

TOP

Related Classes of org.jclouds.joyent.cloudapi.v6_5.features.KeyApi

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.