Examples of xpathFind()


Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

   private void eliminateDomain(String id) {
      try {
         XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(client.domainLookupByUUIDString(id)
                  .getXMLDesc(0))));
         String diskFileName = builder.xpathFind("//devices/disk[@device='disk']/source").getElement().getAttribute(
                  "file");
         StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
         storageVol.delete(0);
         client.domainLookupByUUIDString(id).undefine();
      } catch (Exception e) {
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      try {
         client.domainLookupByUUIDString(id).destroy();

         XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(client.domainLookupByUUIDString(id)
                  .getXMLDesc(0))));
         String diskFileName = builder.xpathFind("//devices/disk[@device='disk']/source").getElement().getAttribute(
                  "file");
         StorageVol storageVol = client.storageVolLookupByPath(diskFileName);
         storageVol.delete(0);
         client.domainLookupByUUIDString(id).undefine();
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      Properties outputProperties = generateOutputXMLProperties();
      XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
      String nodeNamingConvention = "%s-%s";
      String tag = "-clone";
      String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
      builder.xpathFind("//volume/name").t(suffix);
      builder.xpathFind("//volume/key").t(suffix);
      builder.xpathFind("//volume/target/path").t(suffix);

      return builder.asString(outputProperties);
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));
      String nodeNamingConvention = "%s-%s";
      String tag = "-clone";
      String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
      builder.xpathFind("//volume/name").t(suffix);
      builder.xpathFind("//volume/key").t(suffix);
      builder.xpathFind("//volume/target/path").t(suffix);

      return builder.asString(outputProperties);
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      String nodeNamingConvention = "%s-%s";
      String tag = "-clone";
      String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
      builder.xpathFind("//volume/name").t(suffix);
      builder.xpathFind("//volume/key").t(suffix);
      builder.xpathFind("//volume/target/path").t(suffix);

      return builder.asString(outputProperties);
   }

   private static String generateClonedDomainXML(String fromXML, StorageVol clonedVol)
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      XMLBuilder builder = XMLBuilder.parse(new InputSource(new StringReader(fromXML)));

      String nodeNamingConvention = "%s-%s";
      String tag = "-clone";
      String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
      builder.xpathFind("//domain/name").t(suffix);
      // change uuid domain
      Element oldChild = builder.xpathFind("//domain/uuid").getElement();
      Node newNode = oldChild.cloneNode(true);
      newNode.getFirstChild().setNodeValue(UUID.randomUUID().toString());
      builder.getDocument().getDocumentElement().replaceChild(newNode, oldChild);
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      String nodeNamingConvention = "%s-%s";
      String tag = "-clone";
      String suffix = String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom().nextInt(4095)));
      builder.xpathFind("//domain/name").t(suffix);
      // change uuid domain
      Element oldChild = builder.xpathFind("//domain/uuid").getElement();
      Node newNode = oldChild.cloneNode(true);
      newNode.getFirstChild().setNodeValue(UUID.randomUUID().toString());
      builder.getDocument().getDocumentElement().replaceChild(newNode, oldChild);

      // String fromVolPath =
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      newNode.getFirstChild().setNodeValue(UUID.randomUUID().toString());
      builder.getDocument().getDocumentElement().replaceChild(newNode, oldChild);

      // String fromVolPath =
      // builder.xpathFind("//domain/devices/disk/source").getElement().getAttribute("file");
      builder.xpathFind("//domain/devices/disk/source").a("file", clonedVol.getPath());
      // generate valid MAC address
      String fromMACaddress = builder.xpathFind("//domain/devices/interface/mac").getElement().getAttribute("address");
      String lastMACoctet = Integer.toHexString(new SecureRandom().nextInt(255));
      builder.xpathFind("//domain/devices/interface/mac").a("address",
               fromMACaddress.substring(0, fromMACaddress.lastIndexOf(":") + 1) + lastMACoctet);
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      // String fromVolPath =
      // builder.xpathFind("//domain/devices/disk/source").getElement().getAttribute("file");
      builder.xpathFind("//domain/devices/disk/source").a("file", clonedVol.getPath());
      // generate valid MAC address
      String fromMACaddress = builder.xpathFind("//domain/devices/interface/mac").getElement().getAttribute("address");
      String lastMACoctet = Integer.toHexString(new SecureRandom().nextInt(255));
      builder.xpathFind("//domain/devices/interface/mac").a("address",
               fromMACaddress.substring(0, fromMACaddress.lastIndexOf(":") + 1) + lastMACoctet);
      return builder.asString(outputProperties);
   }
View Full Code Here

Examples of com.jamesmurty.utils.XMLBuilder.xpathFind()

      // builder.xpathFind("//domain/devices/disk/source").getElement().getAttribute("file");
      builder.xpathFind("//domain/devices/disk/source").a("file", clonedVol.getPath());
      // generate valid MAC address
      String fromMACaddress = builder.xpathFind("//domain/devices/interface/mac").getElement().getAttribute("address");
      String lastMACoctet = Integer.toHexString(new SecureRandom().nextInt(255));
      builder.xpathFind("//domain/devices/interface/mac").a("address",
               fromMACaddress.substring(0, fromMACaddress.lastIndexOf(":") + 1) + lastMACoctet);
      return builder.asString(outputProperties);
   }

   private static Properties generateOutputXMLProperties() {
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.