Import salt.log at saltapi package level. Missed one salt.log.logging. Fixes #115.

This commit is contained in:
Pedro Algarvio 2013-09-13 10:27:57 +01:00
parent 5a30e80843
commit 7fc6ba4589
4 changed files with 18 additions and 23 deletions

View File

@ -5,6 +5,7 @@ Make api awesomeness
import inspect
# Import Salt libs
import salt.log # pylint: disable=W0611
import salt.client
import salt.runner
import salt.wheel
@ -27,30 +28,30 @@ class APIClient(object):
'''
Execute the specified function in the specified client by passing the
lowstate
New backwards compatible client and fun naming scheme.
In new scheme low['client'] is the client mode either 'sync' or 'async'.
New backwards compatible client and fun naming scheme.
In new scheme low['client'] is the client mode either 'sync' or 'async'.
Default is 'async'
If 'wheel' or 'runner' prefixes fun then use associated salt client given
by prefix in the specified 'sync' or 'async' mode.
by prefix in the specified 'sync' or 'async' mode.
Otherwise use local salt client in the given 'sync' or 'async' mode
'''
if not 'client' in low:
low['client'] = 'async'
#raise SaltException('No client specified')
# check for wheel or runner prefix to fun name
funparts = low.get('fun', '').split('.')
funparts = low.get('fun', '').split('.')
if len(funparts) > 2 and funparts[0] in ['wheel', 'runner']:
if low['client'] not in ['sync', 'async']: #client should be only 'sync' or 'async'
raise SaltException('With fun of "{1}", client must be "sync" or "async" not "{0}".'\
.format(low['client'], low['fun']))
low['client'] = '{0}_{1}'.format(funparts[0], low['client'])
low['fun'] = '.'.join(funparts[1:]) #strip prefix
if not ('token' in low or 'eauth' in low):
raise EauthAuthenticationError(
'No authentication credentials given')
@ -71,7 +72,7 @@ class APIClient(object):
'''
local = salt.client.LocalClient(self.opts['conf_file'])
return local.run_job(*args, **kwargs)
async = local_async # default async client
def local_sync(self, *args, **kwargs):
@ -82,7 +83,7 @@ class APIClient(object):
'''
local = salt.client.LocalClient(self.opts['conf_file'])
return local.cmd(*args, **kwargs)
local = local_sync # backwards compatible alias
sync = local_sync # default sync client
@ -92,7 +93,7 @@ class APIClient(object):
'''
runner = salt.runner.RunnerClient(self.opts)
return runner.low(fun, kwargs)
runner = runner_sync #backwards compatible alias
runner_async = runner_sync # until we get an runner_async
@ -103,6 +104,6 @@ class APIClient(object):
kwargs['fun'] = fun
wheel = salt.wheel.Wheel(self.opts)
return wheel.master_call(**kwargs)
wheel = wheel_sync # backwards compatible alias
wheel_async = wheel_sync # so it works either mode
wheel_async = wheel_sync # so it works either mode

View File

@ -2,15 +2,13 @@
The main entry point for salt-api
'''
# Import python libs
import logging
import multiprocessing
# Import salt libs
import salt.log
# Import salt-api libs
import saltapi.loader
logger = salt.log.logging.getLogger(__name__)
logger = logging.getLogger(__name__)
class SaltAPIClient(object):
'''

View File

@ -22,9 +22,6 @@ try:
except ImportError as exc:
cpy_error = exc
# Import Salt libs
import salt.log
logger = logging.getLogger(__name__)
cpy_min = '3.2.2'

View File

@ -169,7 +169,6 @@ import yaml
# Import Salt libs
import salt
import salt.auth
import salt.log
# Import salt-api libs
import saltapi