当前位置: 首页>>代码示例>>Python>>正文


Python comoonics.XmlTools类代码示例

本文整理汇总了Python中comoonics.XmlTools的典型用法代码示例。如果您正苦于以下问题:Python XmlTools类的具体用法?Python XmlTools怎么用?Python XmlTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XmlTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateMetaData

 def updateMetaData(self, element):
    ComLog.getLogger(self.__logStrLevel__).debug("%u logical volumes cloning all from source" %(len(self.getVolumeGroup().getLogicalVolumes())))
    #ComLog.getLogger(self.__logStrLevel__).debug("Element to copy %s" %(element))
    if (len(self.getVolumeGroup().getLogicalVolumes()) == 0):
       #ComLog.getLogger(self.__logStrLevel__).debug("0 logical volumes cloning all from source")
       XmlTools.merge_trees_with_pk(element, self.getVolumeGroup().getElement(), self.document, "name", XmlTools.ElementFilter("logicalvolume"))
       self.vg=VolumeGroup(self.getVolumeGroup().getElement(), self.getDocument())
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:7,代码来源:ComLVMCopyObject.py

示例2: setUp

    def setUp(self):
        from comoonics.storage.hp.ComHP_EVA_Storage import HP_EVA_Storage
        from comoonics import XmlTools
        from comoonics.storage.ComDisk import StorageDisk
        #mylogger.debug("xml: %s" %(match.group(1)))
        xml_dump="""
        <disk name="Virtual Disks/atix/sourcedisk">
            <properties>
                <property name="size" value="10"/>
                <property name="disk_group" value="146er"/>
            </properties>
        </disk>
"""
        doc=XmlTools.parseXMLString(xml_dump)
        self.disk=StorageDisk(doc.documentElement, doc)
        self.storage=HP_EVA_Storage(system="127.0.0.1/EVA5000", username="Administrator", password="Administrator", autoconnect=True, cmd="../ComHP_EVA_SSSU_Sim.py")
        xml_dump="""
        <disk name="Virtual Disks/atix/sourcedisk_snap">
            <mapping lun="1">
                <host name="server1"/>
            </mapping>
        </disk>
"""
        doc=XmlTools.parseXMLString(xml_dump)
        self.snapdisk=StorageDisk(doc.documentElement, doc)
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:25,代码来源:testHP_EVA_Storage.py

示例3: getEnterprisecopy

    def getEnterprisecopy(self):
        from comoonics import XmlTools
        import xml.dom
        import odict
        import os.path
        ret_doc=None
        ret_element=None
        _sets=odict.Odict()
        for _templatefile in self.templatefiles:
            _file=open(os.path.join(self.sysreport_templatesbase, _templatefile),"r")
            doc=XmlTools.parseXMLFP(_file)
            # Initially create ret_doc. Cannot do it before cause we need the doc
            if not ret_doc:
                ret_doc=XmlTools.getDOMImplementation().createDocument(None, doc.documentElement.tagName, None)
                ret_element=ret_doc.documentElement
            for _child in doc.documentElement.childNodes:
                if _child.nodeType==xml.dom.Node.ELEMENT_NODE:
                    if _child.hasAttribute("name"):
                        _sets[_child.getAttribute("name")]=XmlTools.clone_node(_child, ret_doc)
                elif _child.nodeType == xml.dom.Node.ATTRIBUTE_NODE:
                    ret_element.appendChild(XmlTools.clone_node(_child, ret_doc))
        # remove the save-sysreport and add it to the end
        _save_set= _sets[self.save_set]
        del _sets[self.save_set]
        _sets[self.save_set]=_save_set

        for _set in _sets.values():
            Sysreport.logger.debug("getEnterprisecopy() adding child: %s" %_set.getAttribute("name"))
            ret_element.appendChild(_set)
        del _sets[self.save_set]
        del _sets[self.head_set]
        self.sets=_sets
        return EnterpriseCopy(ret_element, ret_doc)
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:33,代码来源:ComSysreport.py

示例4: setUp

 def setUp(self):
     self.docs=list()
     for i in range(len(xmls)): 
         if i < len(xpaths):
             self.docs.append([ XmlTools.parseXMLString(xmls[i]), xpaths[i]])
         else:
             self.docs.append([ XmlTools.parseXMLString(xmls[i]) ])
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:7,代码来源:testXmlTools.py

