def getDiffsFromSourcesByMaster(self, sourcenames, master, colnames=None, limitup=0, limitdown=0, where=None, orderby=None, Diffs=True, NotInstalled=True, Installed=False):
        """
        Returns a resultset of differences of the given sourcenames.
        Parameter are the sourcesnames to compare
        """
        orderbyclause=BaseDB.resolveOrderBy(orderby)
        limit=BaseDB.getLimit(limitup, limitdown)
        self.log.debug("where: %s" %(where))
        self.log.debug("orderbyclause: %s, limit: %s, diffs: %s, notinstalled: %s, Installed: %s" %(orderbyclause, limit, Diffs, NotInstalled, Installed))
        if not colnames:
            self.log.debug("getting colnames")
            colnames=self.SELECT_FOR_DIFFS_MASTER
        j=0
#        ComLog.getLogger().debug("query %s" % query)
        queries=list()
        for sourcename in sourcenames:
            if Installed:
                queries.append(self.selectQueryOnlyEqualInstalledByMaster(sourcename, master, colnames, where, Diffs or NotInstalled))
            if Diffs:
                queries.append(self.selectQueryOnlyDiffsByMaster(sourcename, master, colnames, where, Installed))
            if NotInstalled:
                queries.append(self.selectQueryNotInstalledByMaster(sourcename, master, colnames, where, True, Installed))
                queries.append(self.selectQueryNotInstalledByMaster(sourcename, master, colnames, where, False, Installed))
        union="\n UNION \n".join(queries)
        if orderbyclause and orderbyclause!="":
            union+="\n"+orderbyclause
        if limit and limit != "":
            union+="\n"+limit
        self.log.debug("union: "+union)
        return self.selectQuery(union)
Beispiel #2
0
 def getSoftwareDublicates(self,
                           clustername,
                           _select="*",
                           _limitup=0,
                           _limitdown=0,
                           _where=None,
                           _orderby=None):
     if _where == None:
         _where = list()
     # Quickhack to support mysql3
     if type(_where) == list:
         for i in range(len(_where)):
             _where[i] = "t1." + _where[i]
     limit = BaseDB.getLimit(_limitup, _limitdown)
     self.log.debug("where: %s" % (_where))
     _where.append("t1.clustername=\"%s\"" % (clustername))
     #        _where+=" AND ".join(_where)
     whereclause = BaseDB.resolveWhere(_where)
     orderbyclause = BaseDB.resolveOrderBy(_orderby)
     self.log.debug("whereclause: %s" % (whereclause))
     query="""SELECT DISTINCT %s FROM %s AS t1
 LEFT JOIN %s AS t2
    USING (clustername, name)
    %s
     AND (t1.version != t2.version OR t1.subversion != t2.subversion)
     %s %s;""" \
     %("t1."+", t1.".join(_select), self.tablename, self.tablename, whereclause, orderbyclause, limit)
     self.log.debug("query: %s" % (query))
     return self.selectQuery(query)
Beispiel #3
0
    def getDiffsFromSources(self,
                            sourcenames,
                            colnames=None,
                            limitup=0,
                            limitdown=0,
                            where=None,
                            orderby=None,
                            Diffs=True,
                            NotInstalled=True,
                            Installed=False):
        """
        Returns a resultset of differences of the given sourcenames.
        Parameter are the sourcesnames to compare
        """
        if not sourcenames or type(sourcenames) != list or len(
                sourcenames) <= 1:
            return None

        orderbyclause = BaseDB.resolveOrderBy(orderby)
        limit = BaseDB.getLimit(limitup, limitdown)
        self.log.debug("where: %s" % (where))
        self.log.debug(
            "orderbyclause: %s, limit: %s, diffs: %s, notinstalled: %s" %
            (orderbyclause, limit, Diffs, NotInstalled))
        self.log.debug("getting colnames")
        if not colnames:
            colnames = self.getColnamesForDiff(sourcenames)
        j = 0
        #        ComLog.getLogger().debug("query %s" % query)
        queries = list()
        installed = None
        if Installed:
            if Diffs or NotInstalled:
                installed = 0
            queries.append(
                self.selectQueryInstalled(sourcenames, colnames,
                                          SoftwareCMDB.COMPARE_2_SOFTWARE,
                                          where, installed))
        if Diffs:
            if Installed:
                installed = 1
            queries.append(
                self.selectQueryOnlyDiffs(sourcenames, colnames,
                                          SoftwareCMDB.COMPARE_2_SOFTWARE,
                                          where, installed))
        if NotInstalled:
            queries += self.selectQueriesNotInstalled(
                sourcenames, colnames, SoftwareCMDB.COMPARE_2_SOFTWARE, where,
                Installed)
        union = "\n UNION \n".join(queries)
        if orderbyclause and orderbyclause != "":
            union += "\n" + orderbyclause
        if limit and limit != "":
            union += "\n" + limit
        self.log.debug("union: " + union)
        return self.selectQuery(union)
 def getSoftware(self, clustername, select="*", limitup=0, limitdown=0, where=None, orderby=None):
     if where==None:
         where=list()
     limit=BaseDB.getLimit(limitup, limitdown)
     where.append("clustername=\"%s\"" %(clustername))
     self.log.debug("where: %s" %(where))
     whereclause=BaseDB.resolveWhere(where)
     orderbyclause=BaseDB.resolveOrderBy(orderby)
     self.log.debug("whereclause: %s" %(whereclause))
     query="SELECT DISTINCT %s FROM %s %s %s %s;" %(", ".join(select), self.tablename, whereclause, orderbyclause, limit)
     self.log.debug("query: %s" %(query))
     return self.selectQuery(query)
