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

Examples of org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions$Builder


      for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) {
         MachineApi api = cloudApiContext.getApi().getMachineApiForDatacenter(datacenterId);
         Set<Machine> response = api.list();
         assert null != response;
         for (Machine machine : response) {
            Machine newDetails = api.get(machine.getId());
            assertEquals(newDetails.getId(), machine.getId());
            assertEquals(newDetails.getName(), machine.getName());
            assertEquals(newDetails.getType(), machine.getType());
            assertEquals(newDetails.getState(), machine.getState());
            assertEquals(newDetails.getDatasetURN(), machine.getDatasetURN());
            assertEquals(newDetails.getMemorySizeMb(), machine.getMemorySizeMb());
            assertEquals(newDetails.getDiskSizeGb(), machine.getDiskSizeGb());
            assertEquals(newDetails.getIps(), machine.getIps());
            assertEquals(newDetails.getCreated(), machine.getCreated());
            assertEquals(newDetails.getUpdated(), machine.getUpdated());
            assertEquals(newDetails.getMetadata(), machine.getMetadata());
         }
      }
   }


         }
      }, 600, 5, 5, SECONDS);
   }

   public void testCreateMachine() {
      Machine newMachine = api.createWithDataset(datasetURN,
            CreateMachineOptions.Builder.metadata(ImmutableMap.of("foo", "bar")));
      machine = newMachine;
      name = newMachine.getName();

      assertEquals(newMachine.getMetadata().get("foo").toString(), "bar");
      assertTrue(
            newMachine.getMetadata().get(Metadata.ROOT_AUTHORIZED_KEYS.key()).indexOf(key.get("public")) != -1,
            newMachine + "; key: " + key.get("public"));

      assertTrue(machineRunning.apply(newMachine), newMachine.toString());
      machine = api.get(newMachine.getId());

   }

      for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) {
         PackageApi api = cloudApiContext.getApi().getPackageApiForDatacenter(datacenterId);
         Set<Package> response = api.list();
         assert null != response;
         for (Package pkg : response) {
            Package newDetails = api.get(pkg.getName());
            assertEquals(newDetails.getName(), pkg.getName());
            assertEquals(newDetails.getMemorySizeMb(), pkg.getMemorySizeMb());
            assertEquals(newDetails.getDiskSizeGb(), pkg.getDiskSizeGb());
            assertEquals(newDetails.getSwapSizeMb(), pkg.getSwapSizeMb());
            assertEquals(newDetails.isDefault(), pkg.isDefault());
         }
      }
   }

      for (String datacenterId : cloudApiContext.getApi().getConfiguredDatacenters()) {
         PackageApi api = cloudApiContext.getApi().getPackageApiForDatacenter(datacenterId);
         Set<Package> response = api.list();
         assert null != response;
         for (Package pkg : response) {
            Package newDetails = api.get(pkg.getName());
            assertEquals(newDetails.getName(), pkg.getName());
            assertEquals(newDetails.getMemorySizeMb(), pkg.getMemorySizeMb());
            assertEquals(newDetails.getDiskSizeGb(), pkg.getDiskSizeGb());
            assertEquals(newDetails.getSwapSizeMb(), pkg.getSwapSizeMb());
            assertEquals(newDetails.isDefault(), pkg.isDefault());
         }
      }
   }

      return ImmutableSet.of();
   }

   @Override
   public MachineInDatacenter getNode(String id) {
      DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id);
      Machine machine = cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).get(
            datacenterAndId.getId());
      return machine == null ? null : new MachineInDatacenter(machine, datacenterAndId.getDatacenter());
   }

      return machine == null ? null : new MachineInDatacenter(machine, datacenterAndId.getDatacenter());
   }

   @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());
   }

      cloudApiApi.getMachineApiForDatacenter(machine.get().getDatacenter()).delete(machine.get().getId());
   }

   @Override
   public void rebootNode(String id) {
      DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id);
      cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).reboot(datacenterAndId.getId());
   }

      cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).reboot(datacenterAndId.getId());
   }

   @Override
   public void resumeNode(String id) {
      DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id);
      cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).start(datacenterAndId.getId());
   }

      cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).start(datacenterAndId.getId());
   }

   @Override
   public void suspendNode(String id) {
      DatacenterAndId datacenterAndId = DatacenterAndId.fromSlashEncoded(id);
      cloudApiApi.getMachineApiForDatacenter(datacenterAndId.getDatacenter()).stop(datacenterAndId.getId());
   }

   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);

TOP

Related Classes of org.jclouds.joyent.cloudapi.v6_5.compute.options.JoyentCloudTemplateOptions$Builder

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.