Use more native key syntax for trace-key
Before: mandatory 'parameters', dot-separated key:
$ reclass-tools trace-key parameters.linux.network.interface
Now: optional 'parameters', dot or semicolon-separated key
Salt pillar paths may be used now without changes:
$ salt-call pillar.get linux:network:interface
$ reclass-tools trace-key linux:network:interface --node=...
Change-Id: Ib480952a57eb2b03d0df3636b6445595ef172d81
diff --git a/README.md b/README.md
index 27e240f..5e83d9c 100644
--- a/README.md
+++ b/README.md
@@ -49,9 +49,9 @@
reclass-tools list-params /srv/salt/reclass/classes/
```
-Trace all the modifications of the key parameters._param.keepalived_vip_interface during loading the model:
+Trace all the modifications of the pillar key _param:keepalived_vip_interface during loading the model:
```
-reclass-tools trace-key parameters._param.keepalived_vip_interface --node=ctl01.virtual-mcp-ocata-cicd.local
+reclass-tools trace-key _param:keepalived_vip_interface --node=ctl01.virtual-mcp-ocata-cicd.local
```
Requirements
diff --git a/reclass_tools/reclass_models.py b/reclass_tools/reclass_models.py
index 265c37a..3a4af38 100644
--- a/reclass_tools/reclass_models.py
+++ b/reclass_tools/reclass_models.py
@@ -43,12 +43,17 @@
def __init__(self, storage, class_mappings, input_data=None,
key=None):
if key:
- self.track_key_path = key.split('.')
- if 'parameters' not in self.track_key_path:
- raise Exception("Please use the key path starting from 'parameters'.")
- # Remove the first 'parameters' element because the model entities
- # keep parameters in different object format.
- self.track_key_path = self.track_key_path[1:]
+ if ':' in key:
+ # Linux pillar notation: linux:network:interface
+ self.track_key_path = key.split(':')
+ else:
+ # Python notation: linux.network.interface
+ self.track_key_path = key.split('.')
+
+ if self.track_key_path[0] == 'parameters':
+ # Remove the first 'parameters' element because the model entities
+ # keep parameters in different object format.
+ self.track_key_path = self.track_key_path[1:]
super(ReclassCore, self).__init__(storage, class_mappings, input_data)