Package org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped

Examples of org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.KeyInDatacenter


   public void testListAndGetKeys() throws Exception {
      KeyApi api = cloudApiContext.getApi().getKeyApi();
      Set<Key> response = api.list();
      assert null != response;
      for (Key key : response) {
         Key newDetails = api.get(key.getName());
         assertEquals(newDetails.getName(), key.getName());
         assertEquals(newDetails.get(), key.get());
         assertEquals(newDetails.getCreated(), key.getCreated());
      }

   }
View Full Code Here


   }

   public void testCreateKey() {
      KeyApi api = cloudApiContext.getApi().getKeyApi();

      Key newKey = api.create(Key.builder().name(fingerprint).key(keyText).build());
      assertEquals(newKey.getName(), fingerprint);
      assertEquals(newKey.get(), keyText);

      newKey = api.get(fingerprint);
      assertEquals(newKey.getName(), fingerprint);
      assertEquals(newKey.get(), keyText);
   }
View Full Code Here

   public void testListAndGetKeys() throws Exception {
      KeyApi api = cloudApiContext.getApi().getKeyApi();
      Set<Key> response = api.list();
      assert null != response;
      for (Key key : response) {
         Key newDetails = api.get(key.getName());
         assertEquals(newDetails.getName(), key.getName());
         assertEquals(newDetails.get(), key.get());
         assertEquals(newDetails.getCreated(), key.getCreated());
      }

   }
View Full Code Here

   }

   public void testCreateKey() {
      KeyApi api = cloudApiContext.getApi().getKeyApi();

      Key newKey = api.create(Key.builder().name(fingerprint).key(keyText).build());
      assertEquals(newKey.getName(), fingerprint);
      assertEquals(newKey.get(), keyText);

      newKey = api.get(fingerprint);
      assertEquals(newKey.getName(), fingerprint);
      assertEquals(newKey.get(), keyText);
   }
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

      String datacenterId = template.getLocation().getId();
      String datasetURN = template.getImage().getProviderId();

      logger.debug(">> creating new machine datacenter(%s) datasetURN(%s) options(%s)", datacenterId, datasetURN,
            options);
      Machine machine = cloudApiApi.getMachineApiForDatacenter(datacenterId).createWithDataset(datasetURN, options);

      logger.trace("<< machine(%s)", machine.getId());

      MachineInDatacenter machineInDatacenter = new MachineInDatacenter(machine, datacenterId);

      //TODO machineInDatacenter.metadata for password
      if (template.getOptions().getLoginPrivateKey() != null){
View Full Code Here

   }

   @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

TOP

Related Classes of org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.KeyInDatacenter

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.