Miscellaneous scripts.

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


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
  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.


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 =
    nodes = nil

        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)

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
[253, 32]
[8, 39]
[1, 2]
[1, 44]

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 11 years ago Last modified on Jun 2, 2012, 8:53:41 PM

Attachments (2)

  • gridmap.rb (3.0 KB ) - added by akoshibe 11 years ago.
  • pingmapper.rb (1.7 KB ) - added by akoshibe 11 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.