mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add __salt__ to mac_utils and __utils__ in mac_service
This commit is contained in:
parent
fb3bf1ff3e
commit
a78652515a
2 changed files with 11 additions and 7 deletions
|
@ -14,7 +14,6 @@ import salt.utils.files
|
|||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
import salt.utils.stringutils
|
||||
import salt.utils.mac_utils
|
||||
from salt.exceptions import CommandExecutionError
|
||||
from salt.utils.versions import LooseVersion as _LooseVersion
|
||||
|
||||
|
@ -62,7 +61,7 @@ def _get_service(name):
|
|||
:return: The service information for the service, otherwise an Error
|
||||
:rtype: dict
|
||||
'''
|
||||
services = salt.utils.mac_utils.available_services()
|
||||
services = __utils__['mac_utils.available_services']()
|
||||
name = name.lower()
|
||||
|
||||
if name in services:
|
||||
|
@ -127,7 +126,7 @@ def launchctl(sub_cmd, *args, **kwargs):
|
|||
|
||||
salt '*' service.launchctl debug org.cups.cupsd
|
||||
'''
|
||||
return salt.utils.mac_utils.launchctl(sub_cmd, *args, **kwargs)
|
||||
return __utils__['mac_utils.launchctl'](sub_cmd, *args, **kwargs)
|
||||
|
||||
|
||||
def list_(name=None, runas=None):
|
||||
|
@ -454,7 +453,7 @@ def get_all(runas=None):
|
|||
enabled = get_enabled(runas=runas)
|
||||
|
||||
# Get list of all services
|
||||
available = list(salt.utils.mac_utils.available_services().keys())
|
||||
available = list(__utils__['mac_utils.available_services']().keys())
|
||||
|
||||
# Return composite list
|
||||
return sorted(set(enabled + available))
|
||||
|
|
|
@ -13,7 +13,6 @@ import plistlib
|
|||
import time
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.modules.cmdmod
|
||||
import salt.utils.args
|
||||
import salt.utils.decorators as decorators
|
||||
import salt.utils.files
|
||||
|
@ -24,6 +23,7 @@ import salt.utils.timed_subprocess
|
|||
import salt.grains.extra
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError,\
|
||||
TimedProcTimeoutError
|
||||
from salt.loader import minion_mods
|
||||
|
||||
# Import Third Party Libs
|
||||
from salt.ext.six.moves import range
|
||||
|
@ -36,6 +36,8 @@ log = logging.getLogger(__name__)
|
|||
|
||||
__virtualname__ = 'mac_utils'
|
||||
|
||||
__salt__ = None
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -44,6 +46,9 @@ def __virtual__():
|
|||
if not salt.utils.platform.is_darwin():
|
||||
return (False, 'The mac_utils utility could not be loaded: '
|
||||
'utility only works on MacOS systems.')
|
||||
global __salt__
|
||||
if not __salt__:
|
||||
__salt__ = minion_mods(__opts__)
|
||||
|
||||
return __virtualname__
|
||||
|
||||
|
@ -267,7 +272,7 @@ def launchctl(sub_cmd, *args, **kwargs):
|
|||
|
||||
# Run command
|
||||
kwargs['python_shell'] = False
|
||||
ret = salt.modules.cmdmod.run_all(cmd, **kwargs)
|
||||
ret = __salt__['cmd.run_all'](cmd, **kwargs)
|
||||
|
||||
# Raise an error or return successful result
|
||||
if ret['retcode']:
|
||||
|
@ -321,7 +326,7 @@ def _available_services():
|
|||
# the system provided plutil program to do the conversion
|
||||
cmd = '/usr/bin/plutil -convert xml1 -o - -- "{0}"'.format(
|
||||
true_path)
|
||||
plist_xml = salt.modules.cmdmod.run(cmd, output_loglevel='quiet')
|
||||
plist_xml = __salt__['cmd.run'](cmd, output_loglevel='quiet')
|
||||
if six.PY2:
|
||||
plist = plistlib.readPlistFromString(plist_xml)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue