Skip to content

Instantly share code, notes, and snippets.

@francisluong
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francisluong/d73785443de4529c17b5 to your computer and use it in GitHub Desktop.
Save francisluong/d73785443de4529c17b5 to your computer and use it in GitHub Desktop.
ARPA: output port to mac mappings on IB network
#!/usr/bin/env ruby
require 'arpa/racktastic/racktastic'
require 'arpa/racktastic/config'
require 'arpa/racktastic/data/data'
require 'sinatra'
require 'arpa/racktastic/controller/catalyst4948_switch_controller'
require 'arpa/racktastic/accessor/factory'
require 'pp'
# Sinatra defaults to development mode
# in order to form real connections and not use mock connections,
# we override this.
Sinatra::Application.environment = "production"
application = Arpa::Racktastic::Application.instance
controller = Arpa::Racktastic::Controller::Catalyst4948SwitchController.new('ib', nil, '192.168.1.254', nil, "arpa-ib")
puts "\n### CONNECTING"
controller.login
mac_output = controller.fetch_mac_table
hostmacs = {}
range = 1..37
range.each do |x|
hostmacs[x] = nil
end
mac_output.to_s.each_line do |line|
line.strip!
if line.start_with?("20")
parts = line.split
port = parts[-1].to_s.split("/")[1].to_i
mac = parts[1]
hostmacs[port] = mac
end
end
controller.logout
puts "\n\nDRAC Check - none should be empty on the right"
hostmacs.each_pair { |port, mac| puts "#{port}\t->\t#{mac}" }
exit
# sample output
# DRAC Check - none should be empty on the right
# 1 -> 7486.7adf.c2ec
# 2 -> 7486.7ae0.700c
# 3 ->
# 4 ->
# 5 ->
# 6 ->
# 7 ->
# 8 ->
# 9 ->
# 10 ->
# 11 ->
# 12 ->
# 13 ->
# 14 -> 9cb6.5480.7aa8
# 15 ->
# 16 ->
# 17 ->
# 18 ->
# 19 ->
# 20 ->
# 21 ->
# 22 ->
# 23 ->
# 24 ->
# 25 ->
# 26 ->
# 27 -> c81f.66c8.6691
# 28 ->
# 29 ->
# 30 ->
# 31 ->
# 32 ->
# 33 ->
# 34 ->
# 35 ->
# 36 ->
# 37 ->
# 43 -> 000a.9c53.9cb6
# 40 -> 0014.d12b.817b
# 38 -> c81f.66d1.9587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment