Added function to check if ip already exists and updated addHost to use it #1248

Merged
merged 3 commits into from Jun 13, 2015

Projects

None yet

2 participants

@laf
Member
laf commented Jun 11, 2015

Ok, this is to finish off all the auto-discover devices that might just use IP.

When addHost is called, if it's an IP that's passed then it's checked against the ip_exists() function, if that returns true then either something has gone wrong or the IP does exist in the DB and the addHost function will not continue.

This means adding a device by hostname will continue to work as normal just in case people have an odd requirement to point multiple names at the same device.

laf added some commits Jun 11, 2015
@laf laf Added function to check if ip already exists and updated addHost to u…
…se it
fadc790
@laf laf Added fallback to false if it is not an IP
15cd6d5
@laf laf added the Discovery label Jun 11, 2015
@paulgear
Member

I have two questions:

  1. Should some of those messages actually be in the event log so that people can see them if they're happening in autodiscover?
  2. What's the rationale for $return = true/false rather than just using "return false" in the right places?
@laf
Member
laf commented Jun 12, 2015
  1. None of the other code within that does at the moment so that's just following on from what we do now - however: #1250

  2. That's just a matter of personal choice, if we're setting a standard in place for it then let me know and I'll update the code.

@paulgear
Member

Probably a good idea to have a think about #1250 separately - if we went overboard, people would probably complain about the spam. :-)

I don't think we could really make a standard other than making things as simple as they can be - in this case I think it detracts a little from the clarity of the code, but not really a big deal either way.

@laf laf Changed to return during function processing
e478a49
@laf
Member
laf commented Jun 12, 2015
  1. You asked the question about logging that info, I've just followed the rest of addHost and printed to the browser. Feel free to comment on the issue to use eventlog in addHost on how you want it to work so someone can put it togther.

  2. I've updated the code to just return mid flow now.

@paulgear paulgear merged commit 0e3b0df into librenms:master Jun 13, 2015

2 checks passed

Auto-Deploy Build finished.
Details
Scrutinizer No new issues
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment