From 7b51f67128a240eeb74fc6ad31eb12e685973d4e Mon Sep 17 00:00:00 2001 From: Ton Kersten Date: Thu, 28 Feb 2013 21:33:56 +0100 Subject: [PATCH] Squashed commit of the following: commit 076501459322cf6c14de742e504339d80ffdeed5 Author: Ton Kersten Date: Thu Feb 28 21:32:57 2013 +0100 Added date and time facts to setup --- library/setup | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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