opinkerfi / adagios

Adagios - Web Based Nagios Configuration
GNU Affero General Public License v3.0
330 stars 75 forks source link

Config error on changing contact_name #268

Open hakong opened 10 years ago

hakong commented 10 years ago

Reproduced in 2 adagios installs with 2 contacts. Steps to reproduce: Configure > Contacts > select a contact > change Contact Name -> Save -> Reload -> Warning! Error: Could not find any contact matching 'new contact name' (config file '/etc/nagios/okconfig/contactgroups/host.com.cfg', starting on line 5)

hakong commented 10 years ago

Should this be closed, or is there anything to be done about this? Would be really nice if Adagios/Pynag would update attribute values that reference something that was just renamed, like... super nice :)

If I remember correctly, me and @palli discussed this and he didn't want to do anything about this because of reasons I don't remember

tomas-edwardsson commented 10 years ago

I'm quite sure this has to do with changing contact_name and updating all objects which refer to this contact object. Considering the following:

Pre-chage

define contact {
    use                 generic-contact
    contact_name        thedude 
}

define contactgroup {
    contactgroup_name   dudes
    alias               a group of dudes
    members             thedude    
}

Updating contact_name

define contact {
    use                 generic-contact
    contact_name        thefoo
}

define contactgroup {
    contactgroup_name   dudes
    alias               a group of dudes
    members             thedude    
}

Here the "clever" thing would be to find all references to the contact in all object types that support it and update, which is not how it is today.

So the question is in my mind, should "Configure" be this clever or not? If so for consistency all object types would have to be reviewed and work in the same manner.

@palli if you have any comments, that would be super.

palli commented 10 years ago

This is not trivial to implement because there are very many edge cases to consider.

This can be done after the underlying config changes required are implemented, there is already progress on this via pynag.Model.*.rename() methods which can facilitate for this.

However they are not all complete, i.e. host is done, but contact is not.

palli commented 10 years ago

Any takers on implementing rename() for all object types ?