mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add initial not working next
This commit is contained in:
parent
18d1493d71
commit
07ad044ab9
1 changed files with 64 additions and 0 deletions
64
tests/wheeltest.py
Normal file
64
tests/wheeltest.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env python
|
||||
'''
|
||||
Test interacting with the wheel system. This script is useful when testing
|
||||
wheel modules
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
import optparse
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.config
|
||||
import salt.wheel
|
||||
import salt.auth
|
||||
|
||||
|
||||
def parse():
|
||||
'''
|
||||
Parse the command line options
|
||||
'''
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-f',
|
||||
'--fun',
|
||||
'--function',
|
||||
dest='fun',
|
||||
help='The wheel function to execute')
|
||||
parser.add_option('-auth',
|
||||
'-a',
|
||||
dest='eauth',
|
||||
help='The external authentication mechanism to use')
|
||||
|
||||
options, args = parser.parse_opts()
|
||||
|
||||
|
||||
|
||||
|
||||
class Wheeler(object):
|
||||
'''
|
||||
Set up communication with the wheel interface
|
||||
'''
|
||||
def __init__(self, cli):
|
||||
self.opts = salt.config.master_config('/etc/salt')
|
||||
self.wheel = salt.wheel.Wheel(self.opts)
|
||||
|
||||
def _eauth(self):
|
||||
'''
|
||||
Fill in the blanks for the eauth system
|
||||
'''
|
||||
if self.options.eauth:
|
||||
resolver = salt.auth.Resolver(self.config)
|
||||
res = resolver.cli(self.options.eauth)
|
||||
if self.options.mktoken and res:
|
||||
tok = resolver.token_cli(
|
||||
self.options.eauth,
|
||||
res
|
||||
)
|
||||
if tok:
|
||||
kwargs['token'] = tok.get('token', '')
|
||||
if not res:
|
||||
sys.exit(2)
|
||||
kwargs.update(res)
|
||||
kwargs['eauth'] = self.options.eauth
|
||||
|
||||
|
||||
print wheel.master_call('key.list_all', username='thatch', eauth='pam', password='idfsuhgsklfdn')
|
Loading…
Add table
Reference in a new issue