Package com.jamesmurty.utils

Examples of com.jamesmurty.utils.XMLBuilder


      networkBuilder.e("rasd:ResourceType").t(ResourceType.ETHERNET_ADAPTER.value());
      networkBuilder.e("rasd:VirtualQuantity").t("1");
   }

   private void addDisks(XMLBuilder sectionBuilder, VMSpec spec) {
      XMLBuilder bootDiskBuilder = sectionBuilder.e("ovf:Item");
      bootDiskBuilder.e("rasd:AllocationUnits").t("Gigabytes");
      bootDiskBuilder.e("rasd:Caption").t("");
      bootDiskBuilder.e("rasd:Description").t("Hard Disk");
      bootDiskBuilder.e("rasd:ElementName").t(spec.getBootDeviceName());
      bootDiskBuilder.e("rasd:HostResource").t("boot");
      bootDiskBuilder.e("rasd:InstanceID").t("4");
      bootDiskBuilder.e("rasd:ResourceType").t(ResourceType.BASE_PARTITIONABLE_UNIT.value());
      bootDiskBuilder.e("rasd:VirtualQuantity").t(spec.getBootDiskSize() + "");

      int instanceId = 5;
      for (Entry<String, Integer> dataDisk : spec.getDataDiskDeviceNameToSizeInGig().entrySet()) {
         XMLBuilder dataDiskBuilder = sectionBuilder.e("ovf:Item");
         dataDiskBuilder.e("rasd:AllocationUnits").t("Gigabytes");
         dataDiskBuilder.e("rasd:Caption").t("");
         dataDiskBuilder.e("rasd:Description").t("Hard Disk");
         dataDiskBuilder.e("rasd:ElementName").t(dataDisk.getKey());
         dataDiskBuilder.e("rasd:HostResource").t("data");
         dataDiskBuilder.e("rasd:InstanceID").t("" + instanceId++);
         dataDiskBuilder.e("rasd:ResourceType").t(ResourceType.PARTITIONABLE_UNIT.value());
         dataDiskBuilder.e("rasd:VirtualQuantity").t(dataDisk.getValue() + "");
      }
   }
View Full Code Here


         dataDiskBuilder.e("rasd:VirtualQuantity").t(dataDisk.getValue() + "");
      }
   }

   protected XMLBuilder buildRoot() throws ParserConfigurationException, FactoryConfigurationError {
      XMLBuilder rootBuilder = XMLBuilder.create("vApp:VApp").a("xmlns:vApp", "http://www.vmware.com/vcloud/v0.8").a(
               "xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1").a("xmlns:vssd",
               "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData").a("xmlns:common",
               "http://schemas.dmtf.org/wbem/wscim/1/common").a("xmlns:rasd",
               "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData");
      return rootBuilder;
View Full Code Here

      return rootBuilder;
   }

   protected XMLBuilder buildChildren(XMLBuilder rootBuilder) throws ParserConfigurationException,
            FactoryConfigurationError {
      XMLBuilder vAppChildrenBuilder = rootBuilder.e("vApp:Children");
      return vAppChildrenBuilder;
   }
View Full Code Here

      return vAppChildrenBuilder;
   }

   protected XMLBuilder buildRootForName(XMLBuilder rootBuilder, String name) throws ParserConfigurationException,
            FactoryConfigurationError {
      XMLBuilder vAppBuilder = rootBuilder.e("vApp:VApp").a("name", name).a("type",
               "application/vnd.vmware.vcloud.vApp+xml");
      return vAppBuilder;
   }
View Full Code Here

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

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

      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

   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

      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

   }

   @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

      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

TOP

Related Classes of com.jamesmurty.utils.XMLBuilder

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.