[Kimchi-devel] [PATCH V2] Fix Software Update rebase issue.

Paulo Vital pvital at linux.vnet.ibm.com
Mon Feb 17 15:15:44 UTC 2014


V1 -> V2:

SoftwareUpdate() executes an exception if there's no pkg manager in the host, so
I changed previous patch to use try/except while instantiating PackagesUpdateModel()

V1:

During the last merge/rebase to apply Software Update feature to the code,
an important line was removed. This fix is adding it again and enabling the
code to list all host's package updates.

Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 src/kimchi/model/host.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 68028b2..ef40879 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -262,21 +262,25 @@ class DeviceModel(object):
 
 class PackagesUpdateModel(object):
     def __init__(self, **kargs):
-
+        try:
+            self.host_swupdate = SoftwareUpdate()
+        except:
+            self.host_swupdate = None
         self.objstore = kargs['objstore']
         self.task = TaskModel(**kargs)
 
     def get_list(self):
+        if self.host_swupdate is None:
+            raise OperationFailed('KCHPKGUPD0004E')
+
         return self.host_swupdate.getUpdates()
 
     def update(self, **kargs):
-        try:
-            swupdate = SoftwareUpdate()
-        except Exception:
+        if self.host_swupdate is None:
             raise OperationFailed('KCHPKGUPD0004E')
 
         try:
-            pkgs = swupdate.getNumOfUpdates()
+            pkgs = self.host_swupdate.getNumOfUpdates()
         except OperationFailed, e:
             raise e
 
@@ -284,7 +288,7 @@ class PackagesUpdateModel(object):
             raise OperationFailed('KCHPKGUPD0001E')
 
         kimchi_log.debug('Host is going to be updated.')
-        taskid = add_task('', swupdate.doUpdate, self.objstore, None)
+        taskid = add_task('', self.host_swupdate.doUpdate, self.objstore, None)
         return self.task.lookup(taskid)
 
 
-- 
1.8.3.1




More information about the Kimchi-devel mailing list