Loading cloudcontrol/node/host/tags.py +16 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ Just define a string or a function and it will be introspected and used as a tag value. """ import re import time import datetime import os as os_ import platform as platform_ from multiprocessing import cpu_count Loading Loading @@ -207,3 +209,17 @@ def load(): def plugins(handler): return ' '.join(handler.plugins) or None # HKVM related tags def hkvmver(): """HKVM version.""" fields = dict(x.split(': ', 1) for x in open('/etc/isimage').read().split('\n') if x.strip()) return int(fields['image version']) def hkvmsetup(): """HKVM setup date.""" fields = dict(x.split(': ', 1) for x in open('/etc/isimage').read().split('\n') if x.strip()) setup_date = datetime.datetime.strptime(fields['setup date'], '%a, %d %b %Y %H:%M:%S +0000') return int(time.mktime(setup_date.timetuple())) Loading
cloudcontrol/node/host/tags.py +16 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ Just define a string or a function and it will be introspected and used as a tag value. """ import re import time import datetime import os as os_ import platform as platform_ from multiprocessing import cpu_count Loading Loading @@ -207,3 +209,17 @@ def load(): def plugins(handler): return ' '.join(handler.plugins) or None # HKVM related tags def hkvmver(): """HKVM version.""" fields = dict(x.split(': ', 1) for x in open('/etc/isimage').read().split('\n') if x.strip()) return int(fields['image version']) def hkvmsetup(): """HKVM setup date.""" fields = dict(x.split(': ', 1) for x in open('/etc/isimage').read().split('\n') if x.strip()) setup_date = datetime.datetime.strptime(fields['setup date'], '%a, %d %b %Y %H:%M:%S +0000') return int(time.mktime(setup_date.timetuple()))