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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
From: Roland Rosenfeld <roland@spinnaker.de>
Date: Wed, 28 Sep 2022 18:01:38 +0200
Subject: Add support for Oracle ACME session border controller.
Forwarded: https://github.com/haussli/rancid/pull/51
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS=foreign no-dependencies
my_pkglibdir = $(pkglibdir)
my_pkglib_DATA = rancid.pm rancidcontrib.pm \
- acos.pm aeos.pm arbor.pm arcos.pm avocent.pm \
+ acme.pm acos.pm aeos.pm arbor.pm arcos.pm avocent.pm \
bigip.pm ciscowlc.pm \
dell.pm dnos9.pm dnos10.pm edgemax.pm edgerouter.pm exos.pm \
fortigate.pm foundry.pm frr.pm fss2.pm fxos.pm \
@@ -60,6 +60,7 @@ $(pkglib_in:%.in=%): Makefile $(top_buil
mv $@.tmp $@
# XXX there must be a better way to produce these dependencies, perhaps in
# configure.
+acme.pm: acme.pm.in
acos.pm: acos.pm.in
aeos.pm: aeos.pm.in
arbor.pm: arbor.pm.in
--- /dev/null
+++ b/lib/acme.pm.in
@@ -0,0 +1,128 @@
+package acme;
+##
+## @PACKAGE@ @VERSION@
+@copyright@
+#
+# RANCID - Really Awesome New Cisco confIg Differ
+#
+# acme.pm - Oracle ACME Session Border Controller (SBC)
+
+use 5.010;
+use strict 'vars';
+use warnings;
+require(Exporter);
+our @ISA = qw(Exporter);
+
+use rancid @VERSION@;
+
+our $proc;
+@ISA = qw(Exporter rancid main);
+
+# load-time initialization
+sub import {
+ 0;
+}
+
+# post-open(collection file) initialization
+sub init {
+ $proc = "";
+ # add content lines and separators
+ ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n");
+
+ 0;
+}
+
+# main loop of input of device output
+sub inloop {
+ my($INPUT, $OUTPUT) = @_;
+ my($cmd, $rval);
+
+TOP: while(<$INPUT>) {
+ print STDERR ("$host inloop line: $_") if ($debug);
+ tr/\015//d;
+ if (/[>#]\s?exit$/) {
+ $clean_run = 1;
+ print STDERR ("$host clean_run___last line: $_");
+ last;
+ }
+ if (/^Error:/) {
+ print STDOUT ("$host acmelogin error: $_");
+ print STDERR ("$host acmelogin error: $_") if ($debug);
+ $clean_run = 0;
+ last;
+ }
+
+
+ while (/[>#]\s*($cmds_regexp)\s*$/) {
+ $cmd = $1;
+ print STDERR "COMMAND: $cmd\n" if ($debug);
+ if (!defined($prompt)) {
+ $prompt = ($_ =~ /^([^#>]+[#>])/)[0];
+ $prompt =~ s/([][}{)(+\\])/\\$1/g;
+ print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
+ }
+ print STDERR ("HIT COMMAND:$_") if ($debug);
+ if (! defined($commands{$cmd})) {
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
+ $clean_run = 0;
+ last TOP;
+ }
+ if (! defined(&{$commands{$cmd}})) {
+ printf(STDERR "$host: undefined function - \"%s\"\n",
+ $commands{$cmd});
+ $clean_run = 0;
+ last TOP;
+ }
+ $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd);
+ delete($commands{$cmd});
+ print STDERR "$host rval: $rval\n" if ($debug);
+ if ($rval == -1) {
+ $clean_run = 0;
+ last TOP;
+ }
+ }
+ }
+}
+
+sub ShowVersion {
+ my($INPUT, $OUTPUT, $cmd) = @_;
+
+ print STDERR "$host ShowVersion: $_" if ($debug);
+
+ while (<$INPUT>) {
+ tr/\015//d;
+ next if /^\s*$/;
+ last if (/$prompt/);
+
+ ProcessHistory("VERSION","","","!VERSION: $_");
+ }
+ ProcessHistory("VERSION","","","!\n");
+ return(0);
+}
+
+# This routine processes a "write term"
+sub WriteTerm {
+ my($INPUT, $OUTPUT, $cmd) = @_;
+ print STDERR "$host In WriteTerm: $_" if ($debug);
+
+ while (<$INPUT>) {
+ print STDERR ("$host WriteTerm line: $_") if ($debug);
+
+TOP:
+ tr/\015//d;
+ return(0) if ($found_end); # Only do this routine once
+ if (/[#>]\s*exit$/) {
+ print STDERR "$host Found exit\n" if ($debug);
+ $found_end = 1;
+ $clean_run = 1;
+ return(0);
+ }
+
+ ProcessHistory("","","","$_");
+
+ }
+ print STDERR "$host Exiting WriteTerm" if ($debug);
+ return(0);
+}
+
+1;
--- a/etc/rancid.types.base
+++ b/etc/rancid.types.base
@@ -19,6 +19,14 @@ a10;command;acos::ShowAflex;show aflex a
a10;command;acos::ShowRunningConfig;show running-config all-partitions
a10;command;acos::ShowRunningConfig;show partition-config all
#
+# Oracle ACME session border controller
+acme;script;rancid -t acme
+acme;login;clogin
+acme;module;acme
+acme;inloop;acme::inloop
+acme;command;acme::ShowVersion;show version
+acme;command;acme::WriteTerm;show running-config
+#
agm;script;agmrancid
#
# XXX This was the start of support for adtran, but it is incomplete.
|