Package org.jclouds.vcloud.domain

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


    * 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

    * 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

   @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

   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

   }
   @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

               .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
View Full Code Here

public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest {

   public void testDefault() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/guestCustomization.xml");

      GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class))
            .parse(is);

      checkGuestCustomization(result);

   }
View Full Code Here

    * 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

   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

TOP

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

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.