mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
use cmd._run_quiet and cmd._run_all_quiet instead of importing minion_mods in __salt__
This commit is contained in:
parent
a78652515a
commit
317e41d3c0
@ -157,13 +157,11 @@ def list_(name=None, runas=None):
|
|||||||
return launchctl('list',
|
return launchctl('list',
|
||||||
label,
|
label,
|
||||||
return_stdout=True,
|
return_stdout=True,
|
||||||
output_loglevel='trace',
|
|
||||||
runas=runas)
|
runas=runas)
|
||||||
|
|
||||||
# Collect information on all services: will raise an error if it fails
|
# Collect information on all services: will raise an error if it fails
|
||||||
return launchctl('list',
|
return launchctl('list',
|
||||||
return_stdout=True,
|
return_stdout=True,
|
||||||
output_loglevel='trace',
|
|
||||||
runas=runas)
|
runas=runas)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import plistlib
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
# Import Salt Libs
|
# Import Salt Libs
|
||||||
|
import salt.modules.cmdmod
|
||||||
import salt.utils.args
|
import salt.utils.args
|
||||||
import salt.utils.decorators as decorators
|
import salt.utils.decorators as decorators
|
||||||
import salt.utils.files
|
import salt.utils.files
|
||||||
@ -23,7 +24,6 @@ import salt.utils.timed_subprocess
|
|||||||
import salt.grains.extra
|
import salt.grains.extra
|
||||||
from salt.exceptions import CommandExecutionError, SaltInvocationError,\
|
from salt.exceptions import CommandExecutionError, SaltInvocationError,\
|
||||||
TimedProcTimeoutError
|
TimedProcTimeoutError
|
||||||
from salt.loader import minion_mods
|
|
||||||
|
|
||||||
# Import Third Party Libs
|
# Import Third Party Libs
|
||||||
from salt.ext.six.moves import range
|
from salt.ext.six.moves import range
|
||||||
@ -36,7 +36,11 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
__virtualname__ = 'mac_utils'
|
__virtualname__ = 'mac_utils'
|
||||||
|
|
||||||
__salt__ = None
|
__salt__ = {
|
||||||
|
'cmd.run_all': salt.modules.cmdmod._run_all_quiet,
|
||||||
|
'cmd.run': salt.modules.cmdmod._run_quiet,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __virtual__():
|
def __virtual__():
|
||||||
@ -46,9 +50,6 @@ def __virtual__():
|
|||||||
if not salt.utils.platform.is_darwin():
|
if not salt.utils.platform.is_darwin():
|
||||||
return (False, 'The mac_utils utility could not be loaded: '
|
return (False, 'The mac_utils utility could not be loaded: '
|
||||||
'utility only works on MacOS systems.')
|
'utility only works on MacOS systems.')
|
||||||
global __salt__
|
|
||||||
if not __salt__:
|
|
||||||
__salt__ = minion_mods(__opts__)
|
|
||||||
|
|
||||||
return __virtualname__
|
return __virtualname__
|
||||||
|
|
||||||
@ -272,6 +273,7 @@ def launchctl(sub_cmd, *args, **kwargs):
|
|||||||
|
|
||||||
# Run command
|
# Run command
|
||||||
kwargs['python_shell'] = False
|
kwargs['python_shell'] = False
|
||||||
|
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||||
ret = __salt__['cmd.run_all'](cmd, **kwargs)
|
ret = __salt__['cmd.run_all'](cmd, **kwargs)
|
||||||
|
|
||||||
# Raise an error or return successful result
|
# Raise an error or return successful result
|
||||||
@ -326,7 +328,8 @@ def _available_services():
|
|||||||
# the system provided plutil program to do the conversion
|
# the system provided plutil program to do the conversion
|
||||||
cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'.format(
|
cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'.format(
|
||||||
true_path)
|
true_path)
|
||||||
plist_xml = __salt__['cmd.run'](cmd, output_loglevel='quiet')
|
|
||||||
|
plist_xml = __salt__['cmd.run'](cmd)
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
plist = plistlib.readPlistFromString(plist_xml)
|
plist = plistlib.readPlistFromString(plist_xml)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user