Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3750983
D1176.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D1176.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 05:20 (21 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250279
Default Alt Text
D1176.diff (1 KB)
Attached To
Mode
D1176: Introduce node.get <setting>
Attached
Detach File
Event Timeline
Log In to Comment