Package org.jclouds.joyent.cloudapi.v6_5.compute.functions

Examples of org.jclouds.joyent.cloudapi.v6_5.compute.functions.OrphanedGroupsByDatacenterId


     
      if (!templateOptions.shouldGenerateKey().isPresent())
         templateOptions.generateKey(defaultToAutogenerateKeys);

      if (templateOptions.shouldGenerateKey().get()) {
         KeyAndPrivateKey keyPair = keyCache.getUnchecked(DatacenterAndName.fromDatacenterAndName(datacenter, namingConvention.create()
               .sharedNameForGroup(group)));
         // in order to delete the key later
         keyCache.asMap().put(DatacenterAndName.fromDatacenterAndName(datacenter, keyPair.getKey().getName()), keyPair);
         templateOptions.overrideLoginPrivateKey(keyPair.getPrivateKey());
      }
      checkArgument(templateOptions.getRunScript() == null || templateOptions.getLoginPrivateKey() != null,
            "when specifying runScript, you must either set overrideLoginPrivateKey, or generateKey(true)");
      return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses);
   }
View Full Code Here


   public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
         Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {

      Template mutableTemplate = template.clone();

      JoyentCloudTemplateOptions templateOptions = JoyentCloudTemplateOptions.class.cast(mutableTemplate.getOptions());

      assert template.getOptions().equals(templateOptions) : "options didn't clone properly";

      templateOptions.userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);

      String datacenter = mutableTemplate.getLocation().getId();
     
      if (!templateOptions.shouldGenerateKey().isPresent())
         templateOptions.generateKey(defaultToAutogenerateKeys);

      if (templateOptions.shouldGenerateKey().get()) {
         KeyAndPrivateKey keyPair = keyCache.getUnchecked(DatacenterAndName.fromDatacenterAndName(datacenter, namingConvention.create()
               .sharedNameForGroup(group)));
         // in order to delete the key later
         keyCache.asMap().put(DatacenterAndName.fromDatacenterAndName(datacenter, keyPair.getKey().getName()), keyPair);
         templateOptions.overrideLoginPrivateKey(keyPair.getPrivateKey());
      }
      checkArgument(templateOptions.getRunScript() == null || templateOptions.getLoginPrivateKey() != null,
            "when specifying runScript, you must either set overrideLoginPrivateKey, or generateKey(true)");
      return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses);
   }
View Full Code Here

public class OrphanedGroupsByDatacenterId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> {
   private final Predicate<DatacenterAndName> allNodesInGroupTerminated;

   @Inject
   protected OrphanedGroupsByDatacenterId(ComputeService computeService) {
      this(new AllNodesInGroupTerminated(checkNotNull(computeService, "computeService")));
   }
View Full Code Here

@Test(testName = "DatasetToOperatingSystemTest")
public class DatasetToOperatingSystemTest {

   public void testCentos6() {

      Dataset datasetToConvert = new ParseDatasetTest().expected();

      OperatingSystem convertedOs = new DatasetToOperatingSystem(ImmutableMap.<OsFamily, Map<String, String>> of(
            OsFamily.CENTOS, ImmutableMap.of("6", "6.0"))).apply(datasetToConvert);

      assertEquals(convertedOs.getName(), datasetToConvert.getName());
      assertEquals(convertedOs.getFamily(), OsFamily.CENTOS);
      assertEquals(convertedOs.getDescription(), datasetToConvert.getUrn());
      assertEquals(convertedOs.getVersion(), "6.0");
      assertEquals(convertedOs.getArch(), null);
      assertTrue(convertedOs.is64Bit());
   }
View Full Code Here

   }

   @Override
   public DatasetInDatacenter getImage(String id) {
      DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id);
      Dataset dataset = cloudApiApi.getDatasetApiForDatacenter(datacenterAndId.getDatacenter()).get(
            datacenterAndId.getId());
      return dataset == null ? null : new DatasetInDatacenter(dataset, datacenterAndId.getDatacenter());
   }
View Full Code Here

   @Override
   public Image apply(DatasetInDatacenter datasetInDatacenter) {
      Location location = locationIndex.get().get(datasetInDatacenter.getDatacenter());
      checkState(location != null, "location %s not in locationIndex: %s", datasetInDatacenter.getDatacenter(),
            locationIndex.get());
      Dataset dataset = datasetInDatacenter.get();
      return new ImageBuilder()
            .id(datasetInDatacenter.slashEncode())
            // note that it is urn that is the expected value!
            .providerId(dataset.getUrn())
            .name(dataset.getName())
            .operatingSystem(imageToOs.apply(dataset))
            .description(dataset.getDescription())
            .version(dataset.getVersion())
            .location(location)
            .status(Image.Status.AVAILABLE).build();
   }
View Full Code Here

      for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) {
         DatasetApi api = cloudApiContext.getApi().getDatasetApiForDatacenter(datacenterId);
         Set<Dataset> response = api.list();
         assert null != response;
         for (Dataset dataset : response) {
            Dataset newDetails = api.get(dataset.getId());
            assertEquals(newDetails.getId(), dataset.getId());
            assertEquals(newDetails.getName(), dataset.getName());
            assertEquals(newDetails.getType(), dataset.getType());
            assertEquals(newDetails.getVersion(), dataset.getVersion());
            assertEquals(newDetails.getUrn(), dataset.getUrn());
            assertEquals(newDetails.getCreated(), dataset.getCreated());
            assertEquals(newDetails.isDefault(), dataset.isDefault());
         }
      }
   }
View Full Code Here

@Test(testName = "DatasetToOperatingSystemTest")
public class DatasetToOperatingSystemTest {

   public void testCentos6() {

      Dataset datasetToConvert = new ParseDatasetTest().expected();

      OperatingSystem convertedOs = new DatasetToOperatingSystem(ImmutableMap.<OsFamily, Map<String, String>> of(
            OsFamily.CENTOS, ImmutableMap.of("6", "6.0"))).apply(datasetToConvert);

      assertEquals(convertedOs.getName(), datasetToConvert.getName());
      assertEquals(convertedOs.getFamily(), OsFamily.CENTOS);
      assertEquals(convertedOs.getDescription(), datasetToConvert.getUrn());
      assertEquals(convertedOs.getVersion(), "6.0");
      assertEquals(convertedOs.getArch(), null);
      assertTrue(convertedOs.is64Bit());
   }
View Full Code Here

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

      String publicKey = keyPair.get("public");
      String privateKey = keyPair.get("private");

      logger.debug(">> creating key datacenter(%s) prefix(%s)", datacenterId, prefix);

      Key key = null;
      while (key == null) {
         String name = namingConvention.createWithoutPrefix().uniqueNameForGroup(prefix);
         try {
            key = cloudApiApi.getKeyApi().create(Key.builder().name(name).key(publicKey).build());
         } catch (IllegalStateException e) {
            logger.trace("error creating keypair named %s, %s", name, e.getMessage());
         }
      }

      logger.debug("<< created key(%s)", key.getName());
      return KeyAndPrivateKey.fromKeyAndPrivateKey(key, privateKey);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.joyent.cloudapi.v6_5.compute.functions.OrphanedGroupsByDatacenterId

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.