wiki:Internal/OpenFlow/OrbitSwitches/scripts

Miscellaneous scripts.

Here you can find various hacky scripts made for various purposes, that may or may not be useful.

pingmapper

A Ruby script that uses SSH to log into each imaged node and

  1. sets the data plane interface address to 192.168.x.y, where the node is nodex-y,
  2. pings the arbitrary address 192.168.0.1
  3. fetches the HW address of each node

The output of this script is a list of [x,y] : HWaddr pairs that can be compared with the MAC address table in a switch to determine which port a node lives on. The script forces the switch to populate its table by pinging the nonexistent address. The syntax is:

ruby pingmapper.rb [MIN_X] [MAX_X] [MIN_Y] [MAX_Y] -[m|p]

Where the script is run from a sandbox console and MIN_X, MAX_X, MIN_Y and MAX_Y are the range of node ID's [X,Y] to map through, -m just returns the MAC address mappings, and -p populates the MAC table of the switch using ping. No flags configures eth0 of each node and runs both tests.

gridmap

A collection of Ruby functions that can be clobbered together into a mapping script. For example:

    require "gridmap.rb"

    puts "enter node ID as \"x1,y1; x2,y2;...\"\n"
    puts "enter \"quit\" to exit\n"

    g = Grid.new
    nodes = nil

    while
        nodes = gets.chomp.split(';')
        break if nodes.first == "quit"
        nodes.each do |el|
            r,c = *(el.split(','))
            p g.switch_of(r.to_i,c.to_i)
        end
    end

Returns a [switch, switchport] mapping for a node [x,y], or list of nodes x1,y1;x2,y2…:

# ruby sample.rb 
enter node ID as "x1,y1; x2,y2;..."
enter "quit" to exit
1,1
[253, 32]
1,2
[8, 39]
20,20;19,19
[1, 2]
[1, 44]
quit

The functions assume underlying wires are there correctly, so it is not 100% accurate. This is for hipshot guesstimates when you don't need exact locations and want them fast.

Last modified 12 years ago Last modified on Jun 2, 2012, 8:53:41 PM

Attachments (2)

  • gridmap.rb (3.0 KB ) - added by akoshibe 12 years ago.
  • pingmapper.rb (1.7 KB ) - added by akoshibe 12 years ago. script that returns a list of [node:MAC] pairs and populates switch MAC tables for a sandbox.

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.