Page MenuHomeDevCentral

D1176.id.diff
No OneTemporary

D1176.id.diff

diff --git a/_modules/node.py b/_modules/node.py
--- a/_modules/node.py
+++ b/_modules/node.py
@@ -10,25 +10,47 @@
# -------------------------------------------------------------
+from salt.exceptions import CommandExecutionError, SaltCloudConfigError
+
+
def _get_all_nodes():
return __pillar__.get('nodes', {})
-def get(nodename=None):
+def get_all_properties(nodename=None):
'''
A function to get a node pillar configuration.
CLI Example:
- salt * node.get
+ salt * node.get_all_properties
'''
if nodename is None:
nodename = __grains__['id']
all_nodes = _get_all_nodes()
+
+ if nodename not in all_nodes:
+ raise CommandExecutionError(
+ SaltCloudConfigError(
+ "Node {0} not declared in pillar.".format(nodename)
+ )
+ )
+
return all_nodes[nodename]
+def get(key, nodename=None):
+ '''
+ A function to get a node pillar configuration key.
+
+ CLI Example:
+
+ salt * node.get hostname
+ '''
+ return _get_property(key, nodename, None)
+
+
def _explode_key(k): return k.split(':')
@@ -40,7 +62,7 @@
def _get_property(key, nodename, default_value, parent=None):
if parent is None:
- parent = get(nodename)
+ parent = get_all_properties(nodename)
if ':' in key:
first_key = _get_first_key(key)
diff --git a/roles/core/network/init.sls b/roles/core/network/init.sls
--- a/roles/core/network/init.sls
+++ b/roles/core/network/init.sls
@@ -8,7 +8,7 @@
{% from "map.jinja" import dirs with context %}
-{% set network = salt['node.get']()['network'] %}
+{% set network = salt['node.get']('network') %}
# -------------------------------------------------------------
# IPv4

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 14:31 (4 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260381
Default Alt Text
D1176.id.diff (1 KB)

Event Timeline