Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ext_pillar:
- - cobbler:
- # - key: None
- # - only: mgmt_classes
- #cobbler.url: http://127.0.0.1/cobbler_api
- #cobbler.user: cobbler
- #cobbler.password: cobbler
- ^^^^^^
- Setting ANY of the above appears to break the return from cobbler.
- Including setting only which also breaks the if key at the bottom of cobbler.py
- ---------------------------------------
- # Import python libs
- import logging
- import xmlrpclib
- __opts__ = {'cobbler.url': 'http://localhost/cobbler_api',
- 'cobbler.user': None,
- 'cobbler.password': None
- }
- # Set up logging
- log = logging.getLogger(__name__)
- def ext_pillar(pillar, key=None, only=()):
- '''
- Read pillar data from Cobbler via its API.
- '''
- url = __opts__['cobbler.url']
- user = __opts__['cobbler.user']
- password = __opts__['cobbler.password']
- minion_id = __opts__['id']
- log.info("Querying cobbler at %r for information for %r", url, minion_id)
- try:
- server = xmlrpclib.Server(url, allow_none=True)
- #####################################################################
- # #
- # ANY ATTEMPT AS USING AUTH BREAKS THE server = xmlrpc LINE BELOW #
- # VERIFIED CORRECT CREDENTIALS BY USING PERL COBBLER API CALL #
- # #
- #####################################################################
- if user:
- server = xmlrpclib.Server(server, server.login(user, password))
- result = server.get_blended_data(None, minion_id)
- except Exception:
- log.exception(
- 'Could not connect to cobbler.'
- )
- return {}
- if only:
- result = dict((k, result[k]) for k in only if k in result)
- if key:
- result = {key: result}
- #####################################################################
- # #
- # ANY ATTEMPT AT USING only / key BREAKS THE ABOVE WITH KEY ERRORS #
- # ONLY WORKING WAY WAS TO USE THE FOLLOWING CODE MODUIFICATIONS #
- # #
- #####################################################################
- data = result["mgmt_classes"]
- result = {'cobbler': data}
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement