def save(self):
        """
        save to peristant storage
        """
        _log.debug( "_clients %s " % (self._clients) )
        try:
            _log.debug( "Dictionary to be saved %s " % (self._persistData) )

            xmlDom = getXmlDomFromDict( self._persistData, rootElem = None )
            _log.debug( "Xml %s" % (getElemPrettyXml(xmlDom)) )

            saveXmlToFilePretty( "%s.xml" % self.persistFile , xmlDom )

        except Exception, ex:
            # possibly read only storage
            _log.exception( "load" )
示例#2
0
def copy(configsetname, node, tgtconfigsetname, tgtnode):
    """
    Copy specified configuration, updating the node number containmed in its body    
    """
    cnfxml = read(configsetname, node)
    if node == tgtnode:
        newxml = cnfxml
    else:
        cnfdom = parseXmlString(cnfxml)
        wbroot = cnfdom.documentElement
        wbsn   = getNamedNode(wbroot, "SN")
        if not wbsn:
            return "Config file has no <SN> element (node number)"
        replaceChildrenText(wbsn, tgtnode)
        newxml = getElemPrettyXml(cnfdom)
        # newxml = cnfdom.toprettyxml(indent="  ",newl="\n")
    return write(tgtconfigsetname, tgtnode, newxml)