Package org.jclouds.joyent.cloudapi.v6_5

Examples of org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi


   }

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


         String expectedImageId, OperatingSystem expectedOs, Image existingImage) {

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

      assertEquals(machineToConvert.getName(), convertedNodeMetadata.getName());
      assertEquals(convertedNodeMetadata.getGroup(), "sample");

      assertEquals(convertedNodeMetadata.getImageId(), expectedImageId);
      assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);

      assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);

      assertEquals(JoyentCloudComputeServiceContextModule.toPortableNodeStatus.get(machineToConvert.getState()),
            convertedNodeMetadata.getStatus());

      assertNotNull(convertedNodeMetadata.getPrivateAddresses());
      assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.224.0.63"));
View Full Code Here

   @Override
   public NodeMetadata apply(MachineInDatacenter machineInDatacenter) {
      Location zone = locationIndex.get().get(machineInDatacenter.getDatacenter());
      checkState(zone != null, "location %s not in locationIndex: %s", machineInDatacenter.getDatacenter(),
            locationIndex.get());
      Machine from = machineInDatacenter.get();

      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.id(machineInDatacenter.slashEncode());
      builder.providerId(from.getId());
      builder.name(from.getName());
      builder.hostname(from.getId());
      builder.location(zone);
      Map<String, String> metadataMap = filterKeys(from.getMetadata(), new Predicate<String>() {

         @Override
         public boolean apply(String input) {
            // TODO make this more efficient
            for (Metadata key : Metadata.values())
               if (key.key().equals(input))
                  return false;
            return true;
         }

      });
      addMetadataAndParseTagsFromCommaDelimitedValue(builder, metadataMap);

      builder.group(groupFromMapOrName(metadataMap, from.getName(), nodeNamingConvention));

      builder.imageId(DatacenterAndName.fromDatacenterAndName(machineInDatacenter.getDatacenter(), from.getDatasetURN())
            .slashEncode());
      builder.operatingSystem(findOperatingSystemForMachineOrNull(machineInDatacenter));
      builder.hardware(findHardwareForMachineOrNull(machineInDatacenter));
      builder.status(toPortableNodeStatus.get(from.getState()));
      builder.publicAddresses(filter(from.getIps(), not(InetAddresses2.IsPrivateIPAddress.INSTANCE)));
      builder.privateAddresses(filter(from.getIps(), InetAddresses2.IsPrivateIPAddress.INSTANCE));
      return builder.build();
   }
View Full Code Here

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

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

   }
View Full Code Here

         String expectedImageId, OperatingSystem expectedOs, Image existingImage) {

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

      assertEquals(machineToConvert.getName(), convertedNodeMetadata.getName());
      assertEquals(convertedNodeMetadata.getGroup(), "sample");

      assertEquals(convertedNodeMetadata.getImageId(), expectedImageId);
      assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);

      assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);

      assertEquals(JoyentCloudComputeServiceContextModule.toPortableNodeStatus.get(machineToConvert.getState()),
            convertedNodeMetadata.getStatus());

      assertNotNull(convertedNodeMetadata.getPrivateAddresses());
      assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.224.0.63"));
View Full Code Here

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

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

   }
View Full Code Here

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

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

TOP

Related Classes of org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi

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.