Re: Problems with the RpmModule

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 14, 2010 at 1:29 AM, jimmy cho <jimmyradix@xxxxxxxxx> wrote:
> Hi,
>
> I have create 2 tickets  88, 89
>
> Solutions :
>
> 1. Don't use  python-2.6 syntax  as  Func should work with RHEL 4 and
> RHEL 5  and other Red Hat Clone Distros  :)
> 2. Keep RpmModule  rpm native,  no yum stuff inside.  that is what the
> yummodule is  for.
>
>
>
> rgds
>
> Jimmy
>
>
> On Thu, Jan 14, 2010 at 4:50 PM, Luca Foppiano <lfoppiano@xxxxxxxxxxxxx> wrote:
>> On 01/14/2010 08:38 AM, jimmy cho wrote:
>>> Hi,
>>>
>>> First I just want to say I find this a very useful project.  In
>>> implementing it I encounter a few issue which I would like to
>>> document here.
>>>
>>> I am working with a bunch of   RHEL 4  and RHEL 5  servers.  I
>>> installed  the epel  RPM packages   for  EL4 and EL5.
>>>
>>> I noticed that
>>>
>>> #func   testserver   call rpms  inventory
>>>
>>> returns a empty list. for both EL4 and EL5 servers.  After some
>>> digging I found that the  inventory  function  in   rpms.py    is
>>> commented out so it will never work.
>>> Removing the comments did not help.
>>>
>>> OK so I installed  func-0.25  on the overlord and minion with the
>>> certmaster also updated  to 0.25.
>>>
>>> Now I find that  RpmModule does not load.
>>>
>>> I checked  on the  rpms.py
>>>
>>> line 56       mi = (ts.dbMatch() if pattern == '' else self.glob(pattern))
>>>
>>> has a syntax  error.    On EL5   uses  python-2.4.  could this be the problem ?
>>>
>> Could you please send the error you got? I don't have a ELA4/5 machine
>> to test it.
>> Anyway if you have proposal about how to fix it, send me :)
>>
>>> I  commented out the entire verify  function  ( which has the
>>> problematic  line of code ) and now the rpms inventory  works very  nicely.
>>>
>>> I notice another thing about the verify function.
>>>
>>> I believe that  the RpmModule is suppose to provide the ability to
>>> handle rpm function for systems that do
>>> use yum  like  EL4.
>>>
>>> So it is not appropriate for the verify function  in rpms.py to use
>>> the yum  module to verify the packages.
>>>
>> Agreed, we might fix everything in once.
>> Could you please open a ticket, because the email is simple to be forgotten.
>>
>> thanks
>> Luca
>>


I attached these patches to the tickets, but I should probably also
post them here.  Here's two patches that fix Tickets #88 and #89



---Brett.



index 4537af4..b28ec9b 100644
--- a/func/minion/modules/rpms.py
+++ b/func/minion/modules/rpms.py
@@ -50,7 +50,6 @@ class RpmModule(func_module.FuncModule):
         Returns information on the verified package(s).
         """
         import rpm
-        import yum
         from re import split
         ts = rpm.TransactionSet()
         mi = None
@@ -66,8 +65,15 @@ class RpmModule(func_module.FuncModule):
             else:
                 name = split("\s",hdr)[0]
             if flatten:
-                yb = yum.YumBase()
-                pkgs = yb.rpmdb.searchNevra(name)
+                pkgs = None
+
+                try:
+                    import yum
+                    yb = yum.YumBase()
+                    pkgs = yb.rpmdb.searchNevra(name)
+                except: # RHEL4
+                    pkgs = ts.dbMatch(name)
+
                 for pkg in pkgs:
                     errors = pkg.verify()
                     for fn in errors.keys():




diff --git a/func/minion/modules/rpms.py b/func/minion/modules/rpms.py
index dfe66e1..4537af4 100644
--- a/func/minion/modules/rpms.py
+++ b/func/minion/modules/rpms.py
@@ -53,11 +53,19 @@ class RpmModule(func_module.FuncModule):
         import yum
         from re import split
         ts = rpm.TransactionSet()
-        mi = (ts.dbMatch() if pattern == '' else self.glob(pattern))
+        mi = None
+        if pattern == '':
+            mi = ts.dbMatch()
+        else:
+            mi = self.glob(pattern)
         results = []
         for hdr in mi:
-            name = hdr['name'] if pattern == '' else split("\s",hdr)[0]
-            if flatten:
+            name = None
+            if pattern == '':
+                name = hdr['name']
+            else:
+                name = split("\s",hdr)[0]
+            if flatten:
                 yb = yum.YumBase()
                 pkgs = yb.rpmdb.searchNevra(name)
                 for pkg in pkgs:

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux