New Saltstack Salt formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 line
1.6KB

  1. # -*- coding: utf-8 -*-
  2. '''
  3. Salt modules to work with the Architect service.
  4. '''
  5. # Import python libs
  6. from __future__ import absolute_import
  7. import yaml
  8. import logging
  9. from architect_client.libarchitect import ArchitectClient
  10. __virtualname__ = 'architect'
  11. logger = logging.getLogger(__name__)
  12. def __virtual__():
  13. return __virtualname__
  14. def _client():
  15. return ArchitectClient()
  16. def inventory():
  17. '''
  18. Get the Architect metadata inventory
  19. CLI Examples:
  20. .. code-block:: bash
  21. salt-call architect.inventory
  22. '''
  23. data = yaml.load(_client().get_data())
  24. return data
  25. def node_pillar(name):
  26. '''
  27. Get the Architect node pillar for given Salt master.
  28. CLI Examples:
  29. .. code-block:: bash
  30. salt-call architect.node_pillar node.domain
  31. '''
  32. data = yaml.load(_client().get_data(name))
  33. return {
  34. name: data
  35. }
  36. def node_classify(name, data={}):
  37. '''
  38. CLassify node by given dictionary of parameters
  39. CLI Examples:
  40. .. code-block:: bash
  41. salt-call architect.node_classify minion.net {'param1': 'value2'}
  42. '''
  43. output = _client().classify_node({
  44. 'name': name,
  45. 'data': data
  46. })
  47. return output
  48. def node_info():
  49. '''
  50. Get Salt minion metadata and forward it to the Architect master.
  51. CLI Examples:
  52. .. code-block:: bash
  53. salt-call architect.minion_info
  54. '''
  55. data = {
  56. 'pillar': __salt__['pillar.data'](),
  57. 'grain': __salt__['grains.items'](),
  58. 'lowstate': __salt__['state.show_lowstate'](),
  59. }
  60. return data