コード例 #1
0
 @Test
 public void testGetImage() throws Exception {
   Set<? extends Image> response = connection.listImages();
   assertNotNull(response);
   if (response.size() > 0) {
     Image image = Iterables.get(response, 0);
     assertEquals(connection.getImage(image.getId()).getId(), image.getId());
   }
 }
コード例 #2
0
  @Test(dependsOnMethods = "testGetLocation")
  public void resolveImageAndInstanceType() throws Exception {
    Iterable<? extends Image> imagesThatAreInOurLocationAndNotBYOL =
        filter(
            connection.listImages(),
            new Predicate<Image>() {
              @Override
              public boolean apply(Image arg0) {
                return arg0.getLocation().equals(location.getId())
                    && arg0.getPlatform().equals(PLATFORM)
                    && !arg0.getName().contains("BYOL")
                    && !arg0.getName().contains("PAYG");
              }
            });

    Ordering<InstanceType> cheapestOrdering =
        new Ordering<InstanceType>() {
          public int compare(InstanceType left, InstanceType right) {
            return ComparisonChain.start()
                .compare(left.getPrice().getRate(), right.getPrice().getRate())
                .result();
          }
        }.reverse();

    Set<InstanceType> instanceTypes = Sets.newLinkedHashSet();

    for (Image image : imagesThatAreInOurLocationAndNotBYOL)
      Iterables.addAll(instanceTypes, image.getSupportedInstanceTypes());

    instanceType = cheapestOrdering.max(instanceTypes);

    final InstanceType cheapestInstanceType = instanceType;
    System.err.println(cheapestInstanceType);

    image =
        Iterables.find(
            imagesThatAreInOurLocationAndNotBYOL,
            new Predicate<Image>() {

              @Override
              public boolean apply(Image arg0) {
                return arg0.getSupportedInstanceTypes().contains(cheapestInstanceType);
              }
            });
    System.err.println(image);
    connection.getManifest(connection.getImage(image.getId()).getManifest());
    connection.getManifest(connection.getImage(image.getId()).getDocumentation());
  }
コード例 #3
0
  @Test(
      dependsOnMethods = {
        "testAddPublicKey",
        "testAllocateIpAddress",
        "testCreateVolume",
        "resolveImageAndInstanceType"
      })
  public void testCreateInstanceWithIpAndVolume() throws Exception {
    String name = TAG + "1";
    killInstance(name);

    instance2 =
        connection.createInstanceInLocation(
            location.getId(),
            name,
            image.getId(),
            instanceType.getId(),
            attachIp(ip.getId())
                .authorizePublicKey(key.getName())
                .mountVolume(volume.getId(), "/mnt"));

    assertBeginState(instance2, name);
    assertIpHostAndStatusNEW(instance2);
    blockUntilRunning(instance2);
    instance2 = assertRunning(instance2, name);

    volume = connection.getVolume(volume.getId());
    assertEquals(volume.getInstanceId(), instance2.getId());

    refreshIpAndReturnAllAddresses();
    assertEquals(ip.getInstanceId(), instance2.getId());
    assertEquals(ip.getIp(), instance2.getIp());
    sshAndDf(
        new IPSocket(instance2.getIp(), 22), new Credentials("idcuser", keyPair.get("private")));
  }
コード例 #4
0
 private void assertConsistent(Instance instance, String name) {
   assertNotNull(instance.getId());
   assertEquals(instance.getName(), name);
   assertEquals(instance.getInstanceType(), instanceType.getId());
   assertEquals(instance.getLocation(), location.getId());
   assertEquals(instance.getImageId(), image.getId());
   assertEquals(instance.getSoftware(), SOFTWARE);
   assertEquals(instance.getKeyName(), key.getName());
   assertNotNull(instance.getLaunchTime());
   assertNotNull(instance.getExpirationTime());
   assertEquals(instance.getOwner(), identity);
   assertEquals(instance.getProductCodes(), ImmutableSet.<String>of());
   assertEquals(instance.getRequestName(), name);
   assertNotNull(instance.getRequestId());
 }
コード例 #5
0
  @Test(dependsOnMethods = {"testAddPublicKey", "resolveImageAndInstanceType"})
  public void testCreateInstance() throws Exception {
    killInstance(TAG);

    instance =
        connection.createInstanceInLocation(
            location.getId(),
            TAG,
            image.getId(),
            instanceType.getId(),
            authorizePublicKey(key.getName()));

    assertBeginState(instance, TAG);
    assertIpHostNullAndStatusNEW(instance);
    blockUntilRunning(instance);
    instance = assertRunning(instance, TAG);
    sshAndDf(new IPSocket(instance.getIp(), 22), new Credentials("idcuser", key.getKeyMaterial()));
  }
コード例 #6
0
ファイル: ParseUtils.java プロジェクト: kohsuke/jclouds
 @Override
 public boolean apply(Image input) {
   if (emptyString.equals(input.getProductCodes())) input.getProductCodes().clear();
   return true;
 }