示例5: __test_overwrite_element_with_xpaths

 def __test_overwrite_element_with_xpaths(self):
     for doc in self.docs:
         if len(doc) > 1:
             (doc, xpathtest)=doc
             (xpath, expectedresult, newvalue) = xpathtest
             xml2=XmlTools.overwrite_element_with_xpaths(doc.documentElement, { xpath: newvalue })
             buf=XmlTools.toPrettyXML(doc)
             self.assertEquals(buf.replace("\n", "").replace(" ", ""), XmlTools.toPrettyXML(doc).replace("\n", "").replace(" ", ""))
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:8,代码来源:testXmlTools.py

示例6: test_overwrite_attributes_with_xpaths

 def test_overwrite_attributes_with_xpaths(self):
     for doc in self.docs:
         if len(doc) > 1:
             (doc, xpathtest)=doc
             (xpath, expectedresult, newvalue) = xpathtest
             xml2=XmlTools.overwrite_attributes_with_xpaths(doc.documentElement, { xpath: newvalue })
             buf=XmlTools.toPrettyXML(xml2)
             self.assertEquals(buf.replace("\n", "").replace(" ", "").replace('<?xmlversion="1.0"?>', ""), 
                               XmlTools.toPrettyXML(doc).replace("\n", "").replace(" ", "").replace('<?xmlversion="1.0"?>', "").replace("lilr629", "myname").replace("/dev/sda1", "mydisk"))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:9,代码来源:testXmlTools.py

示例7: testClusterRepositoryEXT3

    def testClusterRepositoryEXT3(self):
        from comoonics import XmlTools
        result="""<cluster config_version="1" name="testcluster">
    <clusternodes>
        <clusternode name="name0" nodeid="1" votes="1">
            <com_info>
                <eth master="bond0" name="eth0" slave="yes"/>
                <eth master="bond0" name="eth1" slave="yes"/>
                <eth bondingopts="miimon=100,mode=passive" name="bond0"/>
                <eth gateway="10.0.0.2" ip="10.0.0.1" name="bond0.100" netmask="255.255.255.0"/>
                <rootvolume fstype="ext3" name="/dev/vg_testcluster_sr/lv_sharedroot"/>
            </com_info>
            <fence>
                <method name="1"/>
            </fence>
        </clusternode>
    </clusternodes>
    <fencedevices/>
    <cman expected_votes="1" two_node="0"/>
    <rm>
        <resources/>
        <failoverdomains/>
    </rm>
</cluster>
"""
        self.numnodes=1
        osrcluster=OSRCluster(self.clustername, self.numnodes)
        for i in range(self.numnodes):
            _node=OSRClusterNode(osrcluster, "name%u" %i, self.rootvolume)
            _node.rootvol=self.rootvolume
            _node.rootfstype="ext3"
            _netdev=OSRClusterNodeNetdev(_node, "eth0")
            _netdev.master="bond0"
            _netdev.slave="yes"
            _node.addNetdev(_netdev)
            _netdev=OSRClusterNodeNetdev(_node, "eth1")
            _netdev.master="bond0"
            _netdev.slave="yes"
            _node.addNetdev(_netdev)
            _netdev=OSRClusterNodeNetdev(_node, "bond0")
            _netdev.bondingopts="miimon=100,mode=passive"
            _node.addNetdev(_netdev)
            _netdev=OSRClusterNodeNetdev(_node, "bond0.100")
            _netdev.ip="10.0.0.1"
            _netdev.netmask="255.255.255.0"
            _netdev.gateway="10.0.0.2"
            _node.addNetdev(_netdev)
            osrcluster.addNode(_node)
        log.debug("Cluster: %s" %osrcluster)
        log.debug("Cluster as hash: %s" %osrcluster.toHash())
        from comoonics.cluster import getClusterRepository
        hash=osrcluster.toHash()
        tmp=getClusterRepository(None,None,hash,self.defaults)
        print XmlTools.toPrettyXML(tmp.getElement())
        tmp=XmlTools.toPrettyXML(tmp.getElement())
        self.assertEquals(result.replace(" ", "").replace("\n", ""), tmp.replace("\t", "").replace(" ", "").replace("\n", ""))
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:56,代码来源:test_osrcluster.py

示例8: getXPathFromXMLFile

