Package org.jclouds.vcloud.domain

Examples of org.jclouds.vcloud.domain.VAppTemplate


         Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
         for (ReferenceType resource : response.values()) {
            if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
               CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
               if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
                  VAppTemplate template = getVCloudApi().getVAppTemplateApi().getVAppTemplate(item.getEntity().getHref());
                  if (template != null) {
                     // the UUID in the href is the only way to actually link templates
                     assertEquals(template.getHref(), item.getEntity().getHref());
                  } else {
                     // null can be no longer available or auth exception
                  }
               }
            }
View Full Code Here


         Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
         for (ReferenceType resource : response.values()) {
            if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
               CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
               if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
                  VAppTemplate template = getVCloudApi().getVAppTemplateApi().findVAppTemplateInOrgCatalogNamed(
                           org.getName(), response.getName(), item.getEntity().getName());
                  if (template != null) {
                     // the UUID in the href is the only way to actually link templates
                     assertEquals(template.getHref(), item.getEntity().getHref());
                  } else {
                     // null can be no longer available or auth exception
                  }
               }
            }
View Full Code Here

   @Test
   public void testCaptureVApp() throws Exception {
      String group = prefix + "cap";
      NodeMetadata node = null;
      VAppTemplate vappTemplate = null;
      CatalogItem item = null;
      try {

         node = getOnlyElement(client.createNodesInGroup(group, 1));

         Predicate<URI> taskTester = retry(new TaskSuccess(getVCloudApi()), 600, 5, SECONDS);

         // I have to undeploy first
         Task task = getVCloudApi().getVAppApi().undeployVApp(URI.create(node.getId()));

         // wait up to ten minutes per above
         assert taskTester.apply(task.getHref()) : node;

         VApp vApp = getVCloudApi().getVAppApi().getVApp(URI.create(node.getId()));

         // wait up to ten minutes per above
         assertEquals(vApp.getStatus(), Status.OFF);

         // vdc is equiv to the node's location
         // vapp uri is the same as the node's id
         vappTemplate = getVCloudApi().getVAppTemplateApi().captureVAppAsTemplateInVDC(URI.create(node.getId()),
                  group, URI.create(node.getLocation().getId()));

         assertEquals(vappTemplate.getName(), group);

         task = vappTemplate.getTasks().get(0);

         // wait up to ten minutes per above
         assert taskTester.apply(task.getHref()) : vappTemplate;

         item = getVCloudApi().getCatalogApi().addVAppTemplateOrMediaImageToCatalogAndNameItem(
                  vappTemplate.getHref(),
                  getVCloudApi().getCatalogApi().findCatalogInOrgNamed(null, null).getHref(), "fooname",
                  CatalogItemOptions.Builder.description("description").properties(ImmutableMap.of("foo", "bar")));

         assertEquals(item.getName(), "fooname");
         assertEquals(item.getDescription(), "description");
         assertEquals(item.getProperties(), ImmutableMap.of("foo", "bar"));
         assertEquals(item.getEntity().getName(), "fooname");
         assertEquals(item.getEntity().getHref(), vappTemplate.getHref());
         assertEquals(item.getEntity().getType(), vappTemplate.getType());

      } finally {
         if (item != null)
            getVCloudApi().getCatalogApi().deleteCatalogItem(item.getHref());
         if (vappTemplate != null)
            getVCloudApi().getVAppTemplateApi().deleteVAppTemplate(vappTemplate.getHref());
         if (node != null)
            client.destroyNode(node.getId());
      }
   }
View Full Code Here

*/
@Test(groups = "unit")
public class VAppTemplateHandlerTest {

