diff --git a/library/setup b/library/setup index 58ec908c2ae..8c76f3f64f5 100644 --- a/library/setup +++ b/library/setup @@ -26,6 +26,7 @@ import platform import re import socket import struct +import datetime DOCUMENTATION = ''' --- @@ -117,6 +118,7 @@ class Facts(object): self.get_selinux_facts() self.get_pkg_mgr_facts() self.get_lsb_facts() + self.get_date_time_facts() def populate(self): return self.facts @@ -289,6 +291,22 @@ class Facts(object): except OSError, e: self.facts['selinux']['type'] = 'unknown' + + def get_date_time_facts(self): + self.facts['date_time'] = {} + + now = datetime.datetime.now() + self.facts['date_time']['year'] = now.strftime('%Y') + self.facts['date_time']['month'] = now.strftime('%m') + self.facts['date_time']['day'] = now.strftime('%d') + self.facts['date_time']['hour'] = now.strftime('%H') + self.facts['date_time']['minute'] = now.strftime('%M') + self.facts['date_time']['second'] = now.strftime('%S') + self.facts['date_time']['epoch'] = now.strftime('%s') + self.facts['date_time']['date'] = now.strftime('%Y-%m-%d') + self.facts['date_time']['time'] = now.strftime('%H:%M:%S') + + class Hardware(Facts): """ This is a generic Hardware subclass of Facts. This should be further