def getXPathFromXMLFile(xpath, filename):
    try:
        from comoonics import XmlTools
        document=XmlTools.parseXMLFile(filename)
        return XmlTools.evaluateXPath(xpath, document.documentElement)
    except ImportError:
        import xml.dom.minidom
        from xml.xpath import Evaluate
        import os
        filep = os.fdopen(os.open(filename, os.O_RDONLY))
        doc=xml.dom.minidom.parse(filep)
        return Evaluate(xpath, doc.documentElement)
开发者ID:MarcGrimme,项目名称:comoonics-initrd-ng,代码行数:12,代码来源:fence_scsi_test.py

示例9: test_removePrettyTextNodes

    def test_removePrettyTextNodes(self):
        docstring="""<?xml version="1.0" ?>
<x>
  <y>
  abcdef
  </y>
</x>
"""     
        doc=XmlTools.parseXMLString(docstring)
        XmlTools.removePrettyTextNodes(doc)
        result=XmlTools.toPrettyXML(doc, "  ", "\n")
        self.assertEquals(docstring.replace("\n", "").replace(" ", ""), result.replace("\n", "").replace(" ", ""))        
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:12,代码来源:testXmlTools.py

示例10: hasFlag

    def hasFlag(self, name):
        try:
            from comoonics import XmlTools

            return len(XmlTools.evaluateXPath("flag/@name=" + name, self.element))
        except Exception:
            return False
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:7,代码来源:ComPartition.py

示例11: test_evaluateXPath

 def test_evaluateXPath(self):
     for doc in self.docs:
         if len(doc) > 1:
             (doc, xpathtest)=doc
             (xpath, expectedresult, dummy) = xpathtest
             result=XmlTools.evaluateXPath(xpath, doc)
             self.assertEquals(result, expectedresult, "Result of xpath %s in document does not equals the expected result: %s != %s" %(xpath, result, expectedresult))
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:7,代码来源:testXmlTools.py

示例12: getDOMElement

 def getDOMElement(self, name):
     '''returns a DOM Element from the given member name'''
     from comoonics import XmlTools
     file=self.ahandler.getFileObj(name)
     doc=XmlTools.parseXMLFP(file)
     self.ahandler.closeAll()
     return doc.documentElement
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:7,代码来源:ComArchive.py

示例13: _createElement

 def _createElement(filename, document, element=None):
     """
     Create an empty file element. If document is given the document is the bases.
     @param filename: the filename to be given to the file
     @type  filename: String
     @param document: the xml.dom.Document to use for creating a new element. If None it will be 
                      automatically created
     @type  document: xml.dom.Document
     @param element:  if given the element will be used as bases for creating the file element. Default: None (empty element will be created)
     @type  element:  xml.dom.Element
     @return: The element and the document being created
     @rtype:  [xml.dom.Element, xml.dom.Document] 
     """
     import xml.dom
     from comoonics import XmlTools
     if not document:
         impl=xml.dom.getDOMImplementation()
         document=impl.createDocument(None, File.TAGNAME, None)
         relement=document.documentElement
     elif not element:
         relement=document.createElement(File.TAGNAME)
     else:
         relement=XmlTools.clone_node(element, document)
     relement.setAttribute(File.ATTRNAME, filename)
     return (relement, document)
开发者ID:MarcGrimme,项目名称:comoonics-cluster-suite,代码行数:25,代码来源:ComFile.py

示例14: removeFlag

 def removeFlag(self, name):
     try:
         from comoonics import XmlTools
         node=XmlTools.evaluateXPath('flag/@name='+name, self.element)[0]
         self.element.removeChild(node)
     except Exception:
         raise ComException("no flag with name %s found" %name)
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:7,代码来源:ComPartition.py

示例15: addDOMElement

 def addDOMElement(self, element, name=None):
     '''adds an DOM Element as member name'''
     from comoonics import XmlTools
     if name == None:
         name=self.getNextFileName()
     fd, path = tempfile.mkstemp()
     file = os.fdopen(fd, "w")
     XmlTools.toPrettyXMLFP(element, file)
     file.close()
     try:
         self.ahandler.addFile(path, name)
         os.unlink(path)
     except Exception, e:
         os.unlink(path)
         ComLog.debugTraceLog(Archive.log)
         raise e
开发者ID:Open-Sharedroot,项目名称:Open-Sharedroot-cluster-suite,代码行数:16,代码来源:ComArchive.py


注:本文中的comoonics.XmlTools类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。