Hi!
When I create a new host via the API, the normal apply rules are executed.
However it seem apply for rules are not.
It does not matter if the host object is created by config file or api.
I'm testing with example from the documentation:
Host from file:
---------------
object Host "testhost-fromfile" {
import "generic-host"
display_name = "testhost-fromfile"
address = "8.8.8.8"
vars.interfaces["FastEthernet0-fromfile"] = {
iftraffic_community = "a"
}
vars.interfaces["FastEthernet1-fromfile"] = {
iftraffic_community = "a"
}
}
Apply rule is the default 'ping4'
Apply for rule:
-----------
apply Service "if-" for (interface_name => interface_config in
host.vars.interfaces) {
import "generic-service"
check_command = "hostalive"
display_name = "IF-" + interface_name
vars.iftraffic_interface = interface_name
}
Check the services:
-------------------------
# curl -H 'Accept: application/json' -k -s -u root:a
'https://localhost:5665/v1/objects/services?attrs=name' -X GET | python
-m json.tool | grep testhost-fromfile
"name": "testhost-fromfile!if-FastEthernet0-fromfile",
"name": "testhost-fromfile!ping4",
"name": "testhost-fromfile!if-FastEthernet1-fromfile",
Give it a new variable:
----------------------------
# curl -H 'Accept: application/json' -k -s -u root:a
'https://localhost:5665/v1/objects/hosts/testhost-fromfile' -X POST -d
'{ "attrs": { "vars.interfaces.Fastethernet2-fromapi" : {
"iftraffic_community" : "fromAPI" }} }' | python -m json.tool
{
"results": [
{
"code": 200.0,
"name": "testhost-fromfile",
"status": "Attributes updated.",
Check the services again:
-------------------------------
# curl -H 'Accept: application/json' -k -s -u root:a
'https://localhost:5665/v1/objects/services?attrs=name' -X GET | python
-m json.tool | grep testhost-fromfile
"name": "testhost-fromfile!if-FastEthernet0-fromfile",
"name": "testhost-fromfile!ping4",
"name": "testhost-fromfile!if-FastEthernet1-fromfile",
Thx! :)
Csaba
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users