Skip to content

Commit

Permalink
Adding new pkg_mgmt func plus data_collector emitter
Browse files Browse the repository at this point in the history
Ref to #1619
Over pkg_mgmt new yum_check func running yum check-update:
we throw rc != 0 because we need it, if rc = 0 no updates,
if rc == 100 then we have some available packages updates
data_collector new yum_updates emitter return True/False
starting from yum_check returned rc val

Signed-off-by: Mirko Arena <mirko.arena@gmail.com>
  • Loading branch information
MFlyer committed Mar 7, 2017
1 parent ab2d320 commit 839c8e2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/rockstor/smart_manager/data_collector.py
@@ -1,5 +1,5 @@
"""
Copyright (c) 2012-2016 RockStor, Inc. <http://rockstor.com>
Copyright (c) 2012-2017 RockStor, Inc. <http://rockstor.com>
This file is part of RockStor.
RockStor is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -47,7 +47,7 @@
from smart_manager.models import Service # noqa E402
from system.services import service_status # noqa E402
from cli.api_wrapper import APIWrapper # noqa E402
from system.pkg_mgmt import update_check # noqa E402
from system.pkg_mgmt import (update_check, yum_check) # noqa E402
import logging # noqa E402
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -933,6 +933,19 @@ def update_check(self):
'data': uinfo
})

def yum_updates(self):

while self.start:
rc = yum_check()
data = {}
data['yum_updates'] = True if rc == 100 else False
self.emit('yum_updates',
{
'key': 'sysinfo:yum_updates',
'data': data
})
gevent.sleep(20)

def prune_logs(self):

while self.start:
Expand Down
8 changes: 8 additions & 0 deletions src/rockstor/system/pkg_mgmt.py
Expand Up @@ -210,3 +210,11 @@ def update_run(subscription=None):
time.sleep(120)

return out, err, rc

def yum_check():
# Query yum for updates and grab return code
# yum check-update retun code is 0 with no updates
# and 100 if at least 1 update available
out, err, rc = run_command([YUM, 'check-update'], throw=False)

return rc

0 comments on commit 839c8e2

Please sign in to comment.