Examples of XmlBuilder


Examples of com.jamesmurty.utils.XMLBuilder

      String genericVAppURI = vAppURI.toString().substring(0, vAppURI.toString().indexOf("vApp") + vAppStr.length());
      rootBuilder.e("VApp").a("href", genericVAppURI).a("type", "application/vnd.vmware.vcloud.vApp+xml");
   }

   protected XMLBuilder buildRoot(String newVAppName) throws ParserConfigurationException, FactoryConfigurationError {
        XMLBuilder rootBuilder = XMLBuilder.create("CloneVAppParams")
            .a("xmlns", "http://www.vmware.com/vcloud/v0.8")
            .a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
            .a("name", newVAppName)
            .a("deploy" , "true")
            .a("powerOn" , "true")
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

   public String generateXml(URI vAppURI) {
      checkNotNull(vAppURI, "vAppURI");

      try {
         XMLBuilder rootBuilder = buildRoot();
         addSourceSection(rootBuilder, vAppURI);
         Properties outputProperties = new Properties();
         return rootBuilder.asString(outputProperties);
      } catch (Exception e) {
         return null;
      }
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

      rootBuilder.e("Description").t("Save Template");
      rootBuilder.e("Source").a("href", vAppURI.toString());
   }

   protected XMLBuilder buildRoot() throws ParserConfigurationException, FactoryConfigurationError {
      XMLBuilder rootBuilder = XMLBuilder.create("CaptureVAppParams")
            .a("xmlns", "http://schemas.api.sandbox.savvis.net/vpdci")
            .a("name", "CaptureTemplate");
      return rootBuilder;
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

   }

   @Override
   protected void bindSpec(Iterable<VMSpec> specs, XMLBuilder rootBuilder) throws ParserConfigurationException, FactoryConfigurationError {
      rootBuilder.a("name", "");
      XMLBuilder specBuilder = buildChildren(rootBuilder);
      for (VMSpec spec : specs) {
         checkSpec(spec);
         XMLBuilder vAppBuilder = buildRootForName(specBuilder, spec.getName());
         addOperatingSystemAndVirtualHardware(spec, vAppBuilder);
      }
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

      Optional<String> location = Optional.fromNullable((String) postParams.get("location"));
      Optional<String> affinityGroup = Optional.fromNullable((String) postParams.get("affinityGroup"));
      CreateHostedServiceOptions options = Optional
               .fromNullable((CreateHostedServiceOptions) postParams.get("options")).or(NO_OPTIONS);
      try {
         XMLBuilder createHostedService = XMLBuilder.create("CreateHostedService")
                  .a("xmlns", "http://schemas.microsoft.com/windowsazure").e("ServiceName").t(serviceName).up()
                  .e("Label").t(label).up();

         if (options.getDescription().isPresent())
            createHostedService.e("Description").t(options.getDescription().get()).up();

         if (location.isPresent())
            createHostedService.e("Location").t(location.get()).up();
         else if (affinityGroup.isPresent())
            createHostedService.e("AffinityGroup").t(affinityGroup.get()).up();
         else
            throw new IllegalArgumentException("you must specify either Location or AffinityGroup!");

         if (options.getExtendedProperties().isPresent() && options.getExtendedProperties().get().size() > 0) {
            XMLBuilder extendedProperties = createHostedService.e("ExtendedProperties");
            for (Entry<String, String> entry : options.getExtendedProperties().get().entrySet())
               extendedProperties.e("ExtendedProperty").e("Name").t(entry.getKey()).up().e("Value").t(entry.getValue());
         }
         return (R) request.toBuilder().payload(createHostedService.asString()).build();
      } catch (Exception e) {
         throw Throwables.propagate(e);
      }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Object input) {
      DeploymentParams params = DeploymentParams.class.cast(input);
      try {
       
        XMLBuilder builder = XMLBuilder.create("Deployment").a("xmlns", "http://schemas.microsoft.com/windowsazure")
                  .e("Name").t(params.getName()).up()
                  .e("DeploymentSlot").t("Production").up()
                  .e("Label").t(params.getName()).up()
                  .e("RoleList")
                  .e("Role")
                  .e("RoleName").t(params.getName()).up()
                  .e("RoleType").t("PersistentVMRole").up()
                  .e("ConfigurationSets");
                 
        if (params.getOsType() == OSType.WINDOWS){
          XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows
          configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up()
              .e("ComputerName").t(params.getUsername()).up()
              .e("AdminPassword").t(params.getPassword()).up()
              .e("ResetPasswordOnFirstLogon").t("false").up()
              .e("EnableAutomaticUpdate").t("false").up()
              .e("DomainJoin")
              .e("Credentials")
                  .e("Domain").t(params.getName()).up()
                  .e("Username").t(params.getUsername()).up()
                  .e("Password").t(params.getPassword()).up()
              .up()//Credentials
              .e("JoinDomain").t(params.getName()).up()
              .up()// Domain Join
              .e("StoredCertificateSettings").up()
              .up();//Windows ConfigurationSet
        }else if (params.getOsType() == OSType.LINUX){
          XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux
          configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up()
              .e("HostName").t(params.getName()).up()
              .e("UserName").t(params.getUsername()).up()
              .e("UserPassword").t(params.getPassword()).up()
              .e("DisableSshPasswordAuthentication").t("false").up()
              .e("SSH").up()
              .up();//Linux ConfigurationSet 
        }
       
        XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network
      configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up();
     
      XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints");
      for (InputEndpoint endpoint : params.getEndpoints()){
        XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint");
              inputBuilder.e("LocalPort").t(endpoint.getLocalPort().toString()).up()
              .e("Name").t(endpoint.getName()).up()
              .e("Port").t(endpoint.getExternalPort().toString()).up()
              .e("Protocol").t(endpoint.getProtocol().name()).up()
              .up();//InputEndpoint 
          }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

   }

   protected String generateXml(String name, String template, SortedMap<ResourceType, String> virtualHardwareQuantity,
         String networkName, @Nullable String fenceMode, URI network) throws ParserConfigurationException,
         FactoryConfigurationError, TransformerException {
      XMLBuilder rootBuilder = buildRoot(name);

      rootBuilder.e("VAppTemplate").a("href", template);

      XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
      addVirtualQuantityIfPresent(instantiationParamsBuilder, virtualHardwareQuantity);
      addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode, network);
      Properties outputProperties = new Properties();
      outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      return rootBuilder.asString(outputProperties);
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

      return rootBuilder.asString(outputProperties);
   }

   protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name, @Nullable String fenceMode,
         URI network) {
      XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e("NetworkConfig")
            .a("name", name);
      if (fenceMode != null) {
         XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");
         featuresBuilder.e("FenceMode").t(fenceMode);
      }
      networkConfigBuilder.e("NetworkAssociation").a("href", network.toASCIIString());
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

      }
      networkConfigBuilder.e("NetworkAssociation").a("href", network.toASCIIString());
   }

   protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError {
      XMLBuilder rootBuilder = XMLBuilder.create("InstantiateVAppTemplateParams").a("name", name).a("xmlns", ns)
            .a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema)
            .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
      return rootBuilder;
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder

      return options;
   }

   protected void addVirtualQuantityIfPresent(XMLBuilder instantiationParamsBuilder,
         SortedMap<ResourceType, String> virtualHardwareQuantity) {
      XMLBuilder productSectionBuilder = instantiationParamsBuilder.e("ProductSection").a("xmlns:q1", ns)
            .a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
      if (propLocal.get() != null) {
         for (Entry<String, String> entry : propLocal.get().entrySet()) {
            productSectionBuilder.e("Property").a("xmlns", "http://schemas.dmtf.org/ovf/envelope/1")
                  .a("ovf:key", entry.getKey()).a("ovf:value", entry.getValue());
         }
         propLocal.set(null);
      }
      if (virtualHardwareQuantity.size() > 0) {
         XMLBuilder virtualHardwareSectionBuilder = instantiationParamsBuilder.e("VirtualHardwareSection").a(
               "xmlns:q1", ns);
         for (Entry<ResourceType, String> entry : virtualHardwareQuantity.entrySet()) {
            XMLBuilder itemBuilder = virtualHardwareSectionBuilder.e("Item").a("xmlns",
                  "http://schemas.dmtf.org/ovf/envelope/1");
            itemBuilder.e("InstanceID")
                  .a("xmlns", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
                  .t(virtualHardwareToInstanceId.get(entry.getKey()));
            itemBuilder.e("ResourceType")
                  .a("xmlns", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
                  .t(entry.getKey().value());
            itemBuilder.e("VirtualQuantity")
                  .a("xmlns", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
                  .t(entry.getValue());
         }
      }
   }
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.