-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildList.pm
More file actions
31 lines (28 loc) · 788 Bytes
/
BuildList.pm
File metadata and controls
31 lines (28 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package CFG2JSON::BuildList;
use strict;
use FindBin;
use lib $FindBin::Bin;
use File::Slurp;
sub new{
my ($class,$args) = @_;
my ($devlist,$sitelist)=_buildList($args->{rancidpath},$args->{custhash});
$args->{devlist}=$devlist;
$args->{sitelist}=$sitelist;
my $self = bless $args , $class;
}
sub _buildList{
my ($path,$custhash)=@_;
my ($devlist,$sitelist);
for(split("\n",`ls -1 $path`)){
my $site=$_;
my $cust='default';
$cust=$custhash->{$site} if $custhash->{$site};
push(@{$sitelist->{$cust}},{sitename=>$site,rancidpath=>$path});
for(split("\n",`cat $path/$_/router.db`)){
my $hn=lc($1) if $_=~/(.*?);.*/i;
push(@{$devlist->{$cust}},{sitename=>$site,rancidpath=>$path,hostname=>$hn})
}
}
return ($devlist,$sitelist);
}
1;