Closed sthapa-ping closed 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
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()
Get server.id using pyrax, cache it, and use cached value only if it's newer than uptime value.
#!/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)
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