Thanks a lot for your comprehensive answer.
On 05/17/2011 04:06 PM, Miroslav Suchý wrote:
errata.update only receives a list of errata ids, how could we get the
names from the server in order to send them to zypper? I looked around
Hmm, I thought that zypper code could handle it already. How did you
done it till now?
Right now it's done the same way that yum does it - it receives the list
of packages and installs them as normal packages. This approach doesn't
work so well for zypper though.
Could we add a getErrataNamesById method the xmlrpc API under errata?
Yes, you can.
Generally - if you need some API (backend or frontend) and you did not
change semantics of old ones. And as far as the new API call does not
create security risk (e.g. providing info, which system should not see).
Then you can add it without problem.
I have attached a patch to add a new method to the API which returns the
names of erratas when given a list of errata ids. We need this so we can
call it from actions/errata.py in the zypp-plugin-spacewalk.
-Ionuț
>From 4c72b6bf32872377e427bcc53cfefe8e59e69895 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ionu=C8=9B=20Ar=C8=9B=C4=83ri=C8=99i?= <iartar...@suse.cz>
Date: Wed, 18 May 2011 12:31:59 +0200
Subject: [PATCH] added errata.getErrataNamesById function to the API
---
backend/server/handlers/xmlrpc/errata.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/backend/server/handlers/xmlrpc/errata.py b/backend/server/handlers/xmlrpc/errata.py
index 5b11637..b5fbada 100644
--- a/backend/server/handlers/xmlrpc/errata.py
+++ b/backend/server/handlers/xmlrpc/errata.py
@@ -35,6 +35,7 @@ class Errata(rhnHandler):
self.functions.append('GetByPackage') # Clients v1-
self.functions.append('getPackageErratum') # Clients v2+
self.functions.append('getErrataInfo') # clients v2+
+ self.functions.append('getErrataNamesById')
def GetByPackage(self, pkg, osRel):
""" Clients v1- Get errata for a package given "n-v-r" format
@@ -243,6 +244,26 @@ class Errata(rhnHandler):
return ret
+ def getErrataNamesById(self, errata_ids):
+ """Return a list of RhnErrata names
+
+ :arg errata_ids: a list of RhnErrata ids
+
+ Returns an empty list if no erratas were found for the provided ids.
+
+ """
+ # transform the list of ints to an sql list that we can forcibly
+ # insert into the sql statement
+ sql_list = ', '.join([str(i) for i in errata_ids])
+
+ sql = """SELECT advisory_name FROM rhnerrata
+ WHERE id IN (%s)""" % sql_list
+ h = rhnSQL.prepare(sql)
+ h.execute()
+ erratas = [tup[0] for tup in h.fetchall()]
+
+ return erratas
+
#-----------------------------------------------------------------------------
if __name__ == "__main__":
print "You can not run this module by itself"
--
1.7.3.4
_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel