Package org.jclouds.vcloud.domain

Examples of org.jclouds.vcloud.domain.VAppTemplate


         Catalog response = getVCloudApi().getCatalogClient().getCatalog(cat.getHref());
         for (ReferenceType resource : response.values()) {
            if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
               CatalogItem item = getVCloudApi().getCatalogClient().getCatalogItem(resource.getHref());
               if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
                  VAppTemplate template = getVCloudApi().getVAppTemplateClient().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().getCatalogClient().getCatalog(cat.getHref());
         for (ReferenceType resource : response.values()) {
            if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
               CatalogItem item = getVCloudApi().getCatalogClient().getCatalogItem(resource.getHref());
               if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
                  VAppTemplate template = getVCloudApi().getVAppTemplateClient().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().getVAppClient().undeployVApp(URI.create(node.getId()));

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

         VApp vApp = getVCloudApi().getVAppClient().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().getVAppTemplateClient().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().getCatalogClient().addVAppTemplateOrMediaImageToCatalogAndNameItem(
                  vappTemplate.getHref(),
                  getVCloudApi().getCatalogClient().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().getCatalogClient().deleteCatalogItem(item.getHref());
         if (vappTemplate != null)
            getVCloudApi().getVAppTemplateClient().deleteVAppTemplate(vappTemplate.getHref());
         if (node != null)
            client.destroyNode(node.getId());
      }
   }
View Full Code Here

   protected VApp instantiateVAppFromTemplate(String name, Template template) {
      VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions());
     
      URI templateId = URI.create(template.getImage().getId());

      VAppTemplate vAppTemplate = vAppTemplates.getUnchecked(templateId);

      if (vAppTemplate.getChildren().size() > 1)
         throw new UnsupportedOperationException("we currently do not support multiple vms in a vAppTemplate "
                  + vAppTemplate);

      if (vAppTemplate.getNetworkSection().getNetworks().size() > 1)
         throw new UnsupportedOperationException(
                  "we currently do not support multiple network connections in a vAppTemplate " + vAppTemplate);

      Network networkToConnect = get(vAppTemplate.getNetworkSection().getNetworks(), 0);

     
      NetworkConfig config = networkConfigurationForNetworkAndOptions.apply(networkToConnect, vOptions);

      // note that in VCD 1.5, the network name after instantiation will be the same as the parent
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().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

   @VisibleForTesting
   Set<Vm> ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) {
      Set<Vm> vms = ImmutableSet.of();
      if (customizationScript != null) {
         VAppTemplate vAppTemplate = templateCache.getUnchecked(template);
         checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template);
         vms = vAppTemplate.getChildren();
         checkArgument(vms.size() > 0, "no vms found in vAppTemplate %s", vAppTemplate);
      }
      return vms;
   }
View Full Code Here

   protected VApp instantiateVAppFromTemplate(String name, Template template) {
      VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions());
     
      URI templateId = URI.create(template.getImage().getId());

      VAppTemplate vAppTemplate = vAppTemplates.getUnchecked(templateId);

      if (vAppTemplate.getChildren().size() > 1)
         throw new UnsupportedOperationException("we currently do not support multiple vms in a vAppTemplate "
                  + vAppTemplate);

      if (vAppTemplate.getNetworkSection().getNetworks().size() > 1)
         throw new UnsupportedOperationException(
                  "we currently do not support multiple network connections in a vAppTemplate " + vAppTemplate);

      Network networkToConnect = get(vAppTemplate.getNetworkSection().getNetworks(), 0);

     
      NetworkConfig config = networkConfigurationForNetworkAndOptions.apply(networkToConnect, vOptions);

      // note that in VCD 1.5, the network name after instantiation will be the same as the parent
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

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.