mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Namespace 'status' functions in 'win_status'
This commit is contained in:
parent
87b269fc80
commit
d946d10597
2 changed files with 42 additions and 33 deletions
|
@ -4,7 +4,6 @@ Module for returning various status data about a minion.
|
|||
These data can be useful for compiling into stats later.
|
||||
'''
|
||||
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import datetime
|
||||
|
@ -38,6 +37,16 @@ __func_alias__ = {
|
|||
}
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Not all functions supported by Windows
|
||||
'''
|
||||
if salt.utils.is_windows():
|
||||
return False, 'Windows platform is not supported by this module'
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
||||
def _number(text):
|
||||
'''
|
||||
Convert a string to a number.
|
||||
|
@ -64,8 +73,6 @@ def procs():
|
|||
salt '*' status.procs
|
||||
'''
|
||||
# Get the user, pid and cmd
|
||||
if salt.utils.is_windows():
|
||||
raise CommandExecutionError('This platform is not supported')
|
||||
ret = {}
|
||||
uind = 0
|
||||
pind = 0
|
||||
|
@ -114,8 +121,6 @@ def custom():
|
|||
|
||||
salt '*' status.custom
|
||||
'''
|
||||
if salt.utils.is_windows():
|
||||
raise CommandExecutionError('This platform is not supported')
|
||||
ret = {}
|
||||
conf = __salt__['config.dot_vals']('status')
|
||||
for key, val in six.iteritems(conf):
|
||||
|
@ -584,10 +589,6 @@ def diskusage(*args):
|
|||
salt '*' status.diskusage ext? # usage for ext[234] filesystems
|
||||
salt '*' status.diskusage / ext? # usage for / and all ext filesystems
|
||||
'''
|
||||
|
||||
if salt.utils.is_windows():
|
||||
raise CommandExecutionError('This platform is not supported')
|
||||
|
||||
selected = set()
|
||||
fstypes = set()
|
||||
if not args:
|
||||
|
@ -926,8 +927,6 @@ def w(): # pylint: disable=C0103
|
|||
|
||||
salt '*' status.w
|
||||
'''
|
||||
if salt.utils.is_windows():
|
||||
raise CommandExecutionError('This platform is not supported')
|
||||
user_list = []
|
||||
users = __salt__['cmd.run']('w -h').splitlines()
|
||||
for row in users:
|
||||
|
|
|
@ -12,47 +12,57 @@ or for problem solving if your minion is having problems.
|
|||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import ctypes
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
from subprocess import list2cmdline
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.utils
|
||||
import salt.ext.six as six
|
||||
import salt.utils.event
|
||||
from salt._compat import subprocess
|
||||
from salt.utils.network import host_to_ips as _host_to_ips
|
||||
from salt.modules.status import master, ping_master, time_
|
||||
from salt.utils import namespaced_function as _namespaced_function
|
||||
|
||||
import os
|
||||
import ctypes
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
from subprocess import list2cmdline
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
# Import 3rd Party Libs
|
||||
if salt.utils.is_windows():
|
||||
import wmi
|
||||
import salt.utils.winapi
|
||||
has_required_packages = True
|
||||
except ImportError:
|
||||
if salt.utils.is_windows():
|
||||
log.exception('pywin32 and wmi python packages are required '
|
||||
'in order to use the status module.')
|
||||
has_required_packages = False
|
||||
HAS_WMI = True
|
||||
else:
|
||||
HAS_WMI = False
|
||||
|
||||
__opts__ = {}
|
||||
|
||||
# Define the module's virtual name
|
||||
__virtualname__ = 'status'
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only works on Windows systems
|
||||
Only works on Windows systems with WMI and WinAPI
|
||||
'''
|
||||
if salt.utils.is_windows() and has_required_packages:
|
||||
return __virtualname__
|
||||
return (False, 'Cannot load win_status module on non-windows')
|
||||
if not salt.utils.is_windows():
|
||||
return False, 'win_status.py: Requires Windows'
|
||||
|
||||
if not HAS_WMI:
|
||||
return False, 'win_status.py: Requires WMI and WinAPI'
|
||||
|
||||
# Namespace modules from `status.py`
|
||||
global ping_master, time_
|
||||
ping_master = _namespaced_function(ping_master, globals())
|
||||
time_ = _namespaced_function(time_, globals())
|
||||
|
||||
return __virtualname__
|
||||
|
||||
__func_alias__ = {
|
||||
'time_': 'time'
|
||||
}
|
||||
|
||||
|
||||
def cpuload():
|
||||
|
|
Loading…
Add table
Reference in a new issue