Browse Source

Added Architect module and makefile rule for engines installation

Change-Id: I462f47d01bd8d2b249ff059a0efd0271929691f7
pull/73/head
Ales Komarek 6 years ago
parent
commit
ef0eea36b1
2 changed files with 75 additions and 0 deletions
  1. +1
    -0
      Makefile
  2. +74
    -0
      _modules/architect.py

+ 1
- 0
Makefile View File

@@ -40,6 +40,7 @@ install:
cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/
[ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/
[ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true
[ ! -d _engines ] || cp -a _engines $(DESTDIR)/$(SALTENVDIR)/ || true
[ ! -d _grains ] || cp -a _grains $(DESTDIR)/$(SALTENVDIR)/ || true
# Metadata
[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)

+ 74
- 0
_modules/architect.py View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
'''
Salt modules to work with the Architect service.
'''

# Import python libs
from __future__ import absolute_import
import yaml
from architect_client.libarchitect import ArchitectClient
import logging

__virtualname__ = 'architect'

logger = logging.getLogger(__name__)


def __virtual__():
return __virtualname__


def _client():
return ArchitectClient()


def get_inventory():
'''
Get the Architect metadata inventory for given Salt master.

CLI Examples:

.. code-block:: bash

salt-call architect.get_inventory
'''
data = yaml.load(_client().get_data())

return data


def get_node(name):
'''
Get the Architect node metadata for given Salt master.

CLI Examples:

.. code-block:: bash

salt-call architect.get_node node.domain
'''

data = yaml.load(_client().get_data(name))

return {
name: data
}


def collect_minion_info():
'''
Get Salt minion metadata and forward it to the Architect master.

CLI Examples:

.. code-block:: bash

salt-call architect.collect_minion_info
'''

data = {
'pillar': __salt__['pillar.data'](),
'grain': __salt__['grains.items'](),
}
output = _client().push_salt_minion({data['grain']['id']: data})
return output

Loading…
Cancel
Save