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.

76 lines
1.3KB

  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. from architect_client.libarchitect import ArchitectClient
  9. import logging
  10. __virtualname__ = 'architect'
  11. logger = logging.getLogger(__name__)
  12. def __virtual__():
  13. return __virtualname__
  14. def _client():
  15. return ArchitectClient()
  16. def get_inventory():
  17. '''
  18. Get the Architect metadata inventory for given Salt master.
  19. CLI Examples:
  20. .. code-block:: bash
  21. salt-call architect.get_inventory
  22. '''
  23. data = yaml.load(_client().get_data())
  24. return data
  25. def get_node(name):
  26. '''
  27. Get the Architect node metadata for given Salt master.
  28. CLI Examples:
  29. .. code-block:: bash
  30. salt-call architect.get_node node.domain
  31. '''
  32. data = yaml.load(_client().get_data(name))
  33. return {
  34. name: data
  35. }
  36. def collect_minion_info():
  37. '''
  38. Get Salt minion metadata and forward it to the Architect master.
  39. CLI Examples:
  40. .. code-block:: bash
  41. salt-call architect.collect_minion_info
  42. '''
  43. data = {
  44. 'pillar': __salt__['pillar.data'](),
  45. 'grain': __salt__['grains.items'](),
  46. 'lowstate': __salt__['state.show_lowstate'](),
  47. }
  48. output = _client().push_salt_minion({data['grain']['id']: data})
  49. return output