   public void testUbuntuTemplate() {
      VAppTemplate result = parseTemplate();
      assertEquals(result.getName(), "Ubuntu Template");
      assertEquals(result.getHref(), URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921"));
      assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
      assertEquals(result.getStatus(), Status.OFF);
      assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")));
      assertEquals(result.getDescription(), null);
      assertEquals(result.getTasks(), ImmutableList.of());
      assertEquals(result.getVAppScopedLocalId(), null);
      assert result.isOvfDescriptorUploaded();
      Vm vm = Iterables.getOnlyElement(result.getChildren());
      assertEquals(vm.getName(), "Ubuntu1004");
      assertEquals(vm.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194"));
      // NOTE this is vAppTemplate not VM!
      assertEquals(vm.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
      assertEquals(vm.getStatus(), null);
      assertEquals(vm.getParent(), new ReferenceTypeImpl(null, VCloudMediaType.VAPPTEMPLATE_XML, URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921")));
      assertEquals(vm.getDescription(), null);
      assertEquals(vm.getTasks(), ImmutableList.of());
      assertEquals(vm.getVAppScopedLocalId(), "02_ubuntu_template");

      GuestCustomizationSection guestC = vm.getGuestCustomizationSection();

      assertEquals(guestC.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML);
      assertEquals(
               guestC.getHref(),
               URI
                        .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vm-172837194/guestCustomizationSection/"));
      assertEquals(guestC.getInfo(), "Specifies Guest OS Customization Settings");
      assertEquals(guestC.isEnabled(), Boolean.TRUE);
      assertEquals(guestC.shouldChangeSid(), Boolean.FALSE);
      assertEquals(guestC.getVirtualMachineId(), "172837194");
      assertEquals(guestC.isJoinDomainEnabled(), Boolean.FALSE);
      assertEquals(guestC.useOrgSettings(), Boolean.FALSE);
      assertEquals(guestC.getDomainName(), null);
      assertEquals(guestC.getDomainUserName(), null);
      assertEquals(guestC.getDomainUserPassword(), null);
      assertEquals(guestC.isAdminPasswordEnabled(), Boolean.TRUE);
      assertEquals(guestC.isAdminPasswordAuto(), Boolean.TRUE);
      assertEquals(guestC.getAdminPassword(), "%3eD%gmF");
      assertEquals(guestC.isResetPasswordRequired(), Boolean.FALSE);
      assertEquals(
               guestC.getCustomizationScript(),
               "#!/bin/bash if [ \"$1\" = \"postcustomization\" ]; then echo \"post customization\" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo \"completed\" fi");
      assertEquals(guestC.getComputerName(), "Ubuntu1004");
      assertEquals(guestC.getEdit(), null);

      VCloudNetworkSection network = result.getNetworkSection();
      assertEquals(
               network.getHref(),
               URI
                        .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkSection/"));
      assertEquals(network.getType(), VCloudMediaType.NETWORKSECTION_XML);
View Full Code Here

   public static VAppTemplate parseTemplate() {
      InputStream is = VAppTemplateHandlerTest.class.getResourceAsStream("/vAppTemplate.xml");
      Injector injector = Guice.createInjector(new SaxParserModule());
      Factory factory = injector.getInstance(ParseSax.Factory.class);
      VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
      return result;
   }
View Full Code Here

      InputStream is = getClass().getResourceAsStream("/vAppTemplate-copying.xml");
      Injector injector = Guice.createInjector(new SaxParserModule());
      Factory factory = injector.getInstance(ParseSax.Factory.class);
      DateService dateService = injector.getInstance(DateService.class);

      VAppTemplate result = factory.create(injector.getInstance(VAppTemplateHandler.class)).parse(is);
      assertEquals(result.getName(), "Ubuntu10.04_v2");
      assertEquals(result.getHref(), URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881"));
      assertEquals(result.getType(), "application/vnd.vmware.vcloud.vAppTemplate+xml");
      assertEquals(result.getStatus(), Status.UNRESOLVED);
      assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609")));
      assertEquals(result.getDescription(), null);
      assertEquals(result.getTasks(), ImmutableList.of(new TaskImpl(URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr"),
               "Copying Virtual Application Template Ubuntu10.04_v2(699683881)", TaskStatus.RUNNING, dateService
                        .iso8601DateParse("2010-09-17T23:20:46.039-04:00"), dateService
                        .iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
                        .iso8601DateParse("2010-12-16T23:20:46.039-05:00"), new ReferenceTypeImpl("Ubuntu10.04_v2",
                        "application/vnd.vmware.vcloud.vAppTemplate+xml",
                        URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881")),
               null)));
      assertEquals(result.getVAppScopedLocalId(), null);
      assert result.isOvfDescriptorUploaded();
      assertEquals(result.getChildren(), ImmutableList.of());
      assertEquals(result.getNetworkSection(), null);

   }
View Full Code Here

      }));
   }

   public void testDefault() throws IOException {
      URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
      VAppTemplate template = createMock(VAppTemplate.class);
      replay(template);

      String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
      GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(new InstantiateVAppTemplateOptions()));
View Full Code Here

      assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
   }

   public void testDescription() throws IOException {
      URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
      VAppTemplate template = createMock(VAppTemplate.class);
      replay(template);

      String expected = Strings2.toStringAndClose(getClass()
               .getResourceAsStream("/instantiationparams-description.xml"));
      GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(new InstantiateVAppTemplateOptions().description("my foo")));
View Full Code Here

      assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
   }

   public void testWhenTemplateDoesntExist() throws IOException {
      URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
      VAppTemplate template = createMock(VAppTemplate.class);
      replay(template);

      String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
      GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
View Full Code Here

      assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
   }

   public void testWithNetworkNameFenceMode() throws IOException {
      URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
      VAppTemplate template = createMock(VAppTemplate.class);
      replay(template);

      InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("aloha", URI
               .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED));
View Full Code Here

TOP

Related Classes of org.jclouds.vcloud.domain.VAppTemplate

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.