Created
January 31, 2011 17:39
-
-
Save oogali/804439 to your computer and use it in GitHub Desktop.
Self-contained HTML + JS to generate peer configurations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<!-- | |
Self-contained peering template generator | |
========================================= | |
I like to code. | |
I like my peering definitions to have some sort of consistency. | |
I like other people to be able to use my code/templates without hassle. | |
Having each person do things a little differently is like a death by | |
1,000 papercuts. Especially, when it's 4am, you're groggy, and trying | |
to understand what non-sensical frame of mind the other person was in | |
when they configured this thing. | |
Drop this HTML file on your laptop, desktop, or internal engineering | |
server and *make* your team use it. | |
Oh, make sure you've defined your exchanges and peer-groups beforehand. | |
Thanks, | |
Omachonu Ogali / oogali at blip dot tv / @oogali | |
$Id$ // git://gist.github.com/804439.git | |
--> | |
<title>peering template</title> | |
<style type="text/css"> | |
body, h1, h2, h3, h4, h5, h6, input, th, td { font-family: helvetica, arial, verdana; } | |
html { margin: 0; padding: 0; background-color: #ffffff; } | |
body { font-size: 12px } | |
h1 { margin: 0px 0px 10px 0px; } | |
hr { margin-bottom: 10px; } | |
div#footer { position: absolute; bottom: 200px; width: 99%; } | |
span.name, span.val { display: block; } | |
span.name { float: left; margin-top: 4px; width: 150px; } | |
</style> | |
<script language="javascript" type="text/javascript"> | |
/* | |
* CHANGE THIS ARRAY | |
* [ unless of course, you work for Blip.tv/AS18559 :) ] | |
* | |
* Enter your exchanges and the corresponding peer group values here | |
*/ | |
var exchanges = [ | |
[ 'Big Ape NYC', 'BIGAPE-PEERS' ], | |
[ 'PAIX NYC', 'PAIX-NYC-PEERS' ], | |
[ 'Private Peering', 'PRIVATE-PEERS' ], | |
[ 'Transit', 'TRANSIT' ] | |
]; | |
/* | |
* Ok, you can stop changing stuff. | |
*/ | |
function getObj(obj) { | |
return document.getElementById(obj); | |
} | |
function gv(obj) { | |
var e = getObj(obj); | |
return e.value; | |
} | |
function generateConfig() { | |
var cfg = ''; | |
var config = getObj('config'); | |
var exchange = getObj('exchange'); | |
var network = gv('network'); | |
var asn = gv('asn'); | |
var ip = gv('ip'); | |
var pfx = gv('pfx'); | |
var md5 = gv('md5'); | |
var email = gv('email'); | |
var phone = gv('phone'); | |
var peergroup = exchange.options[exchange.selectedIndex].value; | |
cfg += 'neighbor ' + ip + ' remote-as ' + asn + '\n'; | |
cfg += (peergroup.length == 0 ? '!' : '') + 'neighbor ' + ip + ' peer-group ' + (peergroup.length == 0 ? '(no peer-group)' : peergroup) + '\n'; | |
cfg += 'neighbor ' + ip + ' description ' + network + ' [' + email + ' / ' + phone + ']\n'; | |
cfg += (md5.length == 0 ? '!' : '') + 'neighbor ' + ip + ' password ' + (md5.length == 0 ? '(no password)' : md5) + '\n'; | |
cfg += 'neighbor ' + ip + ' maximum-prefix ' + (pfx.length == 0 ? '500' : pfx) + '\n'; | |
cfg += 'neighbor ' + ip + ' shutdown\n'; | |
config.innerHTML = cfg; | |
} | |
function populateExchanges() { | |
var exchange = getObj('exchange'); | |
for (i = 0; i < exchanges.length; i++) { | |
var o = document.createElement('option'); | |
o.text = exchanges[i][0]; | |
o.value = exchanges[i][1]; | |
try { | |
exchange.add(o, null); | |
} catch (e) { | |
exchange.add(o); | |
} | |
} | |
} | |
</script> | |
</head> | |
<body onload="populateExchanges()"> | |
<h1>off-line, self-contained peering template automagic</h1> | |
<hr noshade="#000000"> | |
<div id="fillin"> | |
<form id="params" action="post" name="params"> | |
<span class="name">Exchange/Type:</span> | |
<span class="val"> | |
<select name="exchange" id="exchange"> | |
<option value="">--</option> | |
</select> | |
</span><br> | |
<span class="name">Network Name:</span> | |
<span class= "val"><input type="text" name="network" id="network" default="1" size="35"></span><br> | |
<span class="name">AS Number:</span> | |
<span class= "val"><input type="text" name="asn" id="asn" default="1" size="20"></span><br> | |
<span class="name">Peering IP Address:</span> | |
<span class= "val"><input type="text" name="ip" id="ip" default="1" size= "20"></span><br> | |
<span class="name">Maximum Prefixes:</span> | |
<span class= "val"><input type="text" name="pfx" id="pfx" default="1" size="20"></span><br> | |
<span class="name">MD5 Password (if any):</span> | |
<span class= "val"><input type="text" name="md5" id="md5" default="1" size="20"></span><br> | |
<span class="name">NOC E-Mail address:</span> | |
<span class= "val"><input type="text" name="email" id="email" default="1" size="30"></span><br> | |
<span class="name">NOC Phone Number:</span> | |
<span class="val"><input type="text" name="phone" id="phone" default="1" size="30"></span><br> | |
<br> | |
<input type="button" value="generate!" onclick="generateConfig()"> | |
</form> | |
</div> | |
<div id="template"> | |
<br> | |
<br> | |
<pre id="config"> | |
</pre> | |
</div> | |
<div id="footer"> | |
<hr noshade="#ffffff"> | |
$Id$ // git://gist.github.com/804439.git // <a href="https://gist.github.com/804439">https://gist.github.com/804439</a><br> | |
<br> | |
<b>This HTML is for the taking. Save this file, view source and copy-and-paste, or wget it. Whatever tickles your fancy.</b> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment