Page 1 of 1

delete host through api

Posted: Tue Nov 24, 2015 4:08 am
by sib
Hi

I can not delete a host through the new REST API (Nagios XI 5.2.1)

Code: Select all

# curl -k -XDELETE "https://lbnss22/nagiosxi/api/v1/config/host?apikey=key&host_name=lbnss01"
{
    "error": "Host cannot be deleted using this method. Must be deleted through the CCM."
}
Does not make sense to have to delete it in CCM as I want to automate it.

best
Chris

Re: delete host through api

Posted: Tue Nov 24, 2015 10:09 am
by lmiltchev
Chris, does the host have any services or any other dependencies (i.e. there are host dependencies, the host is added to a hostgroup, etc.)? Can you go to the CCM->Hosts, click on the "Relationship Info" button next to the host and show us the output?

Re: delete host through api

Posted: Wed Nov 25, 2015 3:20 am
by sib
Hi

There is dependencies to various hostgroups

Code: Select all

Items labeled as: 'Dependent relationships' will prohibit deletion
Object ID: 120 of table tbl_host:
Relation to Hostgroups, entry: devua
Relation to Hostgroups, entry: all
Relation to Hostgroups, entry: centrify
Relation to Hostgroups, entry: patching-G3-prod-zurich
Relation to Hostgroups, entry: rhel5
Relation to Hostgroups, entry: rhel6
Relation to Hostgroups, entry: physical_dev
Relation to Hostgroups, entry: bisnet
Relation to Hostgroups, entry: zurich
Relation to Hostgroups, entry: nomonitor
Relation to Hosttemplates, entry: BIS_dev_host
I was hoping that it can resolve the dependencies by just removing the host from each hostgroup. I can resolve them before trying to delete the host.
Still I think the error message is too generic. It should return more useful information such as there is dependencies and maybe even include them into the return message.

best
Chris

Re: delete host through api

Posted: Wed Nov 25, 2015 11:29 am
by lmiltchev
This is strange - I don't see 'Dependent relationship' in the output. See an example of a 'Dependent relationship' that will prohibit deletion (text in red):
example01.PNG
The deletion of your host should have worked. I will do some more digging into it. It is possible that this is a bug.