Exemple #1
0
 def queryXml(self, query):
     """
     Provides the possibility to execute queries 
     which are not yet implemented as a direct function 
     to get a part of the xml.
     
     @param query: xpath to query clusterinfo instance
     @type query: string
     @return: answer of proceeded query as xml
     @rtype: list(xml.dom.Node)
     """
     self.log.debug("queryXml: %s" % (query))
     _tmp1 = evaluateXPath(query, self.clusterRepository.getElement())
     return _tmp1
 def queryXml(self, query):
     """
     Provides the possibility to execute queries 
     which are not yet implemented as a direct function 
     to get a part of the xml.
     
     @param query: xpath to query clusterinfo instance
     @type query: string
     @return: answer of proceeded query as xml
     @rtype: list(xml.dom.Node)
     """
     self.log.debug("queryXml: %s" %(query))
     _tmp1 = evaluateXPath(query, self.clusterRepository.getElement())
     return _tmp1
Exemple #3
0
 def queryValue(self, query):
     """
     Provides the possibility to get specific values by 
     execute queries which are not yet implemented as a 
     direct function.
     
     @param query: xpath to query clusterinfo instance
     @type query: string
     @return: answer of proceeded query as list of strings
     @rtype: list
     """
     self.log.debug("queryValue: %s" % (query))
     _tmp1 = evaluateXPath(query, self.clusterRepository.getElement())
     _tmp2 = []
     for i in range(len(_tmp1)):
         _tmp2.append(_tmp1[i])
     return _tmp2
 def queryValue(self, query):
     """
     Provides the possibility to get specific values by 
     execute queries which are not yet implemented as a 
     direct function.
     
     @param query: xpath to query clusterinfo instance
     @type query: string
     @return: answer of proceeded query as list of strings
     @rtype: list
     """
     self.log.debug("queryValue: %s" %(query))
     _tmp1 = evaluateXPath(query, self.clusterRepository.getElement())
     _tmp2 = []
     for i in range(len(_tmp1)):
         _tmp2.append(_tmp1[i])
     return _tmp2
def getClusterRepository(*args, **kwds):
    """
    Factory method to autocreate a fitting cluster repository.
    The following call semantics are supported:
    getClusterRepository() => SimpleComoonicsClusterRepository
    getClusterRepository(filename) => ComoonicsClusterRepository
    getClusterRepository(docelement, doc, options) => ComoonicsClusterRepository
    getClusterRepository(filename=filename) => ComoonicsClusterRepository
    getClusterRepository(clusterconf=filename) => ComoonicsClusterRepository
    getClusterRepository(maxnodeid=maxnodeid) => SimpleClusterRepository
    Parses the given filename as configuration to the given cluster or already accept a parsed configuration. 
    Right now only xml.dom.Node representation of the cluster configuration is supported.
    @param filename:   representation of the path to the cluster configuration. If it is a xml file it will be parsed. 
                       If not an exception is thrown.
    @type  filename:   L{String} 
    @param docelement: the already parse configuration as dom document.
    @type  docelement: L{xml.dom.Element}
    @param doc:        the document itself.
    @type  doc:        L{xml.dom.Docuement}
    @param options:    options see ClusterRepository constructor.
    @type  options:    L{dict}
    @return:           The best fitting clusterconfiguration repository class instance
    @rtype:            L{ComoonicsClusterRepository}, L{RedHatClusterRepository}, ..
    """
    from comoonics.XmlTools import evaluateXPath
    from comoonics.DictTools import searchDict
    import ComClusterRepository
#    from comoonics.cluster.ComClusterRepository import SimpleComoonicsClusterRepository, ComoonicsClusterRepository, RedHatClusterRepository
    repositoryclass=ComClusterRepository.SimpleComoonicsClusterRepository
    
    clusterconf=None
    if (args and len(args) >= 1 and isinstance(args[0], basestring)) or (kwds and (kwds.has_key("clusterconf") or kwds.has_key("filename"))):
        if args and len(args) >= 1 and isinstance(args[0], basestring):
            clusterconf=args[0]
        elif kwds.has_key("clusterconf"):
            clusterconf=kwds.get("clusterconf")
            del kwds["clusterconf"]
        elif kwds.has_key("filename"):
            clusterconf=kwds.get("filename")
            del kwds["filename"]
    
    if clusterconf and os.path.isfile(clusterconf):
        doc=parseClusterConf(clusterconf)
        newargs=[doc.documentElement,doc]
        newargs.extend(args[1:])
        args=newargs
        if len(evaluateXPath(ComClusterRepository.ComoonicsClusterRepository.getDefaultComoonicsXPath(), doc.documentElement)) > 0:
            repositoryclass = ComClusterRepository.ComoonicsClusterRepository
        elif len(evaluateXPath(ComClusterRepository.RedHatClusterRepository.getDefaultClusterNodeXPath(), doc.documentElement)) > 0:
            repositoryclass = ComClusterRepository.RedHatClusterRepository
    elif len(args) >= 2 or kwds.has_key("element"):
        if args and args[0]:
            element=args[0]
        else:
            element=kwds.get("element", None)
        if (element != None):
            if args and len(args)>=3:
                options=args[2]
            else:
                options=kwds.get("options", {})       
            if evaluateXPath(ComClusterRepository.ComoonicsClusterRepository.getDefaultComoonicsXPath(""), element) or not options:
                repositoryclass = ComClusterRepository.ComoonicsClusterRepository
            elif evaluateXPath(ComClusterRepository.RedHatClusterRepository.getDefaultClusterNodeXPath(), element):
                repositoryclass = ComClusterRepository.RedHatClusterRepository
                
        elif type(args[2]) == dict:
            if searchDict(args[2],"osr"):
                repositoryclass = ComClusterRepository.ComoonicsClusterRepository
            elif searchDict(args[2],ComClusterRepository.RedHatClusterRepository.element_clusternode):
                repositoryclass = ComClusterRepository.RedHatClusterRepository
            
    return repositoryclass(*args, **kwds) #, *args, **kwds)