Patches: Browse | Submit New | Admin

[#5220] Solaris Grid mods to get_mac_address

Date:
2006-07-28 07:54
Priority:
3
Submitted By:
Linda Derezinski (lderezinski)
Assigned To:
Nobody (None)
Category:
None
State:
Closed
Summary:
Solaris Grid mods to get_mac_address

Detailed description
I am running on one of Textdrive.com grid machines.  I do not have a dedicated network card ... which means ifconfig
does not return a mac address.  I added this code(with the help of TxD support) to solve my problem.  I don't have a
real solaris machine to test against, so this may not be the best solution.

What I did was run ifconfig to pull out the ip address.  Then used arp to find the mac address for that ip.

The other question is there a race condition with the other servers on the grid for the MAC address? 

http://trac.geobliki.org/geoblikitrac/changeset/388


446       # Returns the MAC address of the current computer's network card.
447 	  # Returns nil if a MAC address could not be found.
448 	  def UUID.get_mac_address
449 	    if RUBY_PLATFORM =~ /solaris/
450 	         ifconfig_output = `ifconfig -a`.split(' ')
451 	         index = ifconfig_output.index("inet") + 1
452 	         ip = ifconfig_output[index]
453 	         mac = `arp #{ip}`.split(' ')[3]
454 	         return mac
455 	      end
456 	    if RUBY_PLATFORM =~ /win/ && !(RUBY_PLATFORM =~ /darwin/)

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-04-30 15:26
Sender: Bob Aman

I have released 1.0.1 with Mark's version of the patch.  I do
not have access to a Solaris box, so please try it out and let
me know how it goes.
Date: 2007-04-11 17:49
Sender: Mark Uhrmacher

I found a small problem with this patch whereby it would attempt
to call arp on "127.0.0.1". Also, I added paths to
the executables since the user calling this tool didn't have
them by default.

Here are my changes:

if RUBY_PLATFORM =~ /solaris/
	ifconfig_output = `/sbin/ifconfig -a`
	ip_addresses = ifconfig_output.scan(/inet
(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)
	ip = ip_addresses.find {|addr| addr[0] != '127.0.0.1'}[0]
	mac = `/usr/sbin/arp #{ip}`.split(' ')[3]
	return mac 

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
status_idOpen2007-11-07 13:11sporkmonger
resolution_idNone2007-11-07 13:11sporkmonger
close_date2007-11-07 13:112007-11-07 13:11sporkmonger