Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

unable to delete service via RestAPI #1933

Open nilesingalls opened 5 years ago

nilesingalls commented 5 years ago

Expected Behavior

attempting to delete a service I created via RestAPI/POST with RestAPI/DELETE without success. using the suggested director-curl script as provided by the 70-REST-API.md documentation

./director-curl DELETE /director/service?name=service_utm_fortigate_7030_interfaces

(doesn't work)

./director-curl DELETE /director/service?name=service_utm_fortigate_7030_interfaces&host=localhost

(also doesn't work)

Using CLI does work

icingacli director service delete 'service_utm_fortigate_7030_interfaces' --host 'localhost' Service 'service_utm_fortigate_7030_interfaces' has been deleted

Current Behavior

./icingacli director service delete 'service_utm_vdom_vdom-memory' { "error": "Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = 'service_utm_vdom_vdom-memory' AND object_type = 'template'" }

Adding object_type='object' and/or host='{hostname}' does not change the behavior.

object_type appears to default to template, I seem to be unable to pass in my desired object_type with the request.

Possible Solution

more of a work around, but I can delete the service so long as I know the service_id. If the API endpoint for director/services provided the service_id (current outputs groups, host, imports, object_name, object_type), I can successfully delete via DELETE director/service?id={id}

I see that the recently added director/serviceapplyrules API endpoint was created to address a similar issue by returning the service_id.

Steps to Reproduce (for bugs)

./director-curl POST director/service '{"object_name": "test_service", "object_type": "object", "host": "localhost" }'

./director-curl DELETE director/service?name=test_service (response: "error": "Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = 'test_service' AND object_type = 'template'")

trying again with host defined

./director-curl DELETE director/service?name=test_service&host=localhost (response: "error": "Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = 'test_service' AND object_type = 'template'")

trying again with with service_id, which I can't seem to obtain via the API.

./director-curl DELETE director/service?id=833 (response: HTTP/1.1 200 OK ( { "host": "localhost", "object_name": "test_service", "object_type": "object" } )

Obviously, I can delete any service regardless of name/host/object_type, so long as I know the ID. Please advise with any solutions using solely the RestAPI, Thank You.

Your Environment

Moep90 commented 4 years ago

@nilesingalls pls use code tags so its more easy to help you.