[Spacewalk-list] Systems Requiring Reboot
Alexander Dacre
alex.dacre at aridhia.com
Thu Oct 2 13:29:00 UTC 2014
Hi Stephan,
Thanks for the workaround, seems reasonable.
It always was a moonshot!
Alex Dacre
Systems Engineer
+44 131 560 1466
-----Original Message-----
From: spacewalk-list-bounces at redhat.com [mailto:spacewalk-list-bounces at redhat.com] On Behalf Of Stephan Duehr
Sent: 02 October 2014 14:26
To: spacewalk-list at redhat.com
Subject: Re: [Spacewalk-list] Systems Requiring Reboot
Hi,
no such API method exists as far as I know.
A workaround could be to use the API method for getting the running kernel (system.getRunningKernel) and compare that somehow with the latest installed kernel package.
You could use system.listPackages to get all installed packages and the lookup the installed kernel packages in the result.
Some experiment, to show how it could be done:
>>> import pprint
>>> pp=pprint.PrettyPrinter(indent=4)
>>> sys_id = 1000010435
>>> running_kernel = client.system.getRunningKernel(session, sys_id)
>>> installed_kernels = [pkg for pkg in
>>> client.system.listPackages(session, sys_id) if pkg['name'] ==
>>> 'kernel']
>>> pp.pprint(installed_kernels)
[ { 'arch': 'AMD64',
'epoch': ' ',
'installtime': <DateTime '20140724T08:37:54' at 1677f38>,
'name': 'kernel',
'release': '431.el6',
'version': '2.6.32'},
{ 'arch': 'AMD64',
'epoch': ' ',
'installtime': <DateTime '20140724T08:45:54' at 1677f80>,
'name': 'kernel',
'release': '431.20.3.el6',
'version': '2.6.32'},
{ 'arch': 'AMD64',
'epoch': ' ',
'installtime': <DateTime '20140729T09:09:18' at 1677fc8>,
'name': 'kernel',
'release': '431.20.5.el6',
'version': '2.6.32'},
{ 'arch': 'AMD64',
'epoch': ' ',
'installtime': <DateTime '20140805T08:23:18' at 1682050>,
'name': 'kernel',
'release': '431.23.3.el6',
'version': '2.6.32'}]
>>> latest_installed_kernel = None
>>> for ik in installed_kernels:
... if not client.system.listNewerInstalledPackages(session, sys_id, ik['name'], ik['version'], ik['release'], ik['epoch']):
... latest_installed_kernel = ik
... break
...
>>> pp.pprint(latest_installed_kernel)
{ 'arch': 'AMD64',
'epoch': ' ',
'installtime': <DateTime '20140805T08:23:18' at 1682050>,
'name': 'kernel',
'release': '431.23.3.el6',
'version': '2.6.32'}
>>> running_kernel
'2.6.32-431.23.3.el6.x86_64'
>>> system_arch = client.system.getCpu(session, sys_id)['arch']
>>> system_arch
'x86_64'
>>> if running_kernel == '%s-%s.%s' % (latest_installed_kernel['version'], latest_installed_kernel['release'], system_arch):
... print "no reboot required"
... else:
... print "reboot required"
...
no reboot required
Now after installing a newer kernel packages was installed:
>>> installed_kernels = [pkg for pkg in
>>> client.system.listPackages(session, sys_id) if pkg['name'] ==
>>> 'kernel'] latest_installed_kernel = None for ik in installed_kernels:
... if not client.system.listNewerInstalledPackages(session, sys_id, ik['name'], ik['version'], ik['release'], ik['epoch']):
... latest_installed_kernel = ik
... break
...
>>> pp.pprint(latest_installed_kernel)
{ 'arch': 'AMD64',
'epoch': ' ',
'installtime': <DateTime '20141002T14:53:37' at 1675290>,
'name': 'kernel',
'release': '431.29.2.el6',
'version': '2.6.32'}
>>> system_arch = client.system.getCpu(session, sys_id)['arch'] if
>>> running_kernel == '%s-%s.%s' % (latest_installed_kernel['version'], latest_installed_kernel['release'], system_arch):
... print "no reboot required"
... else:
... print "reboot required"
...
reboot required
Regards,
Stephan
On 10/02/2014 11:35 AM, Alexander Dacre wrote:
> Hi,
>
>
>
> Is there an API method available that will return a value indicating if a particular system requires a reboot or not?
>
>
>
> I've had a quick look and not been able to find anything, has anybody found a workaround?
>
>
>
> Thanks,
>
>
>
> Alex Dacre
>
> Systems Engineer
>
>
>
>
>
> _______________________________________________
> Spacewalk-list mailing list
> Spacewalk-list at redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-list
>
--
Stephan Dühr stephan.duehr at dass-it.de
dass IT GmbH Phone: +49.221.3565666-90
http://www.dass-IT.de Fax: +49.221.3565666-10
Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRB52500
Geschäftsführer: S. Dühr, M. Außendorf, Jörg Steffens, P. Storz
_______________________________________________
Spacewalk-list mailing list
Spacewalk-list at redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-list
More information about the Spacewalk-list
mailing list