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.
just trying out uuid on my joyent box and had a feeling of dread when I realized the mac address problem. Thanks for the solution, you saved me HOURS.
no problem. I struggled with this for a while after our migration from Linux to Solaris and hacking gems was not an option. Posted this to hopefully save hours of grief for others, glad it helped !
The current version of UUIDTools is namespaced into a module, so it no longer conflicts with the UUID library. Also, UUIDTools will let you manually set the MAC address if for some reason it can't be automatically detected. Additionally, it correctly switches to a secure random number generator for the node sequence if no MAC address is ever supplied.
Post a Comment