Examples of VApp


Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

            int... portsToOpen) {
      return startAndReturnCredentials(VDC, templateId, name, options, portsToOpen).getNode();
   }

   public String createPublicAddressMappedToPorts(URI vAppId, int... ports) {
      VApp vApp = client.getVApp(vAppId);
      PublicIpAddress ip = null;
      String privateAddress = getLast(vApp.getNetworkToAddresses().values());
      for (int port : ports) {
         InternetService is = null;
         Protocol protocol;
         switch (port) {
         case 22:
            protocol = Protocol.TCP;
            break;
         case 80:
         case 8080:
            protocol = Protocol.HTTP;
            break;
         case 443:
            protocol = Protocol.HTTPS;
            break;
         default:
            protocol = Protocol.HTTP;
            break;
         }
         if (ip == null) {

            Entry<InternetService, PublicIpAddress> entry = internetServiceAndPublicIpAddressSupplier
                  .getNewInternetServiceAndIp(vApp, port, protocol);
            is = entry.getKey();
            ip = entry.getValue();

         } else {
            logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port);
            is = client.addInternetServiceToExistingIp(
                  ip.getId(),
                  vApp.getName() + "-" + port,
                  protocol,
                  port,
                  withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
                        vApp.getName())));
         }
         logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(),
               is.getProtocol(), is.getPort());
         logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
               privateAddress, port);
         Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
         logger.debug("<< added Node(%s)", node.getName());
      }
      return ip != null ? ip.getAddress() : null;
   }
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

    *
    * @param vAppId
    *           vApp to stop
    */
   public void stop(URI id) {
      VApp vApp = client.getVApp(id);
      if (vApp == null)
         return;
      Set<PublicIpAddress> ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp);
      deletePublicIpAddressesWithNoServicesAttached(ipAddresses);
      if (vApp.getStatus() != Status.OFF) {
         try {
            powerOffAndWait(vApp);
         } catch (IllegalStateException e) {
            logger.warn("<< %s vApp(%s)", e.getMessage(), vApp.getName());
            blockOnLastTask(vApp);
            powerOffAndWait(vApp);
         }
         vApp = client.getVApp(id);
         logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName());
      }
      logger.debug(">> deleting vApp(%s)", vApp.getName());
      client.deleteVApp(id);
      logger.debug("<< deleted vApp(%s))", vApp.getName());
   }
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

    * returns a set of addresses that are only visible to the private network.
    *
    * @returns empty set if the node is not found
    */
   public Set<String> getPrivateAddresses(URI id) {
      VApp vApp = client.getVApp(id);
      if (vApp != null)
         return Sets.newHashSet(vApp.getNetworkToAddresses().values());
      else
         return ImmutableSet.<String> of();
   }
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

    * returns a set of addresses that are publically visible
    *
    * @returns empty set if the node is not found
    */
   public Set<String> getPublicAddresses(URI id) {
      VApp vApp = client.getVApp(id);
      if (vApp != null) {
         Set<String> ipAddresses = Sets.newHashSet();
         for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC().getHref())) {
            for (Node node : client.getNodes(service.getId())) {
               if (vApp.getNetworkToAddresses().containsValue(node.getIpAddress())) {
                  ipAddresses.add(service.getPublicIpAddress().getAddress());
               }
            }
         }
         return ipAddresses;
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

    *
    * @param vAppId
    *           vApp to reboot
    */
   public void reset(URI id) {
      VApp vApp = refreshVApp(id);
      logger.debug(">> resetting vApp(%s)", vApp.getName());
      Task task = reset(vApp);
      if (!taskTester.apply(task.getHref())) {
         throw new RuntimeException(String.format("failed to %s %s: %s", "resetVApp", vApp.getName(), task));
      }
      logger.debug("<< on vApp(%s)", vApp.getName());
   }
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

      URI templateURI = URI.create("template");
      URI vdcURI = URI.create("vdc");

      expect(template.getDescription()).andReturn(description).atLeastOnce();
      TerremarkVCloudClient client = createMock(TerremarkVCloudClient.class);
      VApp vApp = createMock(VApp.class);
      InternetServiceAndPublicIpAddressSupplier supplier = createMock(InternetServiceAndPublicIpAddressSupplier.class);
      expect(client.getVAppTemplate(templateURI)).andReturn(template);
      expect(
            client.instantiateVAppTemplateInVDC(vdcURI, templateURI, "name",
                  new InstantiateVAppTemplateOptions().productProperty("password", "password"))).andReturn(vApp);
      Task task = createMock(Task.class);
      URI vappLocation = URI.create("vapp");
      URI taskLocation = URI.create("task");

      expect(vApp.getHref()).andReturn(vappLocation).atLeastOnce();
      expect(vApp.getName()).andReturn("name").atLeastOnce();
      expect(client.deployVApp(vappLocation)).andReturn(task);
      expect(task.getHref()).andReturn(taskLocation).atLeastOnce();
      Predicate<URI> successTester = createMock(Predicate.class);
      expect(successTester.apply(taskLocation)).andReturn(true).atLeastOnce();
      expect(client.powerOnVApp(vappLocation)).andReturn(task);
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

      this.vAppToNodeMetadata = vAppToNodeMetadata;
   }

   public NodeMetadata getNode(String in) {
      URI id = URI.create(in);
      VApp from = client.getVApp(id);
      if (from == null)
         return null;
      return vAppToNodeMetadata.apply(from);
   }
View Full Code Here

Examples of org.jclouds.trmk.vcloud_0_8.domain.VApp

         for (ReferenceType vdc : org.getVDCs().values()) {
            VDC response = api.getVDC(vdc.getHref());
            for (ReferenceType item : response.getResourceEntities().values()) {
               if (item.getType().equals(TerremarkVCloudMediaType.VAPP_XML)) {
                  try {
                     VApp app = api.getVApp(item.getHref());
                     assertNotNull(app);
                  } catch (RuntimeException e) {

                  }
               }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.VApp

               .httpRequestBuilder().build(),
            new VcloudHttpResponsePrimer()
               .xmlFilePayload("/vApp/vApp.xml", VCloudDirectorMediaType.VAPP)
               .httpResponseBuilder().build());

      VApp expected = getVApp();

      assertEquals(api.getVAppApi().get(vAppURI), expected);
   }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.VApp

            .httpRequestBuilder().build(),
         new VcloudHttpResponsePrimer()
            .xmlFilePayload("/vApp/modifiedVapp.xml", VCloudDirectorMediaType.VAPP)
            .httpResponseBuilder().build());

    VApp modified = getVApp();
    modified.setName("new-name");
    modified.setDescription("New Description");

    Task expected = editVAppTask();

    assertEquals(api.getVAppApi().edit(vAppURI, modified), expected);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.