Author: eallen
Date: 2010-10-20 13:23:20 -0400 (Wed, 20 Oct 2010)
New Revision: 4395
Modified:
mgmt/trunk/rosemary/python/rosemary/model.py
mgmt/trunk/rosemary/python/rosemary/util.py
Log:
Added ability to format statistics
Added method to format a property/statistic number as MB / GB / etc.
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2010-10-19 16:47:20 UTC (rev 4394)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2010-10-20 17:23:20 UTC (rev 4395)
@@ -766,7 +766,9 @@
formatter = None
if attr in self._class._properties_by_name:
formatter = self._class._properties_by_name[attr].formatter
- #TODO: handle formatters on statistics and headers as well
+ elif attr in self._class._statistics_by_name:
+ formatter = self._class._statistics_by_name[attr].formatter
+ #TODO: handle formatters headers as well
return formatter and formatter(value) or value
def get_value(self, attr):
Modified: mgmt/trunk/rosemary/python/rosemary/util.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/util.py 2010-10-19 16:47:20 UTC (rev 4394)
+++ mgmt/trunk/rosemary/python/rosemary/util.py 2010-10-20 17:23:20 UTC (rev 4395)
@@ -3,6 +3,7 @@
import sys
from pprint import pprint
+from cumin.formats import *
try:
from xml.etree.ElementTree import *
@@ -11,3 +12,6 @@
def fmt_exchange_name(value):
return value and value or "Default exchange"
+
+def fmt_kbmb(value):
+ return fmt_bytes(value * 1024)
\ No newline at end of file
Show replies by date