Move Salt-internals to Salt's reclass adapters
The Salt reclass_adapter plugins now hide all the internals and provide
reclass only with the information it needs, without having to make
assumptions about Salt internals.
Signed-off-by: martin f. krafft <madduck@madduck.net>
diff --git a/TODO b/TODO
index 4fead5a..050608c 100644
--- a/TODO
+++ b/TODO
@@ -5,9 +5,6 @@
- Tests for outputters
- Improve testing of yaml_fs, maybe with more realistic examples
- Configurable file extension (.yaml/.yml, or support both)
-- Remove applications_hosts, or factor it out to the Ansible adapter, as it's
- not really relevant to Salt or reclass in general. And remove 'groups' from
- the inventory return.
- Improve the adapters, either by just letting them build their own
OptionParsers, or through setuptools entrypoints (probably best…). The
reclass API would need a bit of generalisation for that to happen…
diff --git a/adapters/salt.in b/adapters/salt.in
index 212368e..380ffe6 100644
--- a/adapters/salt.in
+++ b/adapters/salt.in
@@ -78,15 +78,14 @@
posix.EX_USAGE)
if not node:
- # we want master_tops behaviour
- # so we first hack:
- opts = {'master_tops': {'reclass': options}}
- data = top(salt={}, opts=opts, grains={})
+ reclass_opts = options.copy()
+ del reclass_opts['output']
+ del reclass_opts['pretty_print']
+ data = top(**reclass_opts)
else:
- opts={}; salt={}; grains={}; pillar={}
- data = ext_pillar(opts, salt, grains, pillar,
- options.get('storage_type'),
+ pillar={}
+ data = ext_pillar(node, pillar, options.get('storage_type'),
options.get('inventory_base_uri'),
options.get('nodes_uri'),
options.get('classes_uri'))
diff --git a/reclass/adapters/salt.py b/reclass/adapters/salt.py
index 7e0f306..c3edc25 100644
--- a/reclass/adapters/salt.py
+++ b/reclass/adapters/salt.py
@@ -35,15 +35,11 @@
return get_data(storage_type, nodes_uri, classes_uri, node)
-def ext_pillar(pillar, storage_type=None, inventory_base_uri=None,
+def ext_pillar(minion_id, pillar, storage_type=None, inventory_base_uri=None,
nodes_uri=None, classes_uri=None):
- node = opts.get('id')
- if node is None:
- raise InvocationError('no node ID provided')
-
data = _get_data(storage_type, inventory_base_uri, nodes_uri, classes_uri,
- node)
+ minion_id)
params = data.get('parameters', {})
params['__reclass__'] = {}
params['__reclass__']['applications'] = data['applications']
@@ -53,15 +49,8 @@
return params
-def top(salt, opts, grains):
- reclass_opts = opts.get('master_tops', {}).get('reclass')
- if reclass_opts is None:
- raise InvocationError('no configuration provided')
-
- storage_type = reclass_opts.get('storage_type')
- inventory_base_uri = reclass_opts.get('inventory_base_uri')
- nodes_uri = reclass_opts.get('nodes_uri')
- classes_uri = reclass_opts.get('classes_uri')
+def top(storage_type=None, inventory_base_uri=None, nodes_uri=None,
+ classes_uri=None):
data = _get_data(storage_type, inventory_base_uri, nodes_uri, classes_uri,
node=None)