Skip to content

Commit

Permalink
Allow user to configure delimiter character for RANCID records
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Vicente committed May 16, 2016
1 parent c4e7590 commit d9d08a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions etc/Default.conf
Expand Up @@ -948,6 +948,10 @@ RANCID_TYPE_MAP => {
'netscreen' => 'netscreen',
},

# Newer versions of RANCID use semi-colon as the record delimiter.
# For backward compatibility, the colon is the default
RANCID_DELIM => ':',

#####################################################################
# - BIND - www.isc.org
#
Expand Down
7 changes: 6 additions & 1 deletion lib/Netdot/Exporter/Rancid.pm
Expand Up @@ -141,7 +141,12 @@ sub generate_configs {
foreach my $device ( sort keys %{$groups{$group}} ){
my $mfg = $groups{$group}{$device}{mfg} || next;
my $state = $groups{$group}{$device}{state} || next;
print $rancid $device, ":$mfg:$state\n";
my $delim = Netdot->config->get('RANCID_DELIM');
$self->throw_user(sprintf("Netdot::Exporter::Rancid::generate_configs: ".
"Invalid Rancid delimiter: '%s'", $delim))
unless ($delim eq ';' || $delim eq ':');
my $str = join($delim, ($device, $mfg, $state));
print $rancid "$str\n";
}
close($rancid) || $logger->warn("Netdot::Exporter::Rancid::generate_configs: ".
"$file_path did not close nicely");
Expand Down

0 comments on commit d9d08a6

Please sign in to comment.