Add command 'reclass-vcp-list'
Shows all VM names that will be used for VCP
in the parameters.salt.control.cluster object on all nodes
diff --git a/reclass_tools/reclass_models.py b/reclass_tools/reclass_models.py
index 20874d6..9f90fa7 100644
--- a/reclass_tools/reclass_models.py
+++ b/reclass_tools/reclass_models.py
@@ -2,6 +2,8 @@
from reclass.adapters import salt as reclass_salt
from reclass import config as reclass_config
from reclass import core as reclass_core
+
+from reclass_tools import helpers
#import salt.cli.call
#import salt.cli.caller
@@ -35,9 +37,28 @@
def inventory_list(domain=None):
core = get_core()
- inventory = core.inventory()
- nodes_list = inventory['nodes'].keys()
+ inventory = core.inventory()['nodes']
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)))
+ inventory = {key:val for (key, val) in inventory.items() if key.endswith(domain)}
+ return inventory
+
+
+def vcp_list(domain=None):
+ """List VCP node names
+
+ Scan all nodes for the object salt.control.cluster.internal.node.XXX.name
+ """
+
+ inventory = inventory_list(domain=domain)
+ vcp_path = 'parameters.salt.control.cluster.internal.node'.split('.')
+
+ vcp_node_names = set()
+
+ for node_name, node in inventory.items():
+ vcp_nodes = helpers.get_nested_key(node, path=vcp_path)
+ if vcp_nodes is not None:
+ for vcp_node_name, vcp_node in vcp_nodes.items():
+ vcp_node_names.add(vcp_node['name'])
+ return vcp_node_names
+
+