Open burnyd opened 1 year ago
@burnyd In the source plugin are you getting array data? Currently we don't support array in conditions. In the source plugin you should be able to morph the data the way you want to check in the rules.
@burnyd In the source plugin are you getting array data? Currently we don't support array in conditions. In the source plugin you should be able to morph the data the way you want to check in the rules.
Yes, I am getting a python dictionary for the data referenced within the issue. So the output pushed into the python async queue would look like this.
{"name":"sub1","timestamp":1670273612118710138,"tags":{"interface_name":"Ethernet1","source":"172.20.20.3","subscription-name":"sub1"},"values":{"/interfaces/interface/state/admin-status":"UP"}}
If I can understand what you are saying is I need to edit the source plugin so I am only returning the value of a string of "UP" and that the return value cannot be an array?
@burnyd I was thinking you would have multiple interfaces in that case you would have to use indexing e.g. interface[0], interface[1] that is currently not supported. In your example it looks like the key has embedded slashes and that might be throwing it off. I will look into it
Okay please let me know. Otherwise, It looks I have to replace strings with "/" or "-" with underscores.
@burnyd The identifiers used for keys needs to follow the rules for Ansible variable names and it can only contain letters, numbers, and underscores
I think in your case you would have to convert the / to underscore
When you say convert the / to underscore you are referring to the actual source EDA plugin? So have that use python string replace for "/" to "" and within the condition where I am keying use "" ? Just want to make sure I am clear on this.
You can use event filters for this: https://github.com/benthomasson/ci-cd-demo/blob/main/event_filters/dashes_to_underscores.py
See how to use them here: https://github.com/benthomasson/ci-cd-demo/blob/main/github-ci-cd-rules.yml
- name: azure_service_bus
ansible.eda.azure_service_bus:
conn_str: "{{connection_str}}"
queue_name: "{{queue_name}}"
filters:
- json_filter:
include_keys: ['clone_url']
exclude_keys: ['*_url', '_links', 'base', 'sender', 'owner', 'user']
- dashes_to_underscores:```
Version of ansible-rulebook
I am trying to develop a new EDA source plugin. I need to key off data coming from a pub/sub bus. Some sample data will look as the following
The very last portion is what I need to key off of the values key
The condition portion of the rule-book looks as follows.
Resulting in the following error.
I have tried dotted notation, brackets and also vars all within the same error message. Either I can key off of this value or if there is a way to be able to check to see if the word DOWN is within that array would work as well. But generally speaking it does not like slashes or dashes.