source: genesis/nodes/ip2node.pl@ 6721

Last change on this file since 6721 was 5334, checked in by rick, 18 years ago

3 total different ways of making the ip -> nodename link

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:mime-type set to text/plain
File size: 1.9 KB
Line 
1#!/usr/bin/env perl
2
3#maak een mooi systeem met hash aanroepen om snel gegevens te verwerken
4sub parse_config {
5 foreach my $id (sort keys %config) {
6 my $rawData = $config{$id};
7 $rawData =~ s/#.*\n/\n/g; #wegslopen comments
8 $rawData =~ s/\s*[\r,\n]+\s*/:::/g; #spaties+enter+spaties vervangen door :::
9 $rawData =~ s/^::://; #::: aan het begin weghalen
10 $rawData =~ s/:::$//; #::: aan het eind weghalen
11 my @configArray = split( /:::/, $rawData); #array er van maken
12 foreach $line (@configArray) {
13 (my $name, my $value) = split( /\=/, $line);
14 $$name{$id} = $value;
15 };
16 };
17}; #end parse_config
18
19sub clean_ip {
20 local($ip,$name) = @_;
21 split('/',$ip);
22 print "@_[0]|$name\n";
23
24};
25
26 #ga alle config files doorwerken
27 foreach my $file (`ls -1`) {
28 chomp($file);
29 $file .= "/wleiden.conf";
30 if (not ($file =~ /^CNode/ or $file =~ /^proxy/)) {
31 }
32 else {
33 print STDERR "Working on $file...\n";
34 #clean up all old variablen
35 @$_ = [] foreach qw(static_dhcp);
36 $$_ = "" foreach qw(location master_ip gw_open nodetype nodename
37 OS status X Y N E OS DISK AGGREGATE);
38 %$_ = () foreach qw(config TYPE IP DESC SDESC SPEED DHCP DHCP_STATIC
39 OSPF_BROADCAST OSPF_NEIGHBORS MODE ESSID CHANNEL
40 POLAR ANTENNA GAIN DIRECTION BEAMWIDTH CABLE
41 HEIGHT ROUTE);
42 #end cleanup
43
44 #load config file
45 do($file) || die("Cann't open file");
46
47 #parse de config om hem snel en makkelijk te kunnen gebruiken
48 print STDERR "\t Parsing config...";
49 parse_config;
50 print STDERR "DONE\n";
51 clean_ip($master_ip,$nodename);
52 foreach $key (keys %IP) {
53 clean_ip($IP{$key},$nodename);
54 }
55 }
56
57}; #end main
58
59main;
60exit 0;
61
62
Note: See TracBrowser for help on using the repository browser.