mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Make needs_reboot not part of class
This commit is contained in:
parent
50a1440d57
commit
a66777e6b6
@ -162,10 +162,7 @@ def available(software=True,
|
||||
severities)
|
||||
|
||||
# Return results as Summary or Details
|
||||
if summary:
|
||||
return updates.summary()
|
||||
else:
|
||||
return updates.list()
|
||||
return updates.summary() if summary else updates.list()
|
||||
|
||||
|
||||
def list_update(name, download=False, install=False):
|
||||
@ -249,10 +246,7 @@ def list_update(name, download=False, install=False):
|
||||
if install:
|
||||
ret['Install'] = wua.install(updates.updates)
|
||||
|
||||
if not ret:
|
||||
return updates.list()
|
||||
|
||||
return ret
|
||||
return ret if ret else updates.list()
|
||||
|
||||
|
||||
def list_updates(software=True,
|
||||
@ -393,10 +387,7 @@ def list_updates(software=True,
|
||||
ret['Install'] = wua.install(updates.updates)
|
||||
|
||||
if not ret:
|
||||
if summary:
|
||||
return updates.summary()
|
||||
else:
|
||||
return updates.list()
|
||||
return updates.summary() if summary else updates.list()
|
||||
|
||||
return ret
|
||||
|
||||
@ -435,7 +426,7 @@ def download_update(name):
|
||||
raise CommandExecutionError('No updates found')
|
||||
|
||||
if updates.count() > 1:
|
||||
raise CommandExecutionError('More than one update found')
|
||||
raise CommandExecutionError('Multiple updates found, narrow your search')
|
||||
|
||||
return wua.download(updates.updates)
|
||||
|
||||
@ -507,7 +498,7 @@ def install_update(name):
|
||||
raise CommandExecutionError('No updates found')
|
||||
|
||||
if updates.count() > 1:
|
||||
raise CommandExecutionError('More than one update found')
|
||||
raise CommandExecutionError('Multiple updates found, narrow your search')
|
||||
|
||||
return wua.install(updates.updates)
|
||||
|
||||
@ -579,7 +570,7 @@ def uninstall(name):
|
||||
raise CommandExecutionError('No updates found')
|
||||
|
||||
if updates.count() > 1:
|
||||
raise CommandExecutionError('More than one update found')
|
||||
raise CommandExecutionError('Multiple updates found, narrow your search')
|
||||
|
||||
return wua.uninstall(updates.updates)
|
||||
|
||||
@ -943,4 +934,4 @@ def get_needs_reboot():
|
||||
salt '*' win_wua.get_needs_reboot
|
||||
|
||||
'''
|
||||
return salt.utils.win_update.WindowsUpdateAgent.needs_reboot()
|
||||
return salt.utils.win_update.needs_reboot()
|
||||
|
@ -531,7 +531,7 @@ class WindowsUpdateAgent(object):
|
||||
# Populate the return dictionary
|
||||
ret['Success'] = True
|
||||
ret['Message'] = 'Uninstalled using WUSA'
|
||||
ret['NeedsReboot'] = self.needs_reboot()
|
||||
ret['NeedsReboot'] = needs_reboot()
|
||||
log.debug('NeedsReboot: {0}'.format(ret['NeedsReboot']))
|
||||
|
||||
# Refresh the Updates Table
|
||||
@ -589,21 +589,25 @@ class WindowsUpdateAgent(object):
|
||||
|
||||
return ret
|
||||
|
||||
def needs_reboot():
|
||||
'''
|
||||
Determines if the system needs to be rebooted.
|
||||
|
||||
Returns:
|
||||
def needs_reboot():
|
||||
'''
|
||||
Determines if the system needs to be rebooted.
|
||||
|
||||
bool: True if the system requires a reboot, False if not
|
||||
Returns:
|
||||
|
||||
CLI Examples:
|
||||
bool: True if the system requires a reboot, False if not
|
||||
|
||||
.. code-block:: bash
|
||||
CLI Examples:
|
||||
|
||||
salt '*' win_wua.get_needs_reboot
|
||||
.. code-block:: bash
|
||||
|
||||
'''
|
||||
# Create an AutoUpdate object
|
||||
obj_sys = win32com.client.Dispatch('Microsoft.Update.SystemInfo')
|
||||
return salt.utils.is_true(obj_sys.RebootRequired)
|
||||
salt '*' win_wua.get_needs_reboot
|
||||
|
||||
'''
|
||||
# Initialize the PyCom system
|
||||
pythoncom.CoInitialize()
|
||||
|
||||
# Create an AutoUpdate object
|
||||
obj_sys = win32com.client.Dispatch('Microsoft.Update.SystemInfo')
|
||||
return salt.utils.is_true(obj_sys.RebootRequired)
|
||||
|
Loading…
Reference in New Issue
Block a user