Package org.jclouds.vcloud.domain

Examples of org.jclouds.vcloud.domain.Vm


   @Override
   public Hardware apply(VApp from) {
      checkNotNull(from, "VApp");
      // TODO make this work with composite vApps
      Vm vm = from.getChildren().isEmpty() ? null : Iterables.get(from.getChildren(), 0);
      if (vm == null)
         return null;

      VirtualHardwareSection hardware = vm.getVirtualHardwareSection();
      HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getItems());
      builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
      builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
               ImagePredicates.idEquals(from.getHref().toASCIIString()));
      builder.hypervisor("VMware");
View Full Code Here


   }

   public void endElement(String uri, String name, String qName) {
      if (equalsOrSuffix(qName, "Children")) {
         inChildren = false;
         Vm vm = vmHandler.getResult();
         if (vm != null)
            this.children.add(vmHandler.getResult());
      } else if (equalsOrSuffix(qName, "Tasks")) {
         inTasks = false;
         this.tasks.add(taskHandler.getResult());
View Full Code Here

      // vm data is available after instantiate completes
      vAppResponse = client.getVAppApi().getVApp(vAppResponse.getHref());

      // per above check, we know there is only a single VM
      Vm vm = get(vAppResponse.getChildren(), 0);

      template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);
      VCloudTemplateOptions vOptions = VCloudTemplateOptions.class.cast(template.getOptions());

      // note we cannot do tasks in parallel or VCD will throw "is busy" errors

      // note we must do this before any other customizations as there is a dependency on
      // valid naming conventions before you can perform commands such as updateCPUCount
      logger.trace(">> updating customization vm(%s) name->(%s)", vm.getName(), name);
      waitForTask(updateVmWithNameAndCustomizationScript(vm, name, vOptions.getCustomizationScript()));
      logger.trace("<< updated customization vm(%s)", name);

      ensureVmHasAllocationModeOrPooled(vAppResponse, vOptions.getIpAddressAllocationMode());

      int cpuCount = (int) getCores(template.getHardware());
      logger.trace(">> updating cpuCount(%d) vm(%s)", cpuCount, vm.getName());
      waitForTask(updateCPUCountOfVm(vm, cpuCount));
      logger.trace("<< updated cpuCount vm(%s)", vm.getName());
      int memoryMB = template.getHardware().getRam();
      logger.trace(">> updating memoryMB(%d) vm(%s)", memoryMB, vm.getName());
      waitForTask(updateMemoryMBOfVm(vm, memoryMB));
      logger.trace("<< updated memoryMB vm(%s)", vm.getName());
      logger.trace(">> deploying vApp(%s)", vAppResponse.getName());
      waitForTask(client.getVAppApi().deployVApp(vAppResponse.getHref()));
      logger.trace("<< deployed vApp(%s)", vAppResponse.getName());

      // only after deploy is the password valid
View Full Code Here

   }

   public void ensureVmHasAllocationModeOrPooled(VApp vApp, @Nullable IpAddressAllocationMode ipAllocationMode) {
      Network networkToConnect = find(vApp.getNetworkSection().getNetworks(), not(networkWithNoIpAllocation));

      Vm vm = get(vApp.getChildren(), 0);

      NetworkConnectionSection net = vm.getNetworkConnectionSection();
      checkArgument(!net.getConnections().isEmpty(), "no connections on vm %s", vm);

      NetworkConnection toConnect = findWithPoolAllocationOrFirst(net);

      if (ipAllocationMode == null)
         ipAllocationMode = toConnect.getIpAddressAllocationMode();

      // make sure that we are in fact allocating ips
      if (ipAllocationMode == IpAddressAllocationMode.NONE)
         ipAllocationMode = IpAddressAllocationMode.POOL;

      if (toConnect.isConnected() && toConnect.getIpAddressAllocationMode() == ipAllocationMode
               && toConnect.getNetwork().equals(networkToConnect.getName())) {
         // then we don't need to change the network settings, and can save a call
      } else {
         Builder builder = net.toBuilder();
         builder.connections(ImmutableSet.of(toConnect.toBuilder().network(networkToConnect.getName()).connected(true)
                  .ipAddressAllocationMode(ipAllocationMode).build()));
         logger.trace(">> updating networkConnection vm(%s)", vm.getName());

         waitForTask(client.getVmApi().updateNetworkConnectionOfVm(builder.build(), vm.getHref()));
         logger.trace("<< updated networkConnection vm(%s)", vm.getName());

      }

   }
View Full Code Here

            new ReferenceTypeImpl(null, VCloudMediaType.VDC_XML, URI
                  .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439")));
      assertEquals(result.getTasks(), ImmutableList.of());
      assert result.isOvfDescriptorUploaded();
      assert result.getNetworkSection() != null;
      Vm vm = Iterables.getOnlyElement(result.getChildren());
      VmHandlerTest.checkVm(vm);
   }
View Full Code Here

TOP

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

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.