Examples of GuestCustomizationSection


Examples of org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection

      return ImmutableSet.copyOf(Iterables.filter(vAppTemplate.getChildren(), new Predicate<Vm>() {
         // filter out vms in the vApp template with computer name that contains underscores, dots,
         // or both.
         @Override
         public boolean apply(Vm input) {
            GuestCustomizationSection guestCustomizationSection = vmApi.getGuestCustomizationSection(input.getId());
            String computerName = guestCustomizationSection.getComputerName();
            String retainComputerName = CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'z'))
                     .or(CharMatcher.inRange('A', 'Z')).or(CharMatcher.is('-')).retainFrom(computerName);
            return computerName.equals(retainComputerName);
         }
      }));
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection

      return params;
   }

   public static GuestCustomizationSection getGuestCustomizationSection() {
      GuestCustomizationSection section = GuestCustomizationSection.builder()
            .build();

      return section;
   }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection

      return params;
   }

   public static GuestCustomizationSection getGuestCustomizationSection() {
      GuestCustomizationSection section = GuestCustomizationSection.builder()
            .build();

      return section;
   }
View Full Code Here

Examples of org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection

      // Get URI for child VM
      String vmUrn = Iterables.getOnlyElement(vApp.getChildren().getVms()).getId();

      // The method under test
      try {
         GuestCustomizationSection section = getGuestCustomizationSection.apply(vmUrn);

         // Check the retrieved object is well formed
         checkGuestCustomizationSection(section);
      } catch (Exception e) {
         Throwables.propagate(e);
View Full Code Here

Examples of org.jclouds.vcloud.domain.GuestCustomizationSection

   @Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402")
   public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VmAsyncClient.class, "updateGuestCustomizationOfVm", GuestCustomizationSection.class,
               URI.class);
      GuestCustomizationSection guest = new GuestCustomizationSection(URI
               .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
      guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
      GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(guest, URI
               .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));

      assertRequestLineEquals(request,
               "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
View Full Code Here

Examples of org.jclouds.vcloud.domain.GuestCustomizationSection

    * strict than those in a vAppTemplate. For example, while it is possible to instantiate a
    * vAppTemplate with a VM named (incorrectly) {@code Ubuntu_10.04}, you must change the name to a
    * valid (alphanumeric underscore) name before you can update it.
    */
   public Task updateVmWithNameAndCustomizationScript(Vm vm, String name, @Nullable String customizationScript) {
      GuestCustomizationSection guestConfiguration = vm.getGuestCustomizationSection();
      guestConfiguration.setComputerName(name);
      if (customizationScript != null) {
         // In version 1.0.0, the api returns a script that loses newlines, so we cannot append to a
         // customization script.
         // TODO: parameterize whether to overwrite or append existing customization
         if (!buildVersion.startsWith("1.0.0") && !"".endsWith(buildVersion)
                  && guestConfiguration.getCustomizationScript() != null)
            customizationScript = guestConfiguration.getCustomizationScript() + "\n" + customizationScript;

         guestConfiguration.setCustomizationScript(customizationScript);
      }
      return client.getVmClient().updateGuestCustomizationOfVm(guestConfiguration, vm.getHref());
   }
View Full Code Here

Examples of org.jclouds.vcloud.domain.GuestCustomizationSection

    * strict than those in a vAppTemplate. For example, while it is possible to instantiate a
    * vAppTemplate with a VM named (incorrectly) {@code Ubuntu_10.04}, you must change the name to a
    * valid (alphanumeric underscore) name before you can update it.
    */
   public Task updateVmWithNameAndCustomizationScript(Vm vm, String name, @Nullable String customizationScript) {
      GuestCustomizationSection guestConfiguration = vm.getGuestCustomizationSection();
      guestConfiguration.setComputerName(name);
      if (customizationScript != null) {
         // In version 1.0.0, the api returns a script that loses newlines, so we cannot append to a
         // customization script.
         // TODO: parameterize whether to overwrite or append existing customization
         if (!buildVersion.startsWith("1.0.0") && !"".endsWith(buildVersion)
                  && guestConfiguration.getCustomizationScript() != null)
            customizationScript = guestConfiguration.getCustomizationScript() + "\n" + customizationScript;

         guestConfiguration.setCustomizationScript(customizationScript);
      }
      return client.getVmApi().updateGuestCustomizationOfVm(guestConfiguration, vm.getHref());
   }
View Full Code Here

Examples of org.jclouds.vcloud.domain.GuestCustomizationSection

   @Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402")
   public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(VmApi.class, "updateGuestCustomizationOfVm", GuestCustomizationSection.class,
               URI.class);
      GuestCustomizationSection guest = new GuestCustomizationSection(URI
               .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
      guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
      GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(guest, URI
               .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));

      assertRequestLineEquals(request,
               "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
View Full Code Here

Examples of org.jclouds.vcloud.domain.GuestCustomizationSection

   protected Boolean resetPasswordRequired;
   protected String customizationScript;
   protected String computerName;

   public GuestCustomizationSection getResult() {
      GuestCustomizationSection system = new GuestCustomizationSection(guest.getType(), guest.getHref(), info, enabled,
            changeSid, virtualMachineId, joinDomainEnabled, useOrgSettings, domainName, domainUserName,
            domainUserPassword, adminPasswordEnabled, adminPasswordAuto, adminPassword, resetPasswordRequired,
            customizationScript, computerName, edit);
      this.guest = null;
      this.info = null;
View Full Code Here

Examples of org.jclouds.vcloud.domain.GuestCustomizationSection

   }
   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
      checkArgument(checkNotNull(payload, "GuestCustomizationSection") instanceof GuestCustomizationSection,
               "this binder is only valid for GuestCustomizationSection!");
      GuestCustomizationSection guest = GuestCustomizationSection.class.cast(payload);
      XMLBuilder guestCustomizationSection;
      try {
         guestCustomizationSection = XMLBuilder.create("GuestCustomizationSection").a("xmlns", ns).a("xmlns:ovf",
                  "http://schemas.dmtf.org/ovf/envelope/1").a("type", guest.getType()).a("href",
                  guest.getHref().toASCIIString()).a("ovf:required", "false");
         guestCustomizationSection.e("ovf:Info").t(guest.getInfo());

         if (guest.isEnabled() != null)
            guestCustomizationSection.e("Enabled").t(guest.isEnabled().toString());
         if (guest.shouldChangeSid() != null)
            guestCustomizationSection.e("ChangeSid").t(guest.shouldChangeSid().toString());
         if (guest.getVirtualMachineId() != null)
            guestCustomizationSection.e("VirtualMachineId").t(guest.getVirtualMachineId().toString());
         if (guest.isJoinDomainEnabled() != null)
            guestCustomizationSection.e("JoinDomainEnabled").t(guest.isJoinDomainEnabled().toString());
         if (guest.shouldUseOrgSettings() != null)
            guestCustomizationSection.e("UseOrgSettings").t(guest.shouldUseOrgSettings().toString());
         if (guest.getDomainName() != null)
            guestCustomizationSection.e("DomainName").t(guest.getDomainName().toString());
         if (guest.getDomainUserName() != null)
            guestCustomizationSection.e("DomainUserName").t(guest.getDomainUserName().toString());
         if (guest.getDomainUserPassword() != null)
            guestCustomizationSection.e("DomainUserPassword").t(guest.getDomainUserPassword().toString());
         if (guest.isAdminPasswordEnabled() != null)
            guestCustomizationSection.e("AdminPasswordEnabled").t(guest.isAdminPasswordEnabled().toString());
         if (guest.isAdminPasswordAuto() != null)
            guestCustomizationSection.e("AdminPasswordAuto").t(guest.isAdminPasswordAuto().toString());
         // if (guest.getAdminPassword() != null)
         // guestCustomizationSection.e("AdminPassword").t(guest.getAdminPassword().toString());
         if (guest.isResetPasswordRequired() != null)
            guestCustomizationSection.e("ResetPasswordRequired").t(guest.isResetPasswordRequired().toString());
         if (guest.getCustomizationScript() != null)
            guestCustomizationSection.e("CustomizationScript").t(guest.getCustomizationScript());
         if (guest.getComputerName() != null)
            guestCustomizationSection.e("ComputerName").t(guest.getComputerName().toString());
         if (guest.getEdit() != null)
            guestCustomizationSection.e("Link").a("rel", "edit").a("type", guest.getType()).a("href",
                     guest.getHref().toASCIIString());

         Properties outputProperties = new Properties();
         outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
         request =  super.bindToRequest(request, guestCustomizationSection.asString(outputProperties));
         request.getPayload().getContentMetadata().setContentType(guest.getType());
      } catch (Exception e) {
         Throwables.propagate(e);
      }
      return request;
   }
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.