Open ix-dev opened 5 years ago
+1. This happens for every Apply Rule (just found out using Apply Rules for HostGroups).
I am traying to implement something like: "Any IP in Subnet 10.171.252.0/24 where the fourth IP is higher than 127". The most flexible way is to convert host.address into an array of numbers and work with the required octects.
As you can see, Director renders the first 3 numbers as String, where the fourth is rendered as a Number. Because of this, this filter simply does not match.
object HostGroup "test2" {
display_name = "Collection x notifiche Data Center"
assign where host.vars.address_octects[0] == "10" && host.vars.address_octects[1] == "171" && host.vars.address_octects[2] == "252" && host.vars.address_octects[3] > 127
}
I believe is related to the operator, because if I change the operator from = to > or < Rendering works fine. Please fix it, because it is very annoying.
Director version: 1.8.1
Bug still present in the current version v1.10.2.
Expected Behavior
We noticed some strange behavior when we define custom Data Fields and try to match them in a Notification Apply Rule.
We tried to define a Data Field of type "Number" and configure this Data Field as Custom Variable of a Service Object. We also configured a Notification Apply Rule (applied to Services) that used an equality check to test for a specific value of this variable.
We expect that we can use numeric test conditions (equality in the original case) in the "assign where" clause.
Current Behavior
The Notification Apply Rule does not apply, because the "assign where" condition tests for string-equality, the generated condition is
although
test_number
is defined as "Number".There seem to be a lot of corner cases that I will try to summarize below.
Possible Solution
Steps to Reproduce (for bugs)
Please see the screenshot on the configuration of the Data Fields and the Notification Apply Rule.
Then we add the Data Fields to a Service Template and have a service object that imports the template.
Now there are several problems when you configure the custom variables on the service:
test_number
to2
, then the rule applies as expectedtest_number
to1
, then the rule does not apply, i.e., integer1
!= string"1"
test_number
to"1"
, then it complains:'"1"'
does not appear to be an integertest_string
to2
, then it seems to work (probably2
is implicitly cast to string"2"
, not sure if this is intended)test_string
to"2"
or ..test_string
to3
, then the config deployment fails with:Your Environment
icinga2 --version
): v2.10.3-294-g36fe6be