Advertisement
Guest User

Untitled

a guest
Jun 13th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. ext_pillar:
  2. - cobbler:
  3. # - key: None
  4. # - only: mgmt_classes
  5.  
  6. #cobbler.url: http://127.0.0.1/cobbler_api
  7. #cobbler.user: cobbler
  8. #cobbler.password: cobbler
  9.  
  10. ^^^^^^
  11. Setting ANY of the above appears to break the return from cobbler.
  12. Including setting only which also breaks the if key at the bottom of cobbler.py
  13. ---------------------------------------
  14.  
  15.  
  16.  
  17. # Import python libs
  18. import logging
  19. import xmlrpclib
  20.  
  21.  
  22. __opts__ = {'cobbler.url': 'http://localhost/cobbler_api',
  23. 'cobbler.user': None,
  24. 'cobbler.password': None
  25. }
  26.  
  27.  
  28. # Set up logging
  29. log = logging.getLogger(__name__)
  30.  
  31.  
  32. def ext_pillar(pillar, key=None, only=()):
  33. '''
  34. Read pillar data from Cobbler via its API.
  35. '''
  36. url = __opts__['cobbler.url']
  37. user = __opts__['cobbler.user']
  38. password = __opts__['cobbler.password']
  39.  
  40. minion_id = __opts__['id']
  41. log.info("Querying cobbler at %r for information for %r", url, minion_id)
  42. try:
  43. server = xmlrpclib.Server(url, allow_none=True)
  44. #####################################################################
  45. # #
  46. # ANY ATTEMPT AS USING AUTH BREAKS THE server = xmlrpc LINE BELOW #
  47. # VERIFIED CORRECT CREDENTIALS BY USING PERL COBBLER API CALL #
  48. # #
  49. #####################################################################
  50. if user:
  51. server = xmlrpclib.Server(server, server.login(user, password))
  52. result = server.get_blended_data(None, minion_id)
  53. except Exception:
  54. log.exception(
  55. 'Could not connect to cobbler.'
  56. )
  57. return {}
  58.  
  59. if only:
  60. result = dict((k, result[k]) for k in only if k in result)
  61.  
  62. if key:
  63. result = {key: result}
  64.  
  65. #####################################################################
  66. # #
  67. # ANY ATTEMPT AT USING only / key BREAKS THE ABOVE WITH KEY ERRORS #
  68. # ONLY WORKING WAY WAS TO USE THE FOLLOWING CODE MODUIFICATIONS #
  69. # #
  70. #####################################################################
  71.  
  72. data = result["mgmt_classes"]
  73. result = {'cobbler': data}
  74. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement