> On 29 Jan 2016, at 11:30, NAZSA Csaba <[email protected]> wrote:
>
> Hi!
>
>
> When I create a new host via the API, the normal apply rules are executed.
> However it seem apply for rules are not.
There is no real different in evaluating these expressions, both are when new
objects are created via PUT request.
> 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.”,
Apply and object rules are not evaluated on attribute change via POST. You
would have to iterate over all existing objects, delete/add objects, assign
group memberships and so on. That is an even bigger part than the object
dependencies for DELETE requests.
What works for now - DELETE and PUT again.
Kind regards,
Michael
>
> 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
--
Michael Friedrich, DI (FH)
Senior Developer
NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg
Tel: +49 911 92885-0 | Fax: +49 911 92885-77
CEO: Julian Hein, Bernd Erk | AG Nuernberg HRB18461
http://www.netways.de | [email protected]
** OSDC 2016 - April - netways.de/osdc **
** OSBConf 2016 - September - osbconf.org **
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users