diff --git a/Changes b/Changes index 0dc23e0e..f28a2ebb 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ * Icon to copy Navbar search text to Device Search Options field (closes #11) * Typeahead on the main navbar search (for devices only) + * Support for have_nodeip_dns_col setting (closes #14) [ENHANCEMENTS] diff --git a/Netdisco/lib/Netdisco/DB/Result/NodeIp.pm b/Netdisco/lib/Netdisco/DB/Result/NodeIp.pm index ec0f51db..cbf60cb7 100644 --- a/Netdisco/lib/Netdisco/DB/Result/NodeIp.pm +++ b/Netdisco/lib/Netdisco/DB/Result/NodeIp.pm @@ -47,13 +47,16 @@ Calling the C accessor will either return the content of that field if the field is configured and installed, or else perform a live DNS lookup on the IP field within the record (returning the first PTR, or undef). +To enable this feature, set the C environment variable to +a true value. In the Netdisco web app you can activate the column using the +C application setting, instead. + =cut -# XXX uncomment the following two lines if you have a "dns" column XXX -# XXX in your node_ip table which caches the host's name XXX -#__PACKAGE__->add_column("dns" => -# { data_type => "text", is_nullable => 1, accessor => undef }); -# XXX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XXX +if ($ENV{HAVE_NODEIP_DNS_COL}) { + __PACKAGE__->add_column("dns" => + { data_type => "text", is_nullable => 1, accessor => undef }); +} # some customize their node_ip table to have a dns column which # is the cached record at the time of discovery diff --git a/Netdisco/lib/Netdisco/Web.pm b/Netdisco/lib/Netdisco/Web.pm index a856250a..a4927f4d 100644 --- a/Netdisco/lib/Netdisco/Web.pm +++ b/Netdisco/lib/Netdisco/Web.pm @@ -2,7 +2,13 @@ package Netdisco::Web; use Dancer ':syntax'; use Dancer::Plugin::Ajax; -use Dancer::Plugin::DBIC; + +BEGIN { + if (setting('have_nodeip_dns_col')) { + $ENV{HAVE_NODEIP_DNS_COL} = 1; + } + use Dancer::Plugin::DBIC; +} use Socket6 (); # to ensure dependency is met use HTML::Entities (); # to ensure dependency is met