aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/config.local.pm100
-rw-r--r--include/config.pm25
-rw-r--r--include/nms.pm104
-rw-r--r--include/tgmanage.cfg.sh19
4 files changed, 248 insertions, 0 deletions
diff --git a/include/config.local.pm b/include/config.local.pm
new file mode 100644
index 0000000..8e0eeee
--- /dev/null
+++ b/include/config.local.pm
@@ -0,0 +1,100 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use DBI;
+package nms::config;
+
+# Don't change this file for your local setup; use config.local.pm instead.
+
+our $db_name = "nms";
+our $db_host = "flexus.tg13.gathering.org";
+our $db_username = "nms";
+our $db_password = "<removed>";
+
+our $dhcp_server1 = "151.216.126.2";
+our $dhcp_server2 = "151.216.125.17"; # Cisco ISE profiling
+
+our $ios_user = "nms";
+our $ios_pass = "<removed>";
+
+# Tech:Net sets up at least a read-community for SNMP for use
+# with dlink1g, nms and sosuch. This is the one:
+our $snmp_community = "<removed>";
+
+our $dlink1g_user = 'dlinkng';
+our $dlink1g_passwd = '<removed>';
+
+# No longer in use as of '12 ?
+# our $telegw_ip = "12.34.56.78";
+# our @telegw_wanlinks = ("gig1/1", "gig1/2");
+
+our $tgname = "tg13";
+
+our $pri_a = "winix";
+our $pri_ptr = "151.216.126.2";
+our $pri_v6 = "2a02:ed02:126::2";
+our $pri_net = "151.216.126.0/24";
+our $sec_a = "tress90";
+our $sec_ptr = "151.216.125.2";
+our $sec_v6 = "2a02:ed02:125::2";
+
+# for RIPE to get reverse zones via DNS AXFR
+our $ext_xfer = "193.0.0.0/22";
+our $ext_ns = "194.19.3.20";
+
+# To generate new dnssec-key for ddns:
+# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST DHCP_UPDATER
+our $ddns_key = "<removed>";
+our $ddns_to = "127.0.0.1";
+
+# Used by make-named.pl
+our $noc_nett = "151.216.124.0/24";
+our $noc_nett_v6 = "2a02:ed02:124::/64";
+
+# Ikke i bruk i '11 til revers-soner.
+# Ikke i bruk i '12 heller
+# På tide å fjerne dette i '13?
+# Ikke brukt i '13 heller
+# På tide å fjerne dette i '14????????? :-D :-P
+#our $root_arpa = "22.89.in-addr.arpa";
+#our $ipv6nett = "2001:8c0:9840::/48";
+
+our $base_ipv4net = "151.216.0.0";
+our $base_ipv4prefix = 17;
+
+our $base_ipv6net = "2a02:ed02:";
+our $base_ipv6prefix = 32;
+our $ipv6zone = "2.0.d.e.2.0.a.2.ip6.arpa";
+
+our $pxe_server = "151.216.125.3";
+our $ciscowlc_a = "151.216.127.15";
+
+
+# static_switches is supposed to be legacy, and should be safe to remove.
+#130, 144, 145, 196, 197, 198, 199, 200, 203, 201, 206, 208, 209, 211, 213,
+#our @static_switches = (
+# 130,144,145,190,200,201,203,206,208,209,210,211,213,215,216,217,218,219,220,221,223,250,252
+# );
+#our @static_nets = (
+# 0, 212, 254, 255
+# );
+
+# Used by ipv6-stats, but never got updated for tg11-ip's. Commenting.
+# The following is the list of routing netboxes (core, dist, tele, a.s.o)
+our @distrobox_ips = (
+ '151.216.127.17', # distro0
+ '151.216.127.18', # distro1
+ '151.216.127.19', # distro2
+ '151.216.127.20', # distro3
+ '151.216.127.21', # distro4
+ '151.216.127.9', # crewgw
+ '151.216.127.11', # gamegw
+ '151.216.124.1', # nocgw
+ '151.216.127.6', # logistikkgw
+ '151.216.127.5', # wtfgw
+);
+
+# Forwarding zones.
+our @forwarding_zones = qw( );
+
+1;
diff --git a/include/config.pm b/include/config.pm
new file mode 100644
index 0000000..17f2c68
--- /dev/null
+++ b/include/config.pm
@@ -0,0 +1,25 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use DBI;
+package nms::config;
+
+# Don't change this file for your local setup; use config.local.pm instead.
+
+our $db_name = "<removed>";
+our $db_host = "nms.tg08.gathering.org";
+our $db_username = "<removed>";
+our $db_password = "<removed>";
+
+our $zyxel_password = "<removed>";
+our $telnet_timeout = 300;
+
+# Tech:Net sets up at least a read-community for SNMP for use
+our $ios_user = "<removed>";
+our $ios_pass = "<removed>";
+
+# No longer in use as of '12 ?
+#our $telegw_ip = "12.34.56.78";
+#our @telegw_wanlinks = ("gig1/1", "gig1/2");
+
+1;
diff --git a/include/nms.pm b/include/nms.pm
new file mode 100644
index 0000000..9567bde
--- /dev/null
+++ b/include/nms.pm
@@ -0,0 +1,104 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use DBI;
+use Net::Telnet;
+use Data::Dumper;
+use FileHandle;
+package nms;
+
+
+use base 'Exporter';
+our @EXPORT = qw(switch_disconnect switch_connect switch_exec switch_timeout db_connect);
+
+BEGIN {
+ require "config.pm";
+ eval {
+ require "config.local.pm";
+ };
+}
+
+sub db_connect {
+ my $dbh = DBI->connect("dbi:Pg:" .
+ "dbname=" . $nms::config::db_name .
+ ";host=" . $nms::config::db_host,
+ $nms::config::db_username,
+ $nms::config::db_password)
+ or die "Couldn't connect to database";
+ return $dbh;
+}
+
+sub switch_connect($) {
+ my ($ip) = @_;
+
+ my $dumplog = FileHandle->new;
+ $dumplog->open(">>/tmp/dumplog-queue") or die "/tmp/dumplog-queue: $!";
+ $dumplog->print("\n\nConnecting to " . $ip . "\n\n");
+
+ my $inputlog = FileHandle->new;
+ $inputlog->open(">>/tmp/inputlog-queue") or die "/tmp/inputlog-queue: $!";
+ $inputlog->print("\n\nConnecting to " . $ip . "\n\n");
+
+ my $conn = new Net::Telnet( Timeout => $nms::config::telnet_timeout,
+ Dump_Log => $dumplog,
+ Input_Log => $inputlog,
+ Errmode => 'return',
+ Prompt => '/DGS-3100# (?!\x1b\[K)/');
+ my $ret = $conn->open( Host => $ip);
+ if (!$ret || $ret != 1) {
+ return (undef);
+ }
+ # Handle login with and without password
+ print "Logging in without password\n";
+ $conn->waitfor('/User ?Name:/');
+ $conn->print('admin');
+ my (undef, $match) = $conn->waitfor('/DGS-3100#|Password:/');
+ die 'Unexpected prompt after login attempt' if (not defined $match);
+ if ($match eq 'Password:') {
+ $conn->print('gurbagurba'); # Dette passordet skal feile
+ $conn->waitfor('/User ?Name:/');
+ $conn->print($nms::config::dlink1g_user);
+ my (undef, $match) = $conn->waitfor('/DGS-3100#|Password:/');
+ if ($match eq 'Password:') {
+ $conn->cmd($nms::config::dlink1g_passwd);
+ }
+ }
+ return ($conn);
+}
+
+# Send a command to switch and return the data recvied from the switch
+sub switch_exec {
+ my ($cmd, $conn, $print) = @_;
+
+ # Send the command and get data from switch
+ my @data;
+ if (defined($print)) {
+ $conn->print($cmd);
+ return;
+ } else {
+ @data = $conn->cmd($cmd);
+ print $conn->errmsg, "\n";
+ }
+ return @data;
+# my @lines = ();
+# foreach my $line (@data) {
+# # Remove escape-7 sequence
+## $line =~ s/\x1b\x37//g;
+# push (@lines, $line);
+# }
+# return @lines;
+}
+
+sub switch_timeout {
+ my ($timeout, $conn) = @_;
+
+ $conn->timeout($timeout);
+ return ('Set timeout to ' . $timeout);
+}
+
+sub switch_disconnect {
+ my ($conn) = @_;
+ $conn->close;
+}
+
+1;
diff --git a/include/tgmanage.cfg.sh b/include/tgmanage.cfg.sh
new file mode 100644
index 0000000..a922f1c
--- /dev/null
+++ b/include/tgmanage.cfg.sh
@@ -0,0 +1,19 @@
+# This file is autogenerated by tools/create-shellconf.pl,
+# using data from nms::config.
+#
+# Do you need new common/configuration variables?
+# Add/update include/config.local.pm and tools/create-shellconf.pl
+
+PRIMARY="winix.tg13.gathering.org"
+SECONDARY="tress90.tg13.gathering.org"
+TGNAME="tg13"
+
+PRI_PTR="151.216.126.2"
+SEC_PTR="151.216.125.2"
+
+DDNS_KEY="<removed>"
+
+BASEV4="151.216.0.0"
+PREFIXV4="17"
+BASEV6="2a02:ed02:"
+PREFIXV6="32"