use --domain to filter the output from reclass-inventory-list
diff --git a/reclass_tools/cli.py b/reclass_tools/cli.py
index d6aa10c..8b4ebe7 100644
--- a/reclass_tools/cli.py
+++ b/reclass_tools/cli.py
@@ -100,12 +100,10 @@
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
description="")
- parser.add_argument('--all', dest='all_nodes', action='store_const', const=True,
- help=('Show all the nodes available for reclass. '
- 'By default, show nodes only for the same domain '
- 'as used for the current minion'),
- default=False)
+ parser.add_argument('--domain', '-d', dest='domain',
+ help=('Show only the nodes which names are ended with the specified domain, for example:'
+ ' reclass-inventory-list -d example.local'))
params = parser.parse_args(args)
- reclass_models.inventory_list(all_nodes=params.all_nodes)
+ reclass_models.inventory_list(domain=params.domain)
diff --git a/reclass_tools/reclass_models.py b/reclass_tools/reclass_models.py
index 1bc83de..20874d6 100644
--- a/reclass_tools/reclass_models.py
+++ b/reclass_tools/reclass_models.py
@@ -2,8 +2,8 @@
from reclass.adapters import salt as reclass_salt
from reclass import config as reclass_config
from reclass import core as reclass_core
-import salt.cli.call
-import salt.cli.caller
+#import salt.cli.call
+#import salt.cli.caller
def get_core():
@@ -21,23 +21,23 @@
return reclass_core.Core(storage, None, None)
-def get_minion_domain():
- """Try to get domain from the local salt minion"""
- client = salt.cli.call.SaltCall()
- client.parse_args(args=['pillar.items'])
- caller = salt.cli.caller.Caller.factory(client.config)
- result = caller.call()
- # Warning! There is a model-related parameter
- # TODO: move the path to the parameter to a settings/defaults
- domain = result['return']['_param']['cluster_domain']
- return domain
+#def get_minion_domain():
+# """Try to get domain from the local salt minion"""
+# client = salt.cli.call.SaltCall()
+# client.parse_args(args=['pillar.items'])
+# caller = salt.cli.caller.Caller.factory(client.config)
+# result = caller.call()
+# # Warning! There is a model-related parameter
+# # TODO: move the path to the parameter to a settings/defaults
+# domain = result['return']['_param']['cluster_domain']
+# return domain
-def inventory_list(all_nodes=False):
+def inventory_list(domain=None):
core = get_core()
inventory = core.inventory()
nodes_list = inventory['nodes'].keys()
- if not all_nodes:
- domain = get_minion_domain()
- nodes_list = [node for node in nodes_list if domain in node]
+ if domain is not None:
+ #domain = get_minion_domain()
+ nodes_list = [node for node in nodes_list if node.endswith(domain)]
print('\n'.join(sorted(nodes_list)))