Question #10450
closedUse node inventory data in directives? With substring syntax?
Description
After a bit of searching I found http://www.rudder-project.org/redmine/issues/3112 which seems to be the feature I was looking for but I was a bit confused as I saw that it might have been previously implemented then removed in favor of doing something similar for techniques first. So I am wondering if there is a proposed timeline to bring it back.
Also would it be possible to design a syntax to do a sub-string of the returned data? Something like:
For the variable ${rudder.node.Hardware.BIOS.Name} (containing "VMware Virtual Platform")
using the syntax (:<delimiter>:<start position>:<end position>)
${rudder.node.Hardware.BIOS.Name:" ":0:1 would produce "VMware Virtual"
${rudder.node.Hardware.BIOS.Name:" ":1:2 would produce "Virtual Platform"
Another example:
${rudder.node.Environment.Name[BASEDIR] (containing the value "/opt/rudder/share/commands")
${rudder.node.Environment.Name[BASEDIR]:"/":3:4 would produce "share/commands"
${rudder.node.Environment.Name[BASEDIR]:"/":3:3 would produce "share"
${rudder.node.Environment.Name[BASEDIR]:"/":e:e would produce "commands" (using the character "e" to always represent the end element)
And lastly:
${rudder.node.Hardware.Controllers.Name2 (Containing "53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI")
${rudder.node.Hardware.Controllers.Name2:" ":2:e would produce "Fusion-MPT Dual Ultra320 SCSI"
${rudder.node.Hardware.Controllers.Name2:"-":0:0 would produce "53c1030 PCI"
Updated by Hamlyn Mootoo over 7 years ago
In the last example what showed up as superscripts should have been "[2]" so:
${rudder.node.Hardware.Controllers.Name\[2\] (Containing "53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI")
${rudder.node.Hardware.Controllers.Name\[2\]:" ":2:e would produce "Fusion-MPT Dual Ultra320 SCSI"
${rudder.node.Hardware.Controllers.Name\[2\]:"-":0:0 would produce "53c1030 PCI"
Updated by Benoît PECCATTE over 7 years ago
- Status changed from New to Discussion
It seems that you have found the right syntax to do it.
Do you have any question about it ?
Updated by Hamlyn Mootoo over 7 years ago
This does not currently exist, I was just proposing a syntax to be used. Do you know when using variables from node inventory in directives will be implemented?
Updated by François ARMAND over 7 years ago
- Related to User story #3112: Allow to get informations from the node inventory to use them in Directives and ncf techniques added
Updated by François ARMAND over 7 years ago
Sorry for the answer delay, I missed your ticket.
So you correctly found that that feature is not yet available, and that the need is reported in #3112.
Currently, we don't have a timeline for the feature, but thanks for the proposal. That let me think to the following problem: for now, inventory are NOT SORTED. So it is possible that from an inventory to the next, or even between to view of the same inventory, elements such as Controllers are not reported in the same order (it is in fact rather stable, but totally by accident and implementation details of underlying db storage that comes without any contract). It must be change to make the access to inventory items (as you proposed) at least a little interesting.
(for all items, we do have a key, which could be use to enforce stability if the user get a chance to know what the key is).
As for the proposal, your proposition seems nice at first sight, I need to take (much) more time to see what are the edge cases and how to manage them. The main problem I'm seing for now is that it is not a common idiom and may seem strange to new comers - but overall, JSON-xpath-sort-of query language are bad or difficult to understand, so that may not be a problem.
FYI, we are using in the "datasources" plugin that DSL: https://github.com/json-path/JsonPath
And for the command line, I like "jq" (https://stedolan.github.io/jq/manual/), but the learning curve is just a no-go for rudder.
Updated by François ARMAND over 7 years ago
About the timeline: of course, the more people interested, the more likely we are going to work on it. (it is hight in our "must wanted" feature).
Updated by Benoît PECCATTE about 6 years ago
Closing as answered, please see #3112 for a followup, or reopen if this is not sufficient.
Updated by Benoît PECCATTE about 6 years ago
- Status changed from Discussion to Resolved