Do not wait for Postgresql if principal is not a related Pg unit
Fixes: LP#1841120
Given a newly available/changed Postgresql unit, this function is
called to (re)configure telegraf to access it.
The function iterates through all available Postgresql units,
searching for this subordinate telegraph's prinicpal Postgresql
connection string.
Prior to this fix, if no Postgresql connection string is found, this
telegraf unit enters a waiting state for Postgresql. This function
never checks if this unit's principal is NOT a Postgresql unit.
This commit checks if this telegraf's prinicpal is in the expected and
related Postgresql units before searching for a Postgresql connection
string ("context") to render to a template -- and only then if the
Postgres connection string isn't found, does it wait on Postgresql.
Function needs to set the state indicating that nagios has been setup.
This flag will be cleared during a call to config-changed, just to be
sure that we pickup changes if needed, like port number.
In response to the code review of the previous MR the following changes
have been made:
1. Unittest for testing the nagios calls
2. Removed a non functional check
3. removed a hidden file
4. fixed a linting error