@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")));
  }
Exemplo n.º 2
0
 @Override
 public boolean apply(Instance input) {
   if (emptyString.equals(input.getProductCodes())) input.getProductCodes().clear();
   if (input.getIp() != null && "".equals(input.getIp().trim())) input.setIp(null);
   else if (input.getIp() != null && input.getIp().endsWith(" "))
     input.setIp(input.getIp().trim());
   if (input.getHostname() != null && "".equals(input.getHostname().trim()))
     input.setHostname(null);
   else if (input.getHostname() != null && input.getHostname().endsWith(" "))
     input.setHostname(input.getHostname().trim());
   return true;
 }
  @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()));
  }
 private void assertIpHostAndStatusACTIVE(Instance instance) {
   assertNotNull(instance.getIp());
   assertNotNull(instance.getHostname());
   assertEquals(instance.getStatus(), Instance.Status.ACTIVE);
 }
 private void assertIpHostNullAndStatusNEW(Instance instance) {
   assertEquals(instance.getIp(), null);
   assertEquals(instance.getHostname(), null);
   assertEquals(instance.getStatus(), Instance.Status.NEW);
 }