AutoNetkit Documentation - pythonhosted.org · Standard Junosphere has the following console...
Transcript of AutoNetkit Documentation - pythonhosted.org · Standard Junosphere has the following console...
AutoNetkit DocumentationRelease 0.6.1dev-20120713
Simon Knight , Hung Nguyen
August 13, 2012
CONTENTS
1 Previous Documentation 31.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Junosphere Quickstart guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 Netkit Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.4 API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Python Module Index 49
Index 51
i
ii
AutoNetkit Documentation, Release 0.6.1dev-20120713
AutoNetkit API documentation.
Main AutoNetkit project website: www.autonetkit.org
CONTENTS 1
AutoNetkit Documentation, Release 0.6.1dev-20120713
2 CONTENTS
CHAPTER
ONE
PREVIOUS DOCUMENTATION
1.1 Installation
Detailed instructions thanks to Joel Obstfeld.
1.1.1 Overview
Use easy_install:
easy_install AutoNetkit
Depending on your operating system setup, you may need to install using sudo:
sudo easy_install AutoNetkit
1.1.2 Windows Installation
1. Download Python for Windows from:
http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi
Install the package
1. Download easy_install for Windows:
http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe#md5=57e1e64f6b7c7f1d2eddfc9746bbaf20
Install the package
1. Start a command window (run cmd.exe) and cd to directory to which Python was installed (defaults toC:\Python27)
2. cd into the Scripts directory.
3. Install the PIP package management tool by typing:
easy_install pip
4. Once complete, install AutoNetkit as follows:
pip.exe install AutoNetkit
AutoNetkit is now installed in the ‘scripts’ directory
3
AutoNetkit Documentation, Release 0.6.1dev-20120713
1.1.3 Mac Installation
Mac OS X 10.6 includes Python 2.6.1 which is sufficient to run Autonetkit
1. Download:
http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
2. Place in a directory then:
sudo sh ./setuptools-0.6c11-py2.6.egg
3. then install pip package management tools:
sudo easy_install pip
4. then install package library:
sudo pip install AutoNetkit
1.1.4 Updating AutoNetkit
to perform an update of the AutoNetKit tool,
Windows:
open a cmd session (run cmd.exe) cd into the scripts directory where Python has been installed(C:\Python27\Scripts), then:
pip.exe install --upgrade AutoNetkit
Mac:
sudo pip install --upgrade AutoNetkit
1.1.5 Next Steps
Once you have installed AutoNetkit you can proceed to the Junosphere Quickstart guide.
1.2 Junosphere Quickstart guide
1.2.1 Create a Topology
AutoNetKit will process a network topology which is presented in GraphML format. Diagrams can be created usinga tool such as yED, which is available from http://www.yworks.com/en/products_yed_download.html.
A wide range of network topologies are available from http://www.topology-zoo.org/dataset.html
• Using yED, you can build a topology by dragging in two or more ‘shape nodes’.
4 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
• Left-click on a node, hold and drag a connector to the other node to get a connection. Direction is unimportant— AutoNetKit will automatically make all drawn directed links bi-directional.
• Alternatively, download a topology from http://www.topology-zoo.org/dataset.html. Open the file in yED anduse options from the ‘Layout’ menu to see the node connectivity.
• You can set the Router’s name using the Data/Label field which is present in the node’s properties view, bydouble-clicking on a node, or by selecting a node and pressing the Enter key.
• Add the asn numbers by adding ‘Edit/Manage Custom Properties’, create a node property called ‘asn’. and pressclose
Now will see ‘asn’ present under Data field.
1.2. Junosphere Quickstart guide 5
AutoNetkit Documentation, Release 0.6.1dev-20120713
•
6 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
•
•
•
If the asn numbers are different between connected nodes, you will get an eBGP peering. If the asn number is thesame, the result will be iBGP peering.
• Save your file in GraphML format when you’re done.
1.2.2 Generating Junosphere Configuration Files
Please note: the Junosphere command has changed from –junos to –junosphere
To generate Junosphere configuration,
Windows:
1.2. Junosphere Quickstart guide 7
AutoNetkit Documentation, Release 0.6.1dev-20120713
open a cmd session (run cmd.exe) cd into the scripts directory where autonetkit has been installed(C:\Python27\scripts), then:
autonetkit -f <path to .graphml file> --junosphere [--ospf|--isis] [ --plot]
Mac:
cd into the directory where you have the graphml file and then:
autonetkit -f ./test.graphml --junosphere [--ospf|--isis] [--plot]
The --ospf option will create an IGP configuration for OSPF where as --isis will create an IGP configurationfor ISIS. BGP configuration will be created automatically if the asn properties field is present for a node (as describedabove).
The “–plot” option will generate network graphs in an html format and place them in the directory “ank_labplots”.
The script will place all of the files it creates in a directory called ank_lab. It generate a .gz file which can be up-loaded into the Junosphere ‘Library’ where it will be unpacked ready for use. A subdirectory will be created calledjunos_lab. This will contain the resulting Topology.vmm and configset directory, in which you will find theper-router configuration files. Previous configuration files are stored in the ank_lab/archive directory.
1.2.3 Olive-Based Junosphere
If you have a custom Olive-based Junosphere install, you will need to tell AutoNetkit to create the relevant configu-ration files. You will need to create a configuration file autonetkit.cfg in the same directory that you run theautonetkit -f... command in. This file follows the same format as a .ini file. For Olive-based Junosphere, youwill need the following entries:
[Junosphere]platform = Olivebasedisk = /path/to/image/junos.img
(the basedisk parameter is optional).
You should then see the following confirmation in the console output:
INFO Configuring Junos: junosphere_olive
Standard Junosphere has the following console output:
INFO Configuring Junos: junosphere
You can switch back to standard Junosphere by removing the platform line (as VJX is the default), or by explicitlysetting:
[Junosphere]platform = VJX
1.2.4 Generating AutoNetkit Configuration Files
Please refer to the Netkit Tutorial.
8 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
1.3 Netkit Tutorial
1.3.1 Simple example
This example builds and deploys a simple single Autonomous System network.
Topologies:
• Simple Network
• MultiAS Network
1.3.2 Code listing
If you haven’t already installed AutoNetkit, do so using easy_install:
easy_install AutoNetkit
When you install AutoNetkit, it will also install the standalone program. You can run this by running
autonetkit
To get the help:
sk:~ sk2$ autonetkit --helpUsage: autonetkit [options]
Options:--version show program’s version number and exit-h, --help show this help message and exit-p, --plot Plot lab-d, --deploy Deploy lab to Netkit host-f FILE, --file=FILE Load configuration from FILE-n NETKITHOST, --netkithost=NETKITHOST
Netkit host machine (if located on another machine)-u USERNAME, --username=USERNAME
Username for Netkit host machine (if connecting toexternal Netkit machine)
-v, --verify Verify lab on Netkit host--xterm Load each VM console in Xterm This is the default in
Netkit, but not ANK due to potentially large numberof VMs
--debug Debugging output--netkit Compile Netkit--cbgp Compile cBGP--gns3 Compile GNS3--junos Compile JunOS--isis Use IS-IS as IGP--tapsn=TAPSN Tap subnet to use to connect to VMs. Will be split
into /24 subnets, with first subnet allocated totunnel VM. eg 172.16.0.1 is the linux host, 172.16.0.2is the other end of the tunnel
Download the sample topology, and change to that directory on the command line:
sk:Desktop sk2$ lssimple.graphml
1.3. Netkit Tutorial 9
AutoNetkit Documentation, Release 0.6.1dev-20120713
From here you can run autonetkit:
autonetkit -f simple.graphml --netkit
1.3.3 Compiling
Running the example will give an output similar to:
sk:~ sk2$ autonetkit -f simple.graphml --netkitINFO LoadingINFO CompilingINFO Configuring Netkit
this creates the relevant folders:
sk:~ sk2$ tree ank_lab/netkit_lab/ank_lab/netkit_lab/-- AS1_Router_A| -- etc| -- hostname| -- resolv.conf| -- zebra| -- bgpd.conf| -- daemons| -- ospfd.conf| -- zebra.conf-- AS1_Router_A.startup-- AS1_Router_B| -- etc| -- bind| | -- db.2.10| | -- db.AS1| | -- db.root| | -- named.conf| -- hostname| -- resolv.conf| -- zebra| -- bgpd.conf| -- daemons| -- ospfd.conf| -- zebra.conf-- AS1_Router_B.startup
etc (for each router)
1.3.4 Accessing virtual machines
To access the virtual machines, AutoNetkit sets up a TUN/TAP subnet. Unfortunately this requires sudo permissionto create the initial connection. This must be provided outside of AutoNetkit — It is a design decision to not get theuser to enter root/sudo passwords into AutoNetkit.
If you have sudo access on the Netkit host machine, you can setup the required tunnel by issuing the followingcommand, on the Linux Netkit host machine:
vstart taptunnelvm --con0=none --eth0=tap,172.16.0.1,172.16.0.2
10 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
You will then need to issue your sudo password. AutoNetkit will look for a machine named taptunnelvm when itdeploys the lab. It assumes that this machine has been setup as by the previous command.
Once you have run this command, you are ready to deploy the lab.
You can check it is active using ifconfig, where you should have entry similar to the following (but with your user-name):
sknight@trc1:~/autonetkit$ ifconfig
nk_tap_sknight Link encap:Ethernet HWaddr ea:43:6d:b4:8b:bdinet addr:172.16.0.1 Bcast:172.16.255.255 Mask:255.255.0.0inet6 addr: fe80::e843:6dff:feb4:8bbd/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:209 errors:0 dropped:0 overruns:0 frame:0TX packets:3 errors:0 dropped:25 overruns:0 carrier:0collisions:0 txqueuelen:500RX bytes:16318 (16.3 KB) TX bytes:338 (338.0 B)
You should be able to check by pinging the host at 172.16.0.2:
sknight@trc1:~$ ping 172.16.0.2PING 172.16.0.2 (172.16.0.2) 56(84) bytes of data.64 bytes from 172.16.0.2: icmp_seq=1 ttl=64 time=1.29 ms64 bytes from 172.16.0.2: icmp_seq=2 ttl=64 time=0.232 ms
1.3.5 Deploying
To automatically deploy the lab, use the -d argument. If you are running AutoNetkit on the same machine that isrunning Netkit, just use -d. You should see the lab started as follows:
autonetkit@trc1:~$ autonetkit -f simple.graphml --netkit -dINFO LoadingINFO CompilingINFO Configuring NetkitINFO Deploying to NetkitINFO Starting labINFO Checking all previous machines shutdownINFO All previous machines shutdown, starting labINFO Starting AS1_n1 (1/8)INFO Starting AS2_n4 (2/8)INFO Starting AS1_n3 (3/8)INFO Starting AS2_n2 (4/8)INFO Starting AS1_n0 (5/8)INFO Starting AS2_n6 (6/8)INFO Starting AS2_n7 (7/8)INFO Starting AS3_n5 (8/8)INFO Finished starting Lab, 8 machines started
If you are running AutoNetkit from another machine (such as a Mac, a different Linux machine, or the same Linuxmachine but as a different user), you can get AutoNetkit to deploy using SSH. To do so, specify the -u user and -nnetkithost arguments. Note that this method assumes you have setup ssh keys, such that you can log into the Netkithost machine without a password.
Once you have setup ssh keys, you can deploy to a remote Netkit host as follows:
1.3. Netkit Tutorial 11
AutoNetkit Documentation, Release 0.6.1dev-20120713
autonetkit -f simple.graphml --netkit -d -n netkithost -u autonetkit
You can also try aarnet, a larger network. This network can be found in the Internet Topology Zoo, at www.topology-zoo.org. Download the file http://topology-zoo.org/files/Aarnet.gml
sk:~ sk2$ autonetkit -f Aarnet.gml --netkit -d -n netkithost -u autonetkitINFO LoadingINFO CompilingINFO Configuring NetkitINFO Deploying to NetkitINFO Connecting to netkithostINFO Connected to netkithostINFO Copying Lab overINFO Starting labINFO Checking all previous machines shutdownINFO All previous machines shutdown, starting labINFO Starting AARNET_Adelaide1 (1/19)INFO Starting AARNET_Alice_Springs (2/19)INFO Starting AARNET_Adelaide2 (3/19)INFO Starting AARNET_Brisbane1 (4/19)INFO Starting AARNET_Armidale (5/19)INFO Starting AARNET_Brisbane2 (6/19)INFO Starting AARNET_Cairns (7/19)INFO Starting AARNET_Canberra1 (8/19)INFO Starting AARNET_Canberra2 (9/19)INFO Starting AARNET_Darwin (10/19)INFO Starting AARNET_Hobart (11/19)INFO Starting AARNET_Melbourne1 (12/19)INFO Starting AARNET_Melbourne2 (13/19)INFO Starting AARNET_Perth1 (14/19)INFO Starting AARNET_Perth2 (15/19)INFO Starting AARNET_Rockhampton (16/19)INFO Starting AARNET_Sydney1 (17/19)INFO Starting AARNET_Sydney2 (18/19)INFO Starting AARNET_Townsville (19/19)INFO Finished starting Lab, 19 machines started
1.3.6 Logging into virtual machines
Assuming you have setup the tap host, and deployed the lab, you should now be able to access the lab. If you are onan external machine, ssh into the Linux Netkit host. If you are already on the Netkit host, you are ready to go.
Each machine is assigned an IP address inside the TAP subnet, to which you can ssh to. These IPs are allocated perAS, so the first AS has the range 172.16.1.x, the second has 172.16.2.x, etc The first host in the first AS has 172.16.1.1,the second 172.16.1.2, etc
You can check the allocations in the lab.conf file, inside the ank_lab/netkit_lab/ directory:
AARNET_Adelaide1[8]=tap,172.16.0.1,172.16.0.3AARNET_Adelaide2[8]=tap,172.16.0.1,172.16.0.4AARNET_Alice_Springs[4]=tap,172.16.0.1,172.16.0.5AARNET_Armidale[2]=tap,172.16.0.1,172.16.0.6AARNET_Brisbane1[6]=tap,172.16.0.1,172.16.0.7AARNET_Brisbane2[4]=tap,172.16.0.1,172.16.0.8AARNET_Cairns[2]=tap,172.16.0.1,172.16.0.9AARNET_Canberra1[4]=tap,172.16.0.1,172.16.0.10AARNET_Canberra2[4]=tap,172.16.0.1,172.16.0.11
12 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
AARNET_Darwin[4]=tap,172.16.0.1,172.16.0.12AARNET_Hobart[4]=tap,172.16.0.1,172.16.0.13AARNET_Melbourne1[8]=tap,172.16.0.1,172.16.0.14AARNET_Melbourne2[8]=tap,172.16.0.1,172.16.0.15AARNET_Perth1[4]=tap,172.16.0.1,172.16.0.16AARNET_Perth2[4]=tap,172.16.0.1,172.16.0.17AARNET_Rockhampton[4]=tap,172.16.0.1,172.16.0.18AARNET_Sydney1[6]=tap,172.16.0.1,172.16.0.19AARNET_Sydney2[8]=tap,172.16.0.1,172.16.0.20AARNET_Townsville[4]=tap,172.16.0.1,172.16.0.21
The first element is the name of the virtual machine (eg 1_AA), and the last IP on each line is the IP the machine canbe reached at. (The 172.16.0.1 IP is the Linux host). You can ssh into each machine as the “root” user, with the defaultpassword of “1234”:
autonetkit@trc1:~$ ssh [email protected]@172.16.0.3’s password:Last login: Mon Oct 24 04:51:19 2011Adelaide1_AARNET:~#
Here you can check DNS is working, and use standard diagnostic tools:
AS1rA:~# ping AS1rBPING lo0.AS1rB.AS1 (10.0.0.16) 56(84) bytes of data.64 bytes from lo0.AS1rB.AS1 (10.0.0.16): icmp_seq=1 ttl=64 time=0.205 ms64 bytes from lo0.AS1rB.AS1 (10.0.0.16): icmp_seq=2 ttl=64 time=0.122 ms
AS1rA:~# traceroute AS1rCtraceroute to lo0.AS1rC.AS1 (10.0.0.17), 64 hops max, 40 byte packets1 eth2.AS1rB.AS1 (10.0.0.5) 0 ms 0 ms 0 ms2 lo0.AS1rC.AS1 (10.0.0.17) 0 ms 0 ms 0 ms
and for the larger network:
AS1rper1:~# traceroute cns1traceroute to lo0.AS1rcns1.AS1 (10.0.0.128), 64 hops max, 40 byte packets1 eth0.AS1rper2.AS1 (10.0.0.93) 1 ms 0 ms 2 ms2 eth0.AS1radl2.AS1 (10.0.0.61) 0 ms 1 ms 0 ms3 eth2.AS1rmel2.AS1 (10.0.0.21) 1 ms 0 ms 0 ms4 eth0.AS1rmel1.AS1 (10.0.0.18) 1 ms 0 ms 1 ms5 eth2.AS1rsyd1.AS1 (10.0.0.34) 1 ms 1 ms 1 ms6 eth1.AS1rbne1.AS1 (10.0.0.70) 1 ms 1 ms 1 ms7 eth0.AS1rbne2.AS1 (10.0.0.49) 1 ms 1 ms 1 ms8 eth0.AS1rrok1.AS1 (10.0.0.54) 1 ms 1 ms 1 ms9 eth1.AS1rtsv1.AS1 (10.0.0.81) 1 ms 1 ms 1 ms
10 lo0.AS1rcns1.AS1 (10.0.0.128) 1 ms 1 ms 1 ms
You can also directly telnet into the machine, for zebra, ospfd or bgpd (if the router is running bgp). The defaultpassword for each of these is “z”:
sknight@trc1:~$ telnet 172.16.1.1 zebraTrying 172.16.1.1...Connected to 172.16.1.1.Escape character is ’^]’.
Hello, this is Quagga (version 0.99.10).Copyright 1996-2005 Kunihiro Ishiguro, et al.
1.3. Netkit Tutorial 13
AutoNetkit Documentation, Release 0.6.1dev-20120713
User Access Verification
Password:AS1rA.AS1> enPassword:AS1rA.AS1#
and issue Quagga commands:
AS1rA.AS1# sh ip routeCodes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
I - ISIS, B - BGP, > - selected route, * - FIB route
O>* 10.0.0.0/30 [110/2] via 10.0.0.5, eth0, 00:04:33O 10.0.0.4/30 [110/1] is directly connected, eth0, 00:05:16C>* 10.0.0.4/30 is directly connected, eth0O 10.0.0.8/30 [110/1] is directly connected, eth1, 00:04:52C>* 10.0.0.8/30 is directly connected, eth1O>* 10.0.0.16/32 [110/2] via 10.0.0.5, eth0, 00:04:33O>* 10.0.0.17/32 [110/3] via 10.0.0.5, eth0, 00:04:33O 10.0.0.18/32 [110/1] is directly connected, lo, 00:05:16C>* 10.0.0.18/32 is directly connected, loO>* 10.0.3.0/30 [110/20] via 10.0.0.5, eth0, 00:04:32O>* 10.0.3.4/30 [110/20] via 10.0.0.5, eth0, 00:04:32C>* 127.0.0.0/8 is directly connected, loO 172.16.0.0/16 [110/20] via 10.0.0.5, eth0, 00:04:32C>* 172.16.0.0/16 is directly connected, eth2AS1rA.AS1#
for ospfd:
sknight@trc1:~$ telnet 172.16.1.1 ospfdTrying 172.16.1.1...Connected to 172.16.1.1.Escape character is ’^]’.
Hello, this is Quagga (version 0.99.10).Copyright 1996-2005 Kunihiro Ishiguro, et al.
User Access Verification
Password:AS1rA.AS1> sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL10.0.0.16 1 Full/Backup 36.376s 10.0.0.5 eth0:10.0.0.6 0 0 010.0.0.129 1 Full/DROther 36.680s 10.0.0.9 eth1:10.0.0.10 0 0 0AS1rA.AS1>
and for bgpd:
sknight@trc1:~$ telnet 172.16.1.2 bgpdTrying 172.16.1.2...Connected to 172.16.1.2.Escape character is ’^]’.
Hello, this is Quagga (version 0.99.10).Copyright 1996-2005 Kunihiro Ishiguro, et al.
14 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
User Access Verification
Password:AS1rB.AS1> enAS1rB.AS1# sh ip bgpBGP table version is 0, local router ID is 10.0.0.16Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, R RemovedOrigin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 10.0.0.0/30 0.0.0.0 1 32768 ?
*> 10.0.0.4/30 0.0.0.0 1 32768 ?
*> 10.0.0.16/32 0.0.0.0 1 32768 ?
*> 10.0.3.0/30 0.0.0.0 1 32768 ?
*> 172.16.0.0 0.0.0.0 1 32768 ?
Total number of prefixes 5AS1rB.AS1#
and:
AS1rB.AS1# sh ip bgp summaryBGP router identifier 10.0.0.16, local AS number 1RIB entries 9, using 576 bytes of memoryPeers 2, using 5032 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd10.0.0.17 4 1 0 5 0 0 0 never Active10.0.1.1 4 2 0 0 0 0 0 never Active
Total number of neighbors 2
1.3.7 Plotting
Plotting can be enabled using the --plot switch:
sk:Desktop sk2$ autonetkit -f simple.graphml --netkit --plotINFO LoadingINFO CompilingINFO Configuring IGPINFO Configuring BGPINFO Configuring DNSINFO Plotting
We can see the plotting step has been completed. You can access the plots through the HTML summary page:
ank_lab/plots/summary.html
Examples of plotting and summary:
Summary:
1.3. Netkit Tutorial 15
AutoNetkit Documentation, Release 0.6.1dev-20120713
Physical:
16 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
IP Addresses:
iBGP:
1.3. Netkit Tutorial 17
AutoNetkit Documentation, Release 0.6.1dev-20120713
eBGP:
18 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
DNS:
DNS Authority (who advertises who)
1.3. Netkit Tutorial 19
AutoNetkit Documentation, Release 0.6.1dev-20120713
1.4 API Reference
To interface with AutoNetkit please use the internet module. The other modules are used internally within AutoNetkit.
1.4.1 Internet
Internet wrapper for AutoNetkit
class AutoNetkit.internet.Internet(filename=None, tapsn=IPNetwork(‘172.16.0.0/16’),netkit=False, cbgp=False, dynagen=False, libvirt=False,junosphere=False, junosphere_olive=False, olive=False,policy_file=None, olive_qemu_patched=False, deploy=False,igp=’ospf’)
Create Internet, loading from filename.
Args: filename: file to load network topology from
Returns: None
Example usage:
>>> inet = Internet("multias")
add_dns()Set compiler to configure DNS.
Args: None
Returns: None
Example usage:
>>> inet = ank.internet.Internet()>>> inet.add_dns()
collect_data(count=1, delay=0)Collects data for hosts
compile()Compile into device configuration files.
Args: None
Returns: None
Example usage:
>>> inet = ank.internet.Internet()>>> inet.compile()
>>> inet = ank.internet.Internet()>>> inet.compile()
deploy()Deploy compiled configuration files.”
Args: None
Returns: None
Example usage:
20 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
>>> inet = ank.internet.Internet()>>> inet.deploy()
dump()Dumps overlay graphs to file
Note: Doesn’t currently support saving graphs - NetworkX cannot save nodes/edges with dictionaryattributes
load(filename)Loads the network description from a graph file. Note this is done automatically if a filename is given tothe Internet constructor.
Args: filename: The file to load from
Returns: None
Example usage:
>>> inet = ank.internet.Internet()>>> inet.load("simple")>>> sorted(inet.network.graph.nodes())[RouterB.AS1, RouterA.AS1, RouterD.AS2, RouterC.AS1, RouterA.AS2, RouterA.AS3, RouterB.AS2, RouterC.AS2]
>>> inet = ank.internet.Internet()>>> inet.load("singleas")>>> sorted(inet.network.graph.nodes())[1a.AS1, 1b.AS1, 1d.AS1, 1c.AS1]
>>> inet = ank.internet.Internet()>>> inet.load("multias")>>> sorted(inet.network.graph.nodes())[1b.AS1, 1a.AS1, 2d.AS2, 1c.AS1, 2a.AS2, 3a.AS3, 2b.AS2, 2c.AS2]
optimise()Optimise each AS within the network.
Args: None
Returns: None
Example usage:
>>> inet = ank.internet.Internet()>>> inet.optimise()
plot(matplotlib=False)Plot the network topology
Args: None
Returns: None
Example usage:
>>> inet = ank.internet.Internet()>>> inet.plot()
Internal modules. Documentation provided for reference.
1.4. API Reference 21
AutoNetkit Documentation, Release 0.6.1dev-20120713
1.4.2 Algorithms
Algorithms to perform tasks on router graph.
Autonomous System
Autonomous System functions
AutoNetkit.algorithms.autonomous_system.nodes_by_as(network)returns dict of nodes indexed by AS
AutoNetkit.algorithms.autonomous_system.get_as_graphs(network)Returns a graph for each AS.
AutoNetkit.algorithms.autonomous_system.igp_graph(network)Returns IGP graph for network - based on physical graph with inter-AS links removed
AutoNetkit.algorithms.autonomous_system.as_graph_dict(network)as graphs indexed by asn #TODO: use this in ip allocs
AutoNetkit.algorithms.autonomous_system.get_as_list(network)Returns each AS ID in network.
BGP
BGP
Warning: Work in progress.
eBGP
eBGP is configured automatically, if there is an edge in the physical graph between two nodes that belong to differentAutonomous Systems:
if asn(s) != asn(t) for s,t in edges
iBGP
• Peer column refers to connections at the same level (eg 2->2)
• Parent column refers to connections to level above (eg 1->2)
• There are no child connections (eg 3->2)
• as_cluster is the entire AS
l2_cluster can be manually specified. If not specified, it defaults to being a PoP. If no PoPs specified, itdefaults to being the AS.
l3_cluster defaults to asn if not set: we connect the l2 rr to all l3 rrs in the same AS.
Three types of ibgp connection:
• up to a server
• down to a client
22 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
• over to a peer
Note: If the network only has level 1 route-reflectors, then the connections are labelled as peer
The below tables show the matching attributes to use.
1-level:
Level Peer Parent1 asn None
2-level:
Level Peer Parent1 None l2_cluster2 asn None
3-level:
Level Peer Parent1 None l2_cluster2 l2_cluster l3_cluster3 asn None
AutoNetkit.algorithms.bgp.ebgp_routers(network)List of all routers with an eBGP link
>>> network = ank.example_multi_as()>>> sorted(ebgp_routers(network))[1b.AS1, 1c.AS1, 2a.AS2, 2d.AS2, 3a.AS3]
AutoNetkit.algorithms.bgp.get_ebgp_graph(network)Returns graph of eBGP routers and links between them.
AutoNetkit.algorithms.bgp.ebgp_edges(network)Returns eBGP edges once configured from initialise_ebgp
AutoNetkit.algorithms.bgp.ibgp_routers(network)List of all routers with an iBGP link
AutoNetkit.algorithms.bgp.get_ibgp_graph(network)Returns iBGP graph (full mesh currently) for an AS.
BGP Policy
Parse BGP policy from a file.
Example Policies:
(asn = 1) egress-> (node = a.b): (if Origin(asn=2) then addTag a100)(asn = 1) egress-> (asn = 2): (if tags contain abc then setMED 200)(asn = 1) egress-> (asn = 2): (if tag = cde then addTag a300) else (if tag = def then setMED 200)(asn = 1) egress-> (asn = 2): (if tag = ghi then addTag a300)(asn = 2) ->ingress (asn = 1): (if tag = xyz then setLP 100)(asn = 2) ->ingress (asn = 1): (if tag = zzz then setLP 150 & reject route)
importLibrary library.txt
includePolicy somefile.txt
1.4. API Reference 23
AutoNetkit Documentation, Release 0.6.1dev-20120713
(asn =1 ) ->ingress (asn=2): (setLP 200)(asn = 1) egress-> (asn = 3): (if Transit(asn = 2) then addTag t_test)(asn = 1) egress-> (asn = 3): (if Origin(asn = 2) then addTag o_test)(asn = 1) egress-> (asn = 2): (if tag = abc then reject route)
Warning: Work in progress.
class AutoNetkit.algorithms.bgp_policy.BgpPolicyParser(network)Parser class
allocate_tags()Allocates community values to tags
apply_bgp_policy(qstring)Applies policy to network
>>> inet = ank.internet.Internet("2routers")>>> inet.compile()>>> node_a = inet.network.find("a.AS1")>>> node_b = inet.network.find("b.AS2")>>> pol_parser = ank.BgpPolicyParser(inet.network)
>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (setLP 200)")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [] then [setLP 200] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (setMED 200)")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [] then [setMED 200] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (*): (setMED 200)")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [] then [setMED 200] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (if tag = test then setLP 100)")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [tag = test] then [setLP 100] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (if tags contain test then setLP 100)")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [tag = test] then [setLP 100] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (if prefix_list = pl_asn_eq_2 then addTag cl_asn_eq_2))")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [prefix_list = pl_asn_eq_2] then [addTag cl_asn_eq_2] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (addTag ABC & setLP 90))")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [] then [addTag ABC, setLP 90] reject: False]]
24 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (if Origin(asn=2) then addTag a100 ))")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [tag = origin_cl_asn_eq_2] then [addTag a100] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (if Transit(asn=2) then addTag a100 ))")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [tag = transit_cl_asn_eq_2] then [addTag a100] reject: False]]
>>> pol_parser.clear_policies()>>> pol_parser.apply_bgp_policy("(asn=1) ->ingress (asn=2): (if Transit(asn=2) then addTag a100 ))")>>> inet.network.g_session[node_a][node_b][’ingress’][[if [tag = transit_cl_asn_eq_2] then [addTag a100] reject: False]]
>>> pol_parser = ank.BgpPolicyParser(ank.network.Network(ank.load_example("multias")))
#TODO: move these tests out
Testing internals:
>>> attributestring = "2a.as1">>> result = pol_parser.attribute.parseString(attributestring)
Node and edge queries:
>>> nodestring = "node = ’2ab.ab’">>> result = pol_parser.nodeQuery.parseString(nodestring)>>> result = pol_parser.edgeQuery.parseString("(" + nodestring + ") egress-> (node = b)")>>> result = pol_parser.edgeQuery.parseString("(node = a.b) egress-> (node = b)")
Full policy queries:
>>> pol_parser.apply_bgp_policy("(node = ’2a.AS2’) egress-> (*): (if prefix_list = pl_asn_eq_2 then addTag cl_asn_eq_2)")>>> pol_parser.apply_bgp_policy("(Network = AS1 ) ->ingress (Network = AS2): (if tag = deprefme then setLP 90) ")>>> pol_parser.apply_bgp_policy("(Network = AS1 ) ->ingress (Network = AS2): (addTag ABC & setLP 90) ")>>> pol_parser.apply_bgp_policy("(asn = 1) egress-> (asn = 1): (if Origin(asn=2) then addTag a100 )")>>> pol_parser.apply_bgp_policy("(asn = 1) egress-> (asn = 1): (if Transit(asn=2) then addTag a100 )")>>> pol_parser.apply_bgp_policy("(node = a_b ) ->ingress (Network = AS2): (addTag ABC & setLP 90) ")>>> pol_parser.apply_bgp_policy("(node = a_b ) ->ingress (Network = AS2): (if Transit(asn=2) then addTag a100 ) ")
apply_policy_file(policy_in_file)Applies a BGP policy file to the network
cl_and_pl_per_node()extract tags and prefixes used from sessions Also applies sequence numbers to match clauses
evaluate_node_stack(stack)Evaluates a stack of nodes with join queries
get_prefixes(nodes)Return prefixes for given node set
node_select_query(qstring)
>>> pol_parser = ank.BgpPolicyParser(ank.network.Network(ank.load_example("multias")))>>> pol_parser.node_select_query("asn = 1")set([’n0’, ’n1’, ’n3’])
1.4. API Reference 25
AutoNetkit Documentation, Release 0.6.1dev-20120713
>>> pol_parser.node_select_query("name = a.b")set([])>>> pol_parser.node_select_query("name = a_b")set([])
parse_user_def_functions(library_file)Note you need a blank newline after a function definition
proc_ot_match(match_type, match_query)Processes origin or transit match query
process_if_then_else(parsed_query)Processes if-then-else query
query_to_tag(query)flattens a node select query into a tag
store_tags_per_router()Stores the list of tags/community value mappings in the router in session graph
AutoNetkit.algorithms.bgp_policy.tag_to_cl(tag)Adds community list prefix to tag
>>> tag_to_cl("network_eq_as1")’cl_network_eq_as1’
AutoNetkit.algorithms.bgp_policy.tag_to_pl(tag)Adds prefix list prefix to tag
>>> tag_to_pl("network_eq_as1")’pl_network_eq_as1’
DNS
DNS
Warning: Work in progress.
Automated hiearchy
There are four levels.
Connectivity:
Level Name Peer Parent1 Client None dns_l2_cluster2 Caching Server ? asn3 AS Server ? root4 Root None None
Records:
Level Responsibility o1 None2 Caching for clients3 Authoritative for dns_l2_cluster4 Root - announces relevant l3
26 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
dns_l2_cluster is PoP if set, if not is asn
#TODO: allow levels to be selected:
Levels Meaning1 NA2 clients (1) connect to root (2)3 clients (1) connect to as (3), as to root (4)4 full, as above
AutoNetkit.algorithms.dns.allocate_dns_servers(network)Allocates DNS according to rules defined above
TODO: allow 3 level (ie no pop caching, clients connect to AS server) TODO: make DNS servers standalonerather that co-hosted with router
TODO: note set dns level on dns graph, but ibgp level on physical graph - inconsistent!
AutoNetkit.algorithms.dns.dns_servers(network)Servers that have DNS level > 1
AutoNetkit.algorithms.dns.dns_auth_servers(network)Servers that have auth children
AutoNetkit.algorithms.dns.dns_clients(network)Devices that have DNS level == 1
AutoNetkit.algorithms.dns.reverse_subnet(ip, prefixlen)Returns reverse address for given IP Address
•w.x.y.z/prefixlen
•prefixlen >= 24 -> return z
•24 >= prefixlen >= 16 -> return z.y
•16 >= prefixlen >= 8 -> return z.y.w
•8 >= prefixlen -> return z.y.x.w
>>> reverse_subnet(IPAddress("10.0.0.22"), 16)’22.0’>>> reverse_subnet(IPAddress("10.0.0.21"), 16)’21.0’>>> reverse_subnet(IPAddress("10.0.0.129"), 16)’129.0’>>> reverse_subnet(IPAddress("1.2.3.4"), 5)’4.3.2.1’>>> reverse_subnet(IPAddress("1.2.3.4"), 15)’4.3.2’>>> reverse_subnet(IPAddress("1.2.3.4"), 20)’4.3’>>> reverse_subnet(IPAddress("1.2.3.4"), 26)’4’
AutoNetkit.algorithms.dns.rev_dns_identifier(subnet)Returns Identifier part of subnet for use in reverse dns identification.
>>> rev_dns_identifier(IPNetwork("10.1.2.3/8"))’0.0.10.in-addr.arpa.’
>>> rev_dns_identifier(IPNetwork("172.16.1.2/16"))’16.172.in-addr.arpa.’
1.4. API Reference 27
AutoNetkit Documentation, Release 0.6.1dev-20120713
>>> rev_dns_identifier(IPNetwork("192.168.0.1/24"))’0.0.168.192.in-addr.arpa.’
Can only handle classful addreses, expect nothing if prefixlen is not divisible by 8 >>>rev_dns_identifier(IPNetwork(“192.168.0.1/22”))
Graph Product
Implementation of graph products
Introduction
>>> gptest_file = pkg_resources.resource_filename(__name__,"lib/examples/topologies/gptest.graphml")>>> G_out = graph_product("gptest_file")
Implementation
Disable plotting of examples in doctests: >>> plot = lambda x,y: None
Note: add_nodes_from will update the property of a node if it already exists TODO: add example of this
G graph is the undirected base graph
>>> G = nx.Graph()
H graph is the “pop design” graph
Each node u in the graph G has a attribute “H” which specifies the H graph to use
>>> G.add_nodes_from([ (’a’, dict(H=’style_a’)), (’b’, dict(H=’style_b’)), (’c’, dict(H=’style_c’))])
The ‘H’ attribute of a node in G refers to the key in the ‘H_graphs’ dictionary:
>>> H_graphs = {}
>>> H_graphs[’style_a’] = nx.trivial_graph()>>> plot(H_graphs[’style_a’], "style_a")
>>> H_graphs[’style_b’] = nx.cycle_graph(2)>>> plot(H_graphs[’style_b’], "style_b")
>>> H_graphs[’style_c’] = nx.cycle_graph(3)>>> plot(H_graphs[’style_c’], "style_c")
>>> H_graphs[’style_d’] = nx.Graph( [(0,1), (1,2)])>>> H_graphs[’style_d’].add_nodes_from( [(0, dict(root=True))])>>> plot(H_graphs[’style_d’], "style_d")
Edges in the graph G specify edges between pops, and have an operator which specifies the interconnection method(covered below).
Valid operators are cartesian, rooted, strong, or tensor.
>>> G.add_edges_from([(’a’,’b’, dict(operator = ’cartesian’)), (’a’,’c’, dict(operator = ’rooted’)), (’b’,’c’, dict(operator = ’tensor’))])
Nodes in output graph are the tuple (u,v) for u in G for v in G[u][’H’]
28 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
0
0
1
1.4. API Reference 29
AutoNetkit Documentation, Release 0.6.1dev-20120713
0
1
2
0
1
2
30 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
>>> sorted(node_list(G, H_graphs))[(’a’, 0), (’b’, 0), (’b’, 1), (’c’, 0), (’c’, 1), (’c’, 2)]
Examples
Using smaller case study for the following examples:
>>> G.clear()>>> G.add_nodes_from([ (’a’, dict(H=’style_d’)), (’b’, dict(H=’style_d’))])>>> G.add_edge( ’a’, ’b’)
>>> plot(G, "G")
a
b
Intra-PoP links
Intra PoP links are from the relevant H graph:
>>> sorted(intra_pop_links(G, H_graphs))[((’a’, 0), (’a’, 1)), ((’a’, 1), (’a’, 2)), ((’b’, 0), (’b’, 1)), ((’b’, 1), (’b’, 2))]
>>> plot(nx.Graph(intra_pop_links(G, H_graphs)), "intra_pop_links")
Inter-PoP links
Cartesian Product
1.4. API Reference 31
AutoNetkit Documentation, Release 0.6.1dev-20120713
a1
a0
a2
b0
b1
b2
>>> G[’a’][’b’][’operator’] = ’cartesian’>>> inter_pop_links(G, H_graphs)[((’a’, 0), (’b’, 0)), ((’a’, 1), (’b’, 1)), ((’a’, 2), (’b’, 2))]
>>> plot(nx.Graph(inter_pop_links(G, H_graphs)), "cartesian")
Rooted Product>>> G[’a’][’b’][’operator’] = ’rooted’>>> inter_pop_links(G, H_graphs)[((’a’, 0), (’b’, 0))]>>> plot(nx.Graph(inter_pop_links(G, H_graphs)), "rooted")
Lexical Product>>> G[’a’][’b’][’operator’] = ’lexical’>>> inter_pop_links(G, H_graphs)[((’a’, 0), (’b’, 0)), ((’a’, 0), (’b’, 1)), ((’a’, 0), (’b’, 2)), ((’a’, 1), (’b’, 0)), ((’a’, 1), (’b’, 1)), ((’a’, 1), (’b’, 2)), ((’a’, 2), (’b’, 0)), ((’a’, 2), (’b’, 1)), ((’a’, 2), (’b’, 2))]
>>> plot(nx.Graph(inter_pop_links(G, H_graphs)), "lexical")
Tensor Product>>> G[’a’][’b’][’operator’] = ’tensor’>>> inter_pop_links(G, H_graphs)[((’a’, 0), (’b’, 1)), ((’a’, 1), (’b’, 0)), ((’a’, 1), (’b’, 2)), ((’a’, 2), (’b’, 1))]>>> plot(nx.Graph(inter_pop_links(G, H_graphs)), "tensor")
32 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
a1
a0
a2
b0
b1
b2
a0 b0
1.4. API Reference 33
AutoNetkit Documentation, Release 0.6.1dev-20120713
a1
a0
a2
b0
b1
b2
a1
a0
a2
b0
b1
b2
34 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
Strong Product>>> G[’a’][’b’][’operator’] = ’strong’>>> inter_pop_links(G, H_graphs)[((’a’, 0), (’b’, 0)), ((’a’, 1), (’b’, 1)), ((’a’, 2), (’b’, 2)), ((’a’, 0), (’b’, 1)), ((’a’, 1), (’b’, 0)), ((’a’, 1), (’b’, 2)), ((’a’, 2), (’b’, 1))]
>>> plot(nx.Graph(inter_pop_links(G, H_graphs)), "strong")
a1
a0
a2
b0
b1
b2
Combined Intra and Inter pop links can be combined:
>>> G[’a’][’b’][’operator’] = ’cartesian’>>> edge_list = intra_pop_links(G, H_graphs) + inter_pop_links(G, H_graphs)>>> plot(nx.Graph(edge_list), "combined")
Attributes
The above code generates the list of nodes and the list of edges in the new graph. They do not contain attributes. Thenode and edge attributes are copied from the relevant G and H graphs using the rules defined in the following sections.
Node Attributes
Nodes in AutoNetkit can have attributes. A number of attributes carry special meaning, such as pop and asn, but theuser is free to add their own attributes. These attributes are preserved from the G and H graphs.
For attributes that exist in both the H graph and the G graph, the attribute in the H graph is used. This is the idea ofinheritance - the H graph is more specific.
1.4. API Reference 35
AutoNetkit Documentation, Release 0.6.1dev-20120713
a1
a0
a2
b0
b1
b2
Attributes associated with the graph products, such as H and root are not propagated to the output graph, as they areused in the generation process, but are not relevant to AutoNetkit. If the user wishes for a specific attribute to be in theoutput graph, they should add that to the relevant node.
Example Add some extra attributes to the G graph defined above:
>>> G.add_nodes_from([ (’a’, dict(color=’red’)), (’b’, dict(color=’blue’))])>>> G.nodes(data=True)[(’a’, {’color’: ’red’, ’H’: ’style_d’}), (’b’, {’color’: ’blue’, ’H’: ’style_d’})]>>> propagate_node_attributes(G, H_graphs, node_list(G, H_graphs))[((’a’, 0), {’x_pos’: 0, ’color’: ’red’, ’pop’: ’a’, ’label’: ’a0’, ’y_pos’: 0}), ((’a’, 1), {’x_pos’: 100, ’color’: ’red’, ’pop’: ’a’, ’label’: ’a1’, ’y_pos’: 0}), ((’a’, 2), {’x_pos’: 0, ’color’: ’red’, ’pop’: ’a’, ’label’: ’a2’, ’y_pos’: 100}), ((’b’, 0), {’x_pos’: 0, ’color’: ’blue’, ’pop’: ’b’, ’label’: ’b0’, ’y_pos’: 3}), ((’b’, 1), {’x_pos’: 100, ’color’: ’blue’, ’pop’: ’b’, ’label’: ’b1’, ’y_pos’: 3}), ((’b’, 2), {’x_pos’: 0, ’color’: ’blue’, ’pop’: ’b’, ’label’: ’b2’, ’y_pos’: 103})]
>>> G.add_nodes_from([ (’a’, dict(color=’red’, H=’style_e’)), (’b’, dict(color=’blue’, H=’style_e’))])>>> G.nodes(data=True)[(’a’, {’color’: ’red’, ’H’: ’style_e’}), (’b’, {’color’: ’blue’, ’H’: ’style_e’})]
Define a new H graph with some attributes. This shows the color attribute from the H graph over-writing that of the Ggraph. It can be seen that node (‘a’, 1) and (‘b’, 1) both have the color green from the H graph.
>>> H_graphs[’style_e’] = H_graphs[’style_d’].copy()>>> H_graphs[’style_e’].add_nodes_from( [(1, dict(color=’green’))])>>> H_graphs[’style_e’].nodes(data=True)[(0, {’root’: True}), (1, {’color’: ’green’}), (2, {})]
>>> propagate_node_attributes(G, H_graphs, node_list(G, H_graphs))[((’a’, 0), {’x_pos’: 0, ’color’: ’red’, ’pop’: ’a’, ’label’: ’a0’, ’y_pos’: 0}), ((’a’, 1), {’x_pos’: 100, ’color’: ’green’, ’pop’: ’a’, ’label’: ’a1’, ’y_pos’: 0}), ((’a’, 2), {’x_pos’: 0, ’color’: ’red’, ’pop’: ’a’, ’label’: ’a2’, ’y_pos’: 100}), ((’b’, 0), {’x_pos’: 0, ’color’: ’blue’, ’pop’: ’b’, ’label’: ’b0’, ’y_pos’: 3}), ((’b’, 1), {’x_pos’: 100, ’color’: ’green’, ’pop’: ’b’, ’label’: ’b1’, ’y_pos’: 3}), ((’b’, 2), {’x_pos’: 0, ’color’: ’blue’, ’pop’: ’b’, ’label’: ’b2’, ’y_pos’: 103})]
36 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
Edge Attributes
Edge attributes are simpler. Inter-Pop links obtain their data from the G graph. Intra-Pop links obtain their data fromtheir H graph.
Example For clarity, use the cartesian operator:
>>> G[’a’][’b’][’operator’] = ’cartesian’
Add a new attribute to the edge in the G graph:
>>> G.add_edges_from( [(’a’, ’b’, dict(speed=10))])>>> G.edges(data=True)[(’a’, ’b’, {’operator’: ’cartesian’, ’speed’: 10})]>>> edge_list = intra_pop_links(G, H_graphs) + inter_pop_links(G, H_graphs)
>>> H_graphs[’style_f’] = H_graphs[’style_d’].copy()>>> H_graphs[’style_f’].add_edges_from([ (0, 1, dict(speed=100)), (1, 2, dict(speed=150))])>>> H_graphs[’style_f’].edges(data=True)[(0, 1, {’speed’: 100}), (1, 2, {’speed’: 150})]
And use the new H style:
>>> G.add_nodes_from([ (’a’, dict(H=’style_f’)), (’b’, dict(H=’style_f’))])>>> propagate_edge_attributes(G, H_graphs, edge_list)[((’a’, 0), (’a’, 1), {’speed’: 100}), ((’a’, 1), (’a’, 2), {’speed’: 150}), ((’b’, 0), (’b’, 1), {’speed’: 100}), ((’b’, 1), (’b’, 2), {’speed’: 150}), ((’a’, 0), (’b’, 0), {’speed’: 10}), ((’a’, 1), (’b’, 1), {’speed’: 10}), ((’a’, 2), (’b’, 2), {’speed’: 10})]>>> plot(nx.Graph(propagate_edge_attributes(G, H_graphs, edge_list)), "edge_attributes")
speed:
10
0 speed: 1
00
speed: 10
speed: 1
50
speed: 10
speed: 10
speed: 1
50
a1
a0
a2
b0
b1
b2
1.4. API Reference 37
AutoNetkit Documentation, Release 0.6.1dev-20120713
IP
IP Addressing
AutoNetkit.algorithms.ip.get_ip_as_allocs(network)Returns list of Subnets allocated, by network
AutoNetkit.algorithms.ip.allocate_subnets(network, address_block=IPNetwork(‘10.0.0.0/8’))Allocates subnets and IP addresses to links in the network.
Args: address_block (IPNetwork): The address block to use.
Returns: ip_as_allocs
Example usage:
>>> network = ank.example_multi_as()>>> allocate_subnets(network)>>> print ank.debug_nodes(network.graph, "lo_ip"){’1a.AS1’: IPNetwork(’10.0.0.32/32’),’1b.AS1’: IPNetwork(’10.0.0.33/32’),’1c.AS1’: IPNetwork(’10.0.0.34/32’),’2a.AS2’: IPNetwork(’10.1.0.64/32’),’2b.AS2’: IPNetwork(’10.1.0.65/32’),’2c.AS2’: IPNetwork(’10.1.0.66/32’),’2d.AS2’: IPNetwork(’10.1.0.67/32’),’3a.AS3’: IPNetwork(’10.2.0.0/32’)}
>>> print ank.debug_edges(network.graph, "ip"){(’1a.AS1’, ’1b.AS1’): IPAddress(’10.0.0.10’),(’1a.AS1’, ’1c.AS1’): IPAddress(’10.0.0.22’),(’1b.AS1’, ’1a.AS1’): IPAddress(’10.0.0.9’),(’1b.AS1’, ’1c.AS1’): IPAddress(’10.0.0.26’),(’1b.AS1’, ’3a.AS3’): IPAddress(’10.0.0.17’),(’1c.AS1’, ’1a.AS1’): IPAddress(’10.0.0.21’),(’1c.AS1’, ’1b.AS1’): IPAddress(’10.0.0.25’),(’1c.AS1’, ’2a.AS2’): IPAddress(’10.0.0.29’),(’2a.AS2’, ’1c.AS1’): IPAddress(’10.0.0.30’),(’2a.AS2’, ’2b.AS2’): IPAddress(’10.1.0.10’),(’2a.AS2’, ’2d.AS2’): IPAddress(’10.1.0.26’),(’2b.AS2’, ’2a.AS2’): IPAddress(’10.1.0.9’),(’2b.AS2’, ’2c.AS2’): IPAddress(’10.1.0.18’),(’2c.AS2’, ’2b.AS2’): IPAddress(’10.1.0.17’),(’2c.AS2’, ’2d.AS2’): IPAddress(’10.1.0.30’),(’2d.AS2’, ’2a.AS2’): IPAddress(’10.1.0.25’),(’2d.AS2’, ’2c.AS2’): IPAddress(’10.1.0.29’),(’2d.AS2’, ’3a.AS3’): IPAddress(’10.1.0.33’),(’3a.AS3’, ’1b.AS1’): IPAddress(’10.0.0.18’),(’3a.AS3’, ’2d.AS2’): IPAddress(’10.1.0.34’)}
>>> print ank.debug_edges(network.graph, "sn"){(’1a.AS1’, ’1b.AS1’): IPNetwork(’10.0.0.8/30’),(’1a.AS1’, ’1c.AS1’): IPNetwork(’10.0.0.20/30’),(’1b.AS1’, ’1a.AS1’): IPNetwork(’10.0.0.8/30’),(’1b.AS1’, ’1c.AS1’): IPNetwork(’10.0.0.24/30’),(’1b.AS1’, ’3a.AS3’): IPNetwork(’10.0.0.16/30’),(’1c.AS1’, ’1a.AS1’): IPNetwork(’10.0.0.20/30’),(’1c.AS1’, ’1b.AS1’): IPNetwork(’10.0.0.24/30’),(’1c.AS1’, ’2a.AS2’): IPNetwork(’10.0.0.28/30’),(’2a.AS2’, ’1c.AS1’): IPNetwork(’10.0.0.28/30’),
38 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
(’2a.AS2’, ’2b.AS2’): IPNetwork(’10.1.0.8/30’),(’2a.AS2’, ’2d.AS2’): IPNetwork(’10.1.0.24/30’),(’2b.AS2’, ’2a.AS2’): IPNetwork(’10.1.0.8/30’),(’2b.AS2’, ’2c.AS2’): IPNetwork(’10.1.0.16/30’),(’2c.AS2’, ’2b.AS2’): IPNetwork(’10.1.0.16/30’),(’2c.AS2’, ’2d.AS2’): IPNetwork(’10.1.0.28/30’),(’2d.AS2’, ’2a.AS2’): IPNetwork(’10.1.0.24/30’),(’2d.AS2’, ’2c.AS2’): IPNetwork(’10.1.0.28/30’),(’2d.AS2’, ’3a.AS3’): IPNetwork(’10.1.0.32/30’),(’3a.AS3’, ’1b.AS1’): IPNetwork(’10.0.0.16/30’),(’3a.AS3’, ’2d.AS2’): IPNetwork(’10.1.0.32/30’)}
AutoNetkit.algorithms.ip.alloc_interfaces(network)Allocated interface IDs for each link in network
>>> network = ank.example_multi_as()>>> alloc_interfaces(network)>>> print ank.debug_edges(network.graph, "id"){(’1a.AS1’, ’1b.AS1’): 0,(’1a.AS1’, ’1c.AS1’): 1,(’1b.AS1’, ’1a.AS1’): 0,(’1b.AS1’, ’1c.AS1’): 1,(’1b.AS1’, ’3a.AS3’): 2,(’1c.AS1’, ’1a.AS1’): 0,(’1c.AS1’, ’1b.AS1’): 1,(’1c.AS1’, ’2a.AS2’): 2,(’2a.AS2’, ’1c.AS1’): 0,(’2a.AS2’, ’2b.AS2’): 1,(’2a.AS2’, ’2d.AS2’): 2,(’2b.AS2’, ’2a.AS2’): 0,(’2b.AS2’, ’2c.AS2’): 1,(’2c.AS2’, ’2b.AS2’): 0,(’2c.AS2’, ’2d.AS2’): 1,(’2d.AS2’, ’2a.AS2’): 0,(’2d.AS2’, ’2c.AS2’): 1,(’2d.AS2’, ’3a.AS3’): 2,(’3a.AS3’, ’1b.AS1’): 0,(’3a.AS3’, ’2d.AS2’): 1}
AutoNetkit.algorithms.ip.alloc_tap_hosts(network, address_block=IPNetwork(‘172.16.0.0/16’))Allocates TAP IPs for connecting using Netkit
>>> network = ank.example_multi_as()>>> alloc_tap_hosts(network)>>> print ank.debug_nodes(network.graph, "tap_ip"){’1a.AS1’: IPAddress(’172.16.1.1’),’1b.AS1’: IPAddress(’172.16.1.2’),’1c.AS1’: IPAddress(’172.16.1.3’),’2a.AS2’: IPAddress(’172.16.2.1’),’2b.AS2’: IPAddress(’172.16.2.2’),’2c.AS2’: IPAddress(’172.16.2.3’),’2d.AS2’: IPAddress(’172.16.2.4’),’3a.AS3’: IPAddress(’172.16.3.1’)}
AutoNetkit.algorithms.ip.get_tap_host(network)Returns tap host in network
AutoNetkit.algorithms.ip.ip_to_net_ent_title_ios(ip)Converts an IP address into an OSI Network Entity Title suitable for use in IS-IS on IOS.
1.4. API Reference 39
AutoNetkit Documentation, Release 0.6.1dev-20120713
>>> ip_to_net_ent_title_ios(IPAddress("192.168.19.1"))’49.1921.6801.9001.00’
AutoNetkit.algorithms.ip.ip_to_net_ent_title(ip)Converts an IP address into an OSI Network Entity Title suitable for use in IS-IS on Junos.
>>> ip_to_net_ent_title(IPAddress("192.168.19.1"))’49.0001.1921.6801.9001.00’
Housekeeping
Housekeeping
AutoNetkit.algorithms.housekeeping.tidy_archives()Moves old archive files into archive directory
Naming
Naming
AutoNetkit.algorithms.naming.domain(device)Returns domain for device
AutoNetkit.algorithms.naming.fqdn(network, node)Returns formatted domain name for node r in graph graph.
AutoNetkit.algorithms.naming.rtr_folder_name(network, node)Returns file system safe name for device, used for folders.
AutoNetkit.algorithms.naming.hostname(node)Returns name with spaces, underscores and other illegal characters removed. Useful for Bind/DNS
AutoNetkit.algorithms.naming.interface_id(platform, olive_qemu_patched=False)Returns appropriate naming function based on target olive_qemu_patched means can do int 0->6
AutoNetkit.algorithms.naming.tap_interface_id(network, node)Returns the next free interface number for the tap interface
AutoNetkit.algorithms.naming.junos_logical_int_id(int_id)For routing protocols, refer to logical int id:
>>> junos_logical_int_id("ge-0/0/1")’ge-0/0/1.0’>>> junos_logical_int_id("em0")’em0.0’
AutoNetkit.algorithms.naming.junos_int_id_em(numeric_id)Returns Junos format interface ID for an AutoNetkit interface ID eg em1
AutoNetkit.algorithms.naming.default_route(node)Returns default router for a server
AutoNetkit.algorithms.naming.server_ip(node)Servers don’t have a loopback IP
AutoNetkit.algorithms.naming.server_interface_id(node)Servers don’t have a loopback interface
40 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
1.4.3 Compiler
Compile network to target platform
Netkit compiler
Generate Netkit configuration files for a network
class AutoNetkit.compiler.netkitcompiler.NetkitCompiler(network, services, ze-bra_password=‘1234’)
Compiler main
configure()Configure Netkit
configure_bgp()Generates BGP specific configuration files
configure_dns()Generates BIND configuration files for DNS
Can check configs eg:
Forward:
bash-3.2$ named-checkzone -d AS3 ank_lab/netkit_lab/AS3_l3_3_dns_1/etc/bind/db.AS3loading "AS3" from "ank_lab/netkit_lab/AS3_l3_3_dns_1/etc/bind/db.AS3" class "IN"zone AS3/IN: loaded serial 2008080101OK
Reverse:
bash-3.2$ named-checkzone -d 0.10.in-addr.arpa ank_lab/netkit_lab/AS3_l3_3_dns_1/etc/bind/db.0.10.in-addr.arpa.loading "0.10.in-addr.arpa" from "ank_lab/netkit_lab/AS3_l3_3_dns_1/etc/bind/db.0.10.in-addr.arpa." class "IN"zone 0.10.in-addr.arpa/IN: loaded serial 2008080101OK
named:
bash-3.2$ named-checkconf ank_lab/netkit_lab/AS3_l3_3_dns_1/etc/bind/named.conf
configure_igp()Generates IGP specific configuration files (eg ospfd)
configure_netkit()Generates Netkit and Zebra/Quagga specific configuration files.
initialise()Creates lab folder structure
AutoNetkit.compiler.netkitcompiler.bind_dir(network, rtr)Returns bind path for router rtr
AutoNetkit.compiler.netkitcompiler.dot_ssh_dir(network, rtr)Returns .ssh path for router rtr
AutoNetkit.compiler.netkitcompiler.etc_dir(network, rtr)Returns etc path for router rtr
AutoNetkit.compiler.netkitcompiler.lo_interface(int_id=0)Returns Linux format lo_interface id for int_id
1.4. API Reference 41
AutoNetkit Documentation, Release 0.6.1dev-20120713
AutoNetkit.compiler.netkitcompiler.netkit_dir(network, rtr)Returns Netkit path
AutoNetkit.compiler.netkitcompiler.root_dir(network, rtr)Returns root path for router rtr
AutoNetkit.compiler.netkitcompiler.router_dir(network, rtr)Returns path for router rtr
AutoNetkit.compiler.netkitcompiler.sshd_dir(network, rtr)Returns formatted ssh path
AutoNetkit.compiler.netkitcompiler.zebra_dir(network, rtr)Returns formatted Zebra path
C-BGP compiler
Generate Netkit configuration files for a network
class AutoNetkit.compiler.cbgpcompiler.CbgpCompiler(network, services)Compiler main
configure()Configure C-BGP
initialise()Creates lab folder structure
AutoNetkit.compiler.cbgpcompiler.cbgp_file()Returns filename for config file for cbgp lab
Dynagen compiler
Generate dynagen configuration files for a network
Config options
autonetkit.cfg:
[Dynagen]image = /dev/nullworking dir = /home/autonetkit/model = 7200interfaces = "FastEthernet0/0", "FastEthernet0/1", "FastEthernet1/0", "FastEthernet1/1", "FastEthernet2/0", "FastEthernet2/1"[[Slots]]
slot1 = PA-2FE-TXslot2 = PA-2FE-TX
[[Options]]idlepc = 0x6085af60ram = 128
[[Hypervisor]]server = 127.0.0.1port = 7202
lab.net:
42 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
[[7202]]image = /dev/nullghostios = Truechassis = 7200
idlepc = 0x6085af60ram = 128slot1 = PA-2FE-TXslot2 = PA-2FE-TX
can put any key = val line into the options section of the config file. Same for slots, so S0/0 = r2 s0/0 isalso valid.
class AutoNetkit.compiler.dynagencompiler.dynagenCompiler(network, igp, services, im-age, hypervisor_server, hy-pervisor_port)
Compiler main
configure_dynagen()Generates dynagen specific configuration files.
configure_igp(router, igp_graph, ebgp_graph)igp configuration
configure_ios()Configures IOS
dynagen_interface_name(interface_id)FastEthernet1/0 -> f1/0
initialise()Creates lab folder structure
AutoNetkit.compiler.dynagencompiler.router_conf_file(network, router)Returns filename for config file for router
AutoNetkit.compiler.dynagencompiler.router_conf_path(network, router)Returns full path to router config file
Junos compiler
Generate Netkit configuration files for a network
class AutoNetkit.compiler.junoscompiler.JunosCompiler(network, services,igp=’ospf’, target=None,olive_qemu_patched=False)
Compiler main
configure_igp(router, igp_graph, ebgp_graph)igp configuration
configure_junos()Configures Junos
configure_junosphere()Configure Junosphere topology structure
initialise()Creates lab folder structure
AutoNetkit.compiler.junoscompiler.lab_dir()Lab directory for junos configs
1.4. API Reference 43
AutoNetkit Documentation, Release 0.6.1dev-20120713
AutoNetkit.compiler.junoscompiler.router_conf_dir()Directory for individual Junos router configs
AutoNetkit.compiler.junoscompiler.router_conf_file(network, router)Returns filename for config file for router
AutoNetkit.compiler.junoscompiler.router_conf_path(network, router)Returns full path to router config file
Libvirt compiler
Generate Libvirt configuration files for a network
Example deployment:
|– networks | |- net-1.xml | |- net-2.xml | |- net-3.xml |– scripts | |- create.sh | |- destroy.sh | |- start.sh |– vms
|- vm-name1 | – files-for-iso | – name1.xml |- vm-name2 | – files-for-iso | – name2.xml
class AutoNetkit.compiler.libvirtcompiler.LibvirtCompiler(network, services, host,file_structure, images,script_data)
Compiler main
configure_topology()Configure Libvirt topology structure
get_collision_domain_id(link)Returns formatted collision domain for a link
initialise()Creates lab folder structure
lab_dir()Lab directory for libvirt configs
networks_dir()Directory for individual libvirt router configs
router_conf_file(network, router)Returns filename for config file for router
router_conf_path(network, router)Returns full path to router config file
1.4.4 Config
Loads configuration settings and creates logger
AutoNetkit.config.validator = <validate.Validator object at 0x101a80d10>TODO: Document that configs files in (order of overwriting) (internal) ~/.autonetkit/autonetkit.cfg (check forWindows) ./autonetkit.cfg
1.4.5 Console Script
Standalone console script
44 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
1.4.6 Deploy
Deploy AutoNetkit lab to a target enviroment
Olive Deploy
Deploy a given Olive lab to an Olive server
class AutoNetkit.deploy.olive_deploy.OliveDeploy(host=None, username=None, net-work=None, host_alias=None,base_image=None, tel-net_start_port=None, paral-lel=1, qemu=’/usr/bin/qemu’,seabios=’-L /usr/share/seabios’,lab_dir=’junos_config_dir’)
Deploy a given Junos lab to an Olive Host
collect_data(commands)Runs specified collect_data commands
get_command_output(cmd)get current working directory
get_shell()Connects to Netkit server (if remote)
mac_address_list(router_id, count)Returns a generator of random 48-bit MAC addresses
record_port(router, port)Records telnet port in router
start_olives()Starts Olives inside Qemu Steps: 1. Create bash script to start the Olives 2. Copy bash script to remotehost 3. Start bash script as sudo
transfer_file(local_file, remote_folder=’‘)Transfers file to remote host using SCP
unallocated_ports(start=None)checks for allocated ports and returns a generator, which returns a free port
Netkit Deploy
Deploy a given Netkit lab to a Netkit server
class AutoNetkit.deploy.netkit_deploy.NetkitDeploy(server, lab_dir, network,xterm=False, host_alias=None)
Deploy a given Netkit lab to a Netkit server
archive_and_transfer_lab()Archives lab, transfers to remote server, and extracts
confirm_hosts_shutdown(host_list)Shuts down any machines in host_list which are still running
deploy()Deploys lab_dir to Netkit server
1.4. API Reference 45
AutoNetkit Documentation, Release 0.6.1dev-20120713
get_lab_host_list()Uses Netkit command to get list of hosts in lab
start_lab()Starts Netkit lab. Will also copy across lab if Netkit host is remote
1.4.7 Examples
Example networks
Examples
Single AS:
Multi AS: Examples
AutoNetkit.examples.examples.example_single_as()Single AS example topology
>>> network = example_single_as()
>>> sorted(network.graph.nodes())[1a.AS1, 1b.AS1, 1c.AS1, 1d.AS1]
>>> sorted(network.graph.edges())[(1a.AS1, 1b.AS1), (1b.AS1, 1a.AS1), (1b.AS1, 1c.AS1), (1b.AS1, 1d.AS1), (1c.AS1, 1b.AS1), (1c.AS1, 1d.AS1), (1d.AS1, 1b.AS1), (1d.AS1, 1c.AS1)]
AutoNetkit.examples.examples.example_multi_as()Multi AS example topology
#TODO: update these with bi-directional edges
>>> network = example_multi_as()
>>> sorted(network.graph.nodes())[1a.AS1, 1b.AS1, 1c.AS1, 2a.AS2, 2b.AS2, 2c.AS2, 2d.AS2, 3a.AS3]
>>> sorted(network.graph.edges())[(1a.AS1, 1b.AS1), (1a.AS1, 1c.AS1), (1b.AS1, 1a.AS1), (1b.AS1, 1c.AS1), (1b.AS1, 3a.AS3), (1c.AS1, 1a.AS1), (1c.AS1, 1b.AS1), (1c.AS1, 2a.AS2), (2a.AS2, 1c.AS1), (2a.AS2, 2b.AS2), (2a.AS2, 2d.AS2), (2b.AS2, 2a.AS2), (2b.AS2, 2c.AS2), (2c.AS2, 2b.AS2), (2c.AS2, 2d.AS2), (2d.AS2, 2a.AS2), (2d.AS2, 2c.AS2), (2d.AS2, 3a.AS3), (3a.AS3, 1b.AS1), (3a.AS3, 2d.AS2)]
1.4.8 Network
Main functions for AutoNetkit
AutoNetkit.network.LOG = <logging.Logger object at 0x101a5f410>
TODO: use for fast node access, eg can do self.ank[n][’asn’] #Return a dict of neighbors of node n. Use theexpression ‘G[n]’. def __getitem__(self, n):
also look at def __iter__(self):
and def __contains__(self,n):
to pass through to the netx graph methods for quick access
class AutoNetkit.network.Network(physical_graph=None)Main network containing router graph
46 Chapter 1. Previous Documentation
AutoNetkit Documentation, Release 0.6.1dev-20120713
add_device(node_id, asn=None, device_type=None, **kwargs)Adds a device to the physical graph
asn(node)syntactic sugar for accessing asn of a node
>>> network = ank.example_multi_as()>>> network.asn("1a.AS1")1
>>> [network.asn(node) for node in sorted(network.devices())][1, 1, 1, 2, 2, 2, 2, 3]
devices(asn=None)return devices in a network
find(fqdn)Note: this is O(N) in number of nodes
>>> network = ank.example_multi_as()>>> network.find("1a.AS1")1a.AS1>>> network.find("1a.AS4")Traceback (most recent call last):...DeviceNotFoundException
fqdn(node)Shortcut to fqdn
ibgp_cluster(node)syntactic sugar for accessing ibgp_cluster of a node
ibgp_level(node)syntactic sugar for accessing ibgp_level of a node
label(node)syntactic sugar for accessing label of a node
link(e)Returns a named-tuple for accessing link properties
lo_ip(node)syntactic sugar for accessing loopback IP of a node
network(node)syntactic sugar for accessing network of a node
pop(node)syntactic sugar for accessing pop of a node
route_reflector(node)syntactic sugar for accessing if a ndoe is a route_reflector
routers(asn=None)return routers in network
servers(asn=None)return servers in network
update_node_type(*args, **kwargs)Updates any node in graph that has no type set to be default_type
1.4. API Reference 47
AutoNetkit Documentation, Release 0.6.1dev-20120713
virtual_nodes(asn=None)return devices in a network
class AutoNetkit.network.deviceAPI to access device in network
device_hostnameReplaces . with _ to make safe for router configs
class AutoNetkit.network.link_namedtupleAPI to access link in network
remote_ipAssume bi-directional link
class AutoNetkit.network.overlayAPI to access overlay graph in network
class AutoNetkit.network.overlay_nodeAPI to access overlay graph node in network
1.4.9 Plot
Plotting
AutoNetkit.plotting.plot.plot(network, show=False, save=True)Plot the network
AutoNetkit.plotting.plot.plot_paths(network, show=False, save=True, paths=None)Plot the network
1.4.10 Read Write
Functions to load and save networks from other formats.
Example Topologies
For loading of example topologies included in AutoNetkit Example Topologies
AutoNetkit.readwrite.example_topologies.load_example(filename)Load example network
Graphml
For loading of networks from Graphml Graphml
AutoNetkit.readwrite.graphml.load_graphml(net_file, default_asn=1)Loads a network from Graphml into AutoNetkit.
Zoo
For loading of networks from the Internet Topology Zoo www.topology-zoo.org Zoo
AutoNetkit.readwrite.zoo.load_zoo(network, net_file)Loads a network from the zoo into AutoNetkit. If the file is interconnect.gml, it will treat the “type” of eachnode as the source filename of a network to load. This can be used to construct graphs of Multiple ASes.
48 Chapter 1. Previous Documentation
PYTHON MODULE INDEX
aAutoNetkit.algorithms.autonomous_system,
22AutoNetkit.algorithms.bgp, 22AutoNetkit.algorithms.bgp_policy, 23AutoNetkit.algorithms.dns, 26AutoNetkit.algorithms.graph_product, 28AutoNetkit.algorithms.housekeeping, 40AutoNetkit.algorithms.ip, 38AutoNetkit.algorithms.naming, 40AutoNetkit.autonetkit, 46AutoNetkit.compiler.cbgpcompiler, 42AutoNetkit.compiler.dynagencompiler, 42AutoNetkit.compiler.junoscompiler, 43AutoNetkit.compiler.libvirtcompiler, 44AutoNetkit.compiler.netkitcompiler, 41AutoNetkit.config, 44AutoNetkit.console_script, 44AutoNetkit.deploy.netkit_deploy, 45AutoNetkit.deploy.olive_deploy, 45AutoNetkit.examples.examples, 46AutoNetkit.internet, 20AutoNetkit.network, 46AutoNetkit.plotting.plot, 48AutoNetkit.readwrite.example_topologies,
48AutoNetkit.readwrite.graphml, 48AutoNetkit.readwrite.zoo, 48
49
AutoNetkit Documentation, Release 0.6.1dev-20120713
50 Python Module Index
INDEX
Aadd_device() (AutoNetkit.network.Network method), 46add_dns() (AutoNetkit.internet.Internet method), 20alloc_interfaces() (in module AutoNetkit.algorithms.ip),
39alloc_tap_hosts() (in module AutoNetkit.algorithms.ip),
39allocate_dns_servers() (in module Au-
toNetkit.algorithms.dns), 27allocate_subnets() (in module AutoNetkit.algorithms.ip),
38allocate_tags() (AutoNetkit.algorithms.bgp_policy.BgpPolicyParser
method), 24apply_bgp_policy() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 24
apply_policy_file() (Au-toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 25
archive_and_transfer_lab() (Au-toNetkit.deploy.netkit_deploy.NetkitDeploymethod), 45
as_graph_dict() (in module Au-toNetkit.algorithms.autonomous_system),22
asn() (AutoNetkit.network.Network method), 47AutoNetkit.algorithms.autonomous_system (module), 22AutoNetkit.algorithms.bgp (module), 22AutoNetkit.algorithms.bgp_policy (module), 23AutoNetkit.algorithms.dns (module), 26AutoNetkit.algorithms.graph_product (module), 28AutoNetkit.algorithms.housekeeping (module), 40AutoNetkit.algorithms.ip (module), 38AutoNetkit.algorithms.naming (module), 40AutoNetkit.autonetkit (module), 46AutoNetkit.compiler.cbgpcompiler (module), 42AutoNetkit.compiler.dynagencompiler (module), 42AutoNetkit.compiler.junoscompiler (module), 43AutoNetkit.compiler.libvirtcompiler (module), 44AutoNetkit.compiler.netkitcompiler (module), 41AutoNetkit.config (module), 44
AutoNetkit.console_script (module), 44AutoNetkit.deploy.netkit_deploy (module), 45AutoNetkit.deploy.olive_deploy (module), 45AutoNetkit.examples.examples (module), 46AutoNetkit.internet (module), 20AutoNetkit.network (module), 46AutoNetkit.plotting.plot (module), 48AutoNetkit.readwrite.example_topologies (module), 48AutoNetkit.readwrite.graphml (module), 48AutoNetkit.readwrite.zoo (module), 48
BBgpPolicyParser (class in Au-
toNetkit.algorithms.bgp_policy), 24bind_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 41
Ccbgp_file() (in module Au-
toNetkit.compiler.cbgpcompiler), 42CbgpCompiler (class in Au-
toNetkit.compiler.cbgpcompiler), 42cl_and_pl_per_node() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 25
collect_data() (AutoNetkit.deploy.olive_deploy.OliveDeploymethod), 45
collect_data() (AutoNetkit.internet.Internet method), 20compile() (AutoNetkit.internet.Internet method), 20configure() (AutoNetkit.compiler.cbgpcompiler.CbgpCompiler
method), 42configure() (AutoNetkit.compiler.netkitcompiler.NetkitCompiler
method), 41configure_bgp() (AutoNetkit.compiler.netkitcompiler.NetkitCompiler
method), 41configure_dns() (AutoNetkit.compiler.netkitcompiler.NetkitCompiler
method), 41configure_dynagen() (Au-
toNetkit.compiler.dynagencompiler.dynagenCompilermethod), 43
configure_igp() (AutoNetkit.compiler.dynagencompiler.dynagenCompilermethod), 43
51
AutoNetkit Documentation, Release 0.6.1dev-20120713
configure_igp() (AutoNetkit.compiler.junoscompiler.JunosCompilermethod), 43
configure_igp() (AutoNetkit.compiler.netkitcompiler.NetkitCompilermethod), 41
configure_ios() (AutoNetkit.compiler.dynagencompiler.dynagenCompilermethod), 43
configure_junos() (AutoNetkit.compiler.junoscompiler.JunosCompilermethod), 43
configure_junosphere() (Au-toNetkit.compiler.junoscompiler.JunosCompilermethod), 43
configure_netkit() (Au-toNetkit.compiler.netkitcompiler.NetkitCompilermethod), 41
configure_topology() (Au-toNetkit.compiler.libvirtcompiler.LibvirtCompilermethod), 44
confirm_hosts_shutdown() (Au-toNetkit.deploy.netkit_deploy.NetkitDeploymethod), 45
Ddefault_route() (in module Au-
toNetkit.algorithms.naming), 40deploy() (AutoNetkit.deploy.netkit_deploy.NetkitDeploy
method), 45deploy() (AutoNetkit.internet.Internet method), 20device (class in AutoNetkit.network), 48device_hostname (AutoNetkit.network.device attribute),
48devices() (AutoNetkit.network.Network method), 47dns_auth_servers() (in module Au-
toNetkit.algorithms.dns), 27dns_clients() (in module AutoNetkit.algorithms.dns), 27dns_servers() (in module AutoNetkit.algorithms.dns), 27domain() (in module AutoNetkit.algorithms.naming), 40dot_ssh_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 41dump() (AutoNetkit.internet.Internet method), 21dynagen_interface_name() (Au-
toNetkit.compiler.dynagencompiler.dynagenCompilermethod), 43
dynagenCompiler (class in Au-toNetkit.compiler.dynagencompiler), 43
Eebgp_edges() (in module AutoNetkit.algorithms.bgp), 23ebgp_routers() (in module AutoNetkit.algorithms.bgp),
23etc_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 41evaluate_node_stack() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 25
example_multi_as() (in module Au-toNetkit.examples.examples), 46
example_single_as() (in module Au-toNetkit.examples.examples), 46
Ffind() (AutoNetkit.network.Network method), 47fqdn() (AutoNetkit.network.Network method), 47fqdn() (in module AutoNetkit.algorithms.naming), 40
Gget_as_graphs() (in module Au-
toNetkit.algorithms.autonomous_system),22
get_as_list() (in module Au-toNetkit.algorithms.autonomous_system),22
get_collision_domain_id() (Au-toNetkit.compiler.libvirtcompiler.LibvirtCompilermethod), 44
get_command_output() (Au-toNetkit.deploy.olive_deploy.OliveDeploymethod), 45
get_ebgp_graph() (in module Au-toNetkit.algorithms.bgp), 23
get_ibgp_graph() (in module AutoNetkit.algorithms.bgp),23
get_ip_as_allocs() (in module AutoNetkit.algorithms.ip),38
get_lab_host_list() (Au-toNetkit.deploy.netkit_deploy.NetkitDeploymethod), 45
get_prefixes() (AutoNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 25
get_shell() (AutoNetkit.deploy.olive_deploy.OliveDeploymethod), 45
get_tap_host() (in module AutoNetkit.algorithms.ip), 39
Hhostname() (in module AutoNetkit.algorithms.naming),
40
Iibgp_cluster() (AutoNetkit.network.Network method), 47ibgp_level() (AutoNetkit.network.Network method), 47ibgp_routers() (in module AutoNetkit.algorithms.bgp), 23igp_graph() (in module Au-
toNetkit.algorithms.autonomous_system),22
initialise() (AutoNetkit.compiler.cbgpcompiler.CbgpCompilermethod), 42
initialise() (AutoNetkit.compiler.dynagencompiler.dynagenCompilermethod), 43
52 Index
AutoNetkit Documentation, Release 0.6.1dev-20120713
initialise() (AutoNetkit.compiler.junoscompiler.JunosCompilermethod), 43
initialise() (AutoNetkit.compiler.libvirtcompiler.LibvirtCompilermethod), 44
initialise() (AutoNetkit.compiler.netkitcompiler.NetkitCompilermethod), 41
interface_id() (in module AutoNetkit.algorithms.naming),40
Internet (class in AutoNetkit.internet), 20ip_to_net_ent_title() (in module Au-
toNetkit.algorithms.ip), 40ip_to_net_ent_title_ios() (in module Au-
toNetkit.algorithms.ip), 39
Jjunos_int_id_em() (in module Au-
toNetkit.algorithms.naming), 40junos_logical_int_id() (in module Au-
toNetkit.algorithms.naming), 40JunosCompiler (class in Au-
toNetkit.compiler.junoscompiler), 43
Llab_dir() (AutoNetkit.compiler.libvirtcompiler.LibvirtCompiler
method), 44lab_dir() (in module AutoNetkit.compiler.junoscompiler),
43label() (AutoNetkit.network.Network method), 47LibvirtCompiler (class in Au-
toNetkit.compiler.libvirtcompiler), 44link() (AutoNetkit.network.Network method), 47link_namedtuple (class in AutoNetkit.network), 48lo_interface() (in module Au-
toNetkit.compiler.netkitcompiler), 41lo_ip() (AutoNetkit.network.Network method), 47load() (AutoNetkit.internet.Internet method), 21load_example() (in module Au-
toNetkit.readwrite.example_topologies),48
load_graphml() (in module Au-toNetkit.readwrite.graphml), 48
load_zoo() (in module AutoNetkit.readwrite.zoo), 48LOG (in module AutoNetkit.network), 46
Mmac_address_list() (Au-
toNetkit.deploy.olive_deploy.OliveDeploymethod), 45
Nnetkit_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 41NetkitCompiler (class in Au-
toNetkit.compiler.netkitcompiler), 41
NetkitDeploy (class in AutoNetkit.deploy.netkit_deploy),45
Network (class in AutoNetkit.network), 46network() (AutoNetkit.network.Network method), 47networks_dir() (AutoNetkit.compiler.libvirtcompiler.LibvirtCompiler
method), 44node_select_query() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 25
nodes_by_as() (in module Au-toNetkit.algorithms.autonomous_system),22
OOliveDeploy (class in AutoNetkit.deploy.olive_deploy),
45optimise() (AutoNetkit.internet.Internet method), 21overlay (class in AutoNetkit.network), 48overlay_node (class in AutoNetkit.network), 48
Pparse_user_def_functions() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 26
plot() (AutoNetkit.internet.Internet method), 21plot() (in module AutoNetkit.plotting.plot), 48plot_paths() (in module AutoNetkit.plotting.plot), 48pop() (AutoNetkit.network.Network method), 47proc_ot_match() (AutoNetkit.algorithms.bgp_policy.BgpPolicyParser
method), 26process_if_then_else() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 26
Qquery_to_tag() (AutoNetkit.algorithms.bgp_policy.BgpPolicyParser
method), 26
Rrecord_port() (AutoNetkit.deploy.olive_deploy.OliveDeploy
method), 45remote_ip (AutoNetkit.network.link_namedtuple at-
tribute), 48rev_dns_identifier() (in module Au-
toNetkit.algorithms.dns), 27reverse_subnet() (in module AutoNetkit.algorithms.dns),
27root_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 42route_reflector() (AutoNetkit.network.Network method),
47router_conf_dir() (in module Au-
toNetkit.compiler.junoscompiler), 43
Index 53
AutoNetkit Documentation, Release 0.6.1dev-20120713
router_conf_file() (AutoNetkit.compiler.libvirtcompiler.LibvirtCompilermethod), 44
router_conf_file() (in module Au-toNetkit.compiler.dynagencompiler), 43
router_conf_file() (in module Au-toNetkit.compiler.junoscompiler), 44
router_conf_path() (Au-toNetkit.compiler.libvirtcompiler.LibvirtCompilermethod), 44
router_conf_path() (in module Au-toNetkit.compiler.dynagencompiler), 43
router_conf_path() (in module Au-toNetkit.compiler.junoscompiler), 44
router_dir() (in module Au-toNetkit.compiler.netkitcompiler), 42
routers() (AutoNetkit.network.Network method), 47rtr_folder_name() (in module Au-
toNetkit.algorithms.naming), 40
Sserver_interface_id() (in module Au-
toNetkit.algorithms.naming), 40server_ip() (in module AutoNetkit.algorithms.naming),
40servers() (AutoNetkit.network.Network method), 47sshd_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 42start_lab() (AutoNetkit.deploy.netkit_deploy.NetkitDeploy
method), 46start_olives() (AutoNetkit.deploy.olive_deploy.OliveDeploy
method), 45store_tags_per_router() (Au-
toNetkit.algorithms.bgp_policy.BgpPolicyParsermethod), 26
Ttag_to_cl() (in module Au-
toNetkit.algorithms.bgp_policy), 26tag_to_pl() (in module Au-
toNetkit.algorithms.bgp_policy), 26tap_interface_id() (in module Au-
toNetkit.algorithms.naming), 40tidy_archives() (in module Au-
toNetkit.algorithms.housekeeping), 40transfer_file() (AutoNetkit.deploy.olive_deploy.OliveDeploy
method), 45
Uunallocated_ports() (Au-
toNetkit.deploy.olive_deploy.OliveDeploymethod), 45
update_node_type() (AutoNetkit.network.Networkmethod), 47
Vvalidator (in module AutoNetkit.config), 44virtual_nodes() (AutoNetkit.network.Network method),
47
Zzebra_dir() (in module Au-
toNetkit.compiler.netkitcompiler), 42
54 Index