Beispiel #5
0
 def getDiffsFromSourcesByMaster(self,
                                 sourcenames,
                                 master,
                                 colnames=None,
                                 limitup=0,
                                 limitdown=0,
                                 where=None,
                                 orderby=None,
                                 Diffs=True,
                                 NotInstalled=True,
                                 Installed=False):
     """
     Returns a resultset of differences of the given sourcenames.
     Parameter are the sourcesnames to compare
     """
     orderbyclause = BaseDB.resolveOrderBy(orderby)
     limit = BaseDB.getLimit(limitup, limitdown)
     self.log.debug("where: %s" % (where))
     self.log.debug(
         "orderbyclause: %s, limit: %s, diffs: %s, notinstalled: %s, Installed: %s"
         % (orderbyclause, limit, Diffs, NotInstalled, Installed))
     if not colnames:
         self.log.debug("getting colnames")
         colnames = self.SELECT_FOR_DIFFS_MASTER
     j = 0
     #        ComLog.getLogger().debug("query %s" % query)
     queries = list()
     for sourcename in sourcenames:
         if Installed:
             queries.append(
                 self.selectQueryOnlyEqualInstalledByMaster(
                     sourcename, master, colnames, where, Diffs
                     or NotInstalled))
         if Diffs:
             queries.append(
                 self.selectQueryOnlyDiffsByMaster(sourcename, master,
                                                   colnames, where,
                                                   Installed))
         if NotInstalled:
             queries.append(
                 self.selectQueryNotInstalledByMaster(
                     sourcename, master, colnames, where, True, Installed))
             queries.append(
                 self.selectQueryNotInstalledByMaster(
                     sourcename, master, colnames, where, False, Installed))
     union = "\n UNION \n".join(queries)
     if orderbyclause and orderbyclause != "":
         union += "\n" + orderbyclause
     if limit and limit != "":
         union += "\n" + limit
     self.log.debug("union: " + union)
     return self.selectQuery(union)
Beispiel #6
0
 def getSoftware(self,
                 clustername,
                 select="*",
                 limitup=0,
                 limitdown=0,
                 where=None,
                 orderby=None):
     if where == None:
         where = list()
     limit = BaseDB.getLimit(limitup, limitdown)
     where.append("clustername=\"%s\"" % (clustername))
     self.log.debug("where: %s" % (where))
     whereclause = BaseDB.resolveWhere(where)
     orderbyclause = BaseDB.resolveOrderBy(orderby)
     self.log.debug("whereclause: %s" % (whereclause))
     query = "SELECT DISTINCT %s FROM %s %s %s %s;" % (", ".join(
         select), self.tablename, whereclause, orderbyclause, limit)
     self.log.debug("query: %s" % (query))
     return self.selectQuery(query)
    def getSoftwareDublicates(self, clustername, _select="*", _limitup=0, _limitdown=0, _where=None, _orderby=None):
        if _where==None:
            _where=list()
        # Quickhack to support mysql3
        if type(_where)==list:
            for i in range(len(_where)):
                _where[i]="t1."+_where[i]
        limit=BaseDB.getLimit(_limitup, _limitdown)
        self.log.debug("where: %s" %(_where))
        _where.append("t1.clustername=\"%s\"" %(clustername))
#        _where+=" AND ".join(_where)
        whereclause=BaseDB.resolveWhere(_where)
        orderbyclause=BaseDB.resolveOrderBy(_orderby)
        self.log.debug("whereclause: %s" %(whereclause))
        query="""SELECT DISTINCT %s FROM %s AS t1
    LEFT JOIN %s AS t2
       USING (clustername, name)
       %s
        AND (t1.version != t2.version OR t1.subversion != t2.subversion)
        %s %s;""" \
        %("t1."+", t1.".join(_select), self.tablename, self.tablename, whereclause, orderbyclause, limit)
        self.log.debug("query: %s" %(query))
        return self.selectQuery(query)
    def getDiffsFromSources(self, sourcenames, colnames=None, limitup=0, limitdown=0, where=None, orderby=None, Diffs=True, NotInstalled=True, Installed=False):
        """
        Returns a resultset of differences of the given sourcenames.
        Parameter are the sourcesnames to compare
        """
        if not sourcenames or type(sourcenames)!=list or len(sourcenames)<=1:
            return None

        orderbyclause=BaseDB.resolveOrderBy(orderby)
        limit=BaseDB.getLimit(limitup, limitdown)
        self.log.debug("where: %s" %(where))
        self.log.debug("orderbyclause: %s, limit: %s, diffs: %s, notinstalled: %s" %(orderbyclause, limit, Diffs, NotInstalled))
        self.log.debug("getting colnames")
        if not colnames:
            colnames=self.getColnamesForDiff(sourcenames)
        j=0
#        ComLog.getLogger().debug("query %s" % query)
        queries=list()
        installed=None
        if Installed:
            if Diffs or NotInstalled:
                installed=0
            queries.append(self.selectQueryInstalled(sourcenames, colnames, SoftwareCMDB.COMPARE_2_SOFTWARE, where, installed))
        if Diffs:
            if Installed:
                installed=1
            queries.append(self.selectQueryOnlyDiffs(sourcenames, colnames, SoftwareCMDB.COMPARE_2_SOFTWARE, where, installed))
        if NotInstalled:
            queries+=self.selectQueriesNotInstalled(sourcenames, colnames, SoftwareCMDB.COMPARE_2_SOFTWARE, where, Installed)
        union="\n UNION \n".join(queries)
        if orderbyclause and orderbyclause!="":
            union+="\n"+orderbyclause
        if limit and limit != "":
            union+="\n"+limit
        self.log.debug("union: "+union)
        return self.selectQuery(union)