boxidau / rax-autoscaler

Apache License 2.0
5 stars 2 forks source link

replace dmidecode #86

Closed sthapa-ping closed 9 years ago

sthapa-ping commented 9 years ago

It turns out dmidecode is not reliable, https://www.centos.org/forums/viewtopic.php?t=18376 Find & Use alternative way to get machine mac address, eg: ifconfig

jon-walton commented 9 years ago

in common.get_machine_uuid() we use xenstore-read name.

autoscale.is_node_master() is the only place we call dmidecode so we should use the common.get_machine_uuid() function instead to return the system uuid

jon-walton commented 9 years ago

OK I see what we're doing now.

instead of reading the uuid from a file named with the result of dmidecode (which apparently could go wrong), why don't we update common.get_machine_uuid() to save the result to a cache file /tmp/.uuid.cache ? (teddy just filled me in that xenstore-read name has a rate limit

the code to read and write the cache should be in common.get_machine_uuid()

siso commented 9 years ago

Get server.id using pyrax, cache it, and use cached value only if it's newer than uptime value.

Fetch uptime unix timestamp:

#!/usr/bin/python

from datetime import timedelta

with open('/proc/uptime', 'r') as f:
    uptime_seconds = float(f.readline().split()[0])
    uptime_string = str(timedelta(seconds = uptime_seconds))

print(uptime_string)