Friday, February 6, 2009

So, it turns out the default behavior of the uuid gem for UUID generation on solaris relies on "ifconfig" to use the MAC address as part of the random UUID seeding. This is the default behavior of the uuid gem which includes the macaddr gem. The issue is that the command "ifconfig" by itself on solaris does not work. A few things I found en route to this.

Firstly the uuid gem has the following line inside the initialize block

@mac = Mac.addr.gsub(/:|-/, '').hex & 0x7FFFFFFFFFFF

This references the macaddr gem which has the following line in it.

cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all'

Besides not even referencing 'ifconfig -a' which is the only command that works on solaris to get the info they are after, by default solaris doesnt show the mac address so you need to pull the IP out and then filter it from the ARP table, eek. I found this link off of the Joyent website that shows how to do this if you *really* want to override initialize and pull the MAC out (http://rubyforge.org/tracker/index.php?func=detail&aid=5220&group_id=914&atid=3591)

After some research it turns out there is a much simpler solution for solaris and ruby users. Install uuidtools instead of uuid. Then instead of the old UUID.new, etc just call UUID.random_create with the new gem. This prevents any gem overriding or hacking of gem libraries, or to be honest, even using the mac address at all.

One caveat, since both gems use the UUID constructor, you cant have both loaded or things go absolutely bonkers. So if you have both gems "required" anywhere, make sure you only require one in your app.