@Test(groups = "live", enabled = true)
  public void testCreateServiceOffering() throws Exception {
    skipIfNotGlobalAdmin();

    String name = prefix + "-test-create-service-offering";
    String displayText = name + "-display";
    ServiceOffering offering = null;
    try {
      offering =
          globalAdminClient
              .getOfferingApi()
              .createServiceOffering(
                  name,
                  displayText,
                  2,
                  1024,
                  2048,
                  highlyAvailable(true).storageType(StorageType.LOCAL));
      Logger.CONSOLE.info("Created Service Offering: " + offering);

      assertEquals(offering.getName(), name);
      assertEquals(offering.getDisplayText(), displayText);
      checkServiceOffering(offering);

      offering =
          globalAdminClient
              .getOfferingApi()
              .updateServiceOffering(
                  offering.getId(),
                  UpdateServiceOfferingOptions.Builder.name(name + "-2")
                      .displayText(displayText + "-2"));

      assertEquals(offering.getName(), name + "-2");
      assertEquals(offering.getDisplayText(), displayText + "-2");
      checkServiceOffering(offering);

    } finally {
      if (offering != null) {
        globalAdminClient.getOfferingApi().deleteServiceOffering(offering.getId());
      }
    }
  }
예제 #2
0
  @Test
  public void testListTemplates() throws Exception {
    Set<Template> response = client.getTemplateClient().listTemplates();
    assert null != response;
    long templateCount = response.size();
    assertTrue(templateCount >= 0);
    for (Template template : response) {
      Template newDetails =
          Iterables.getOnlyElement(
              client
                  .getTemplateClient()
                  .listTemplates(zoneId(template.getZoneId()).id(template.getId())));
      Logger.CONSOLE.info("Checking template: " + template);

      assertEquals(template, newDetails);
      assertEquals(
          template,
          client.getTemplateClient().getTemplateInZone(template.getId(), template.getZoneId()));
      assert template.getId() > 0 : template;
      assert template.getName() != null : template;
      assert template.getDisplayText() != null : template;
      assert template.getCreated() != null : template;
      assert template.getFormat() != null && template.getFormat() != Template.Format.UNRECOGNIZED
          : template;
      assert template.getOSType() != null : template;
      assert template.getOSTypeId() > 0 : template;
      assert template.getAccount() != null : template;
      assert template.getZone() != null : template;
      assert template.getZoneId() > 0 : template;
      assert (template.getStatus() == null || template.getStatus().equals("Download Complete"))
          : template;
      assert template.getType() != null && template.getType() != Template.Type.UNRECOGNIZED
          : template;
      assert template.getHypervisor() != null : template;
      assert template.getDomain() != null : template;
      assert template.getDomainId() > 0 : template;
      assert template.getSize() > 0 : template;
    }
  }