public Image resolveImage(Image image) throws OpenstackException {
    if (image == null) {
      return null;
    }

    return getLinkResolver().resolveImage(image.getId(), image.getLinks());
  }
示例#2
0
  @Test
  public void createServer() throws Exception {

    try {
      Flavor bestFlavor = null;
      for (Flavor flavor : compute.flavors().get().getList()) {
        if (bestFlavor == null || bestFlavor.getRam() > flavor.getRam()) {
          bestFlavor = flavor;
        }
      }

      Image image =
          Iterables.find(
              compute.images().get().getList(),
              new Predicate<Image>() {

                @Override
                public boolean apply(Image image) {
                  return "cirros-0.3.0-x86_64-uec".equals(image.getName());
                }
              });

      NovaServerForCreate serverForCreate = new NovaServerForCreate();
      serverForCreate.setName(random.randomAlphanumericString(10));
      serverForCreate.setFlavorRef(findSmallestFlavor().getId());
      serverForCreate.setImageRef(image.getId());
      // serverForCreate.setSecurityGroups(new ArrayList<ServerForCreate.SecurityGroup>() {{
      // add(new ServerForCreate.SecurityGroup("test"));
      // }});
      System.out.println(serverForCreate);

      server = compute.servers().post(serverForCreate);
      waitForState("ACTIVE");
    } catch (NoSuchElementException e) {
      throw new SkipException("Skipping test because image not found");
    }
  }