summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Schiffer <pschiffe@redhat.com>2014-01-29 16:24:50 +0100
committerPeter Schiffer <pschiffe@redhat.com>2014-02-05 16:19:22 +0100
commit0106b750a697c327ec49ad6865ff49a1ed1e1415 (patch)
tree537309d22f8df4fa96fc4b7e39031fb1d9a3ebc6
parentb641e5e538ea38fca0531aaec830c336efd13014 (diff)
downloadopenlmi-scripts-0106b750a697c327ec49ad6865ff49a1ed1e1415.tar.gz
openlmi-scripts-0106b750a697c327ec49ad6865ff49a1ed1e1415.tar.xz
openlmi-scripts-0106b750a697c327ec49ad6865ff49a1ed1e1415.zip
Hardware: added memory module information
-rw-r--r--commands/hardware/lmi/scripts/hardware/__init__.py53
1 files changed, 46 insertions, 7 deletions
diff --git a/commands/hardware/lmi/scripts/hardware/__init__.py b/commands/hardware/lmi/scripts/hardware/__init__.py
index 8beba40..f070496 100644
--- a/commands/hardware/lmi/scripts/hardware/__init__.py
+++ b/commands/hardware/lmi/scripts/hardware/__init__.py
@@ -73,6 +73,23 @@ def get_all_instances(ns, class_name):
"""
return _cache_replies(ns, class_name, 'instances')
+def format_memory_size(size):
+ """
+ Returns formatted memory size.
+
+ :param size: Size in bytes
+ :type size: Number
+ :returns: Formatted size string.
+ :rtype: String
+ """
+ if not size:
+ return 'N/A GB'
+ if size >= 1073741824:
+ sizestr = '%d GB' % (int(size) / 1073741824)
+ else:
+ sizestr = '%d MB' % (int(size) / 1048576)
+ return sizestr
+
def get_all_info(ns):
"""
:returns: Tabular data of all available info.
@@ -147,6 +164,9 @@ def get_memory_info(ns):
memory = get_single_instance(ns, 'LMI_Memory')
phys_memory = get_all_instances(ns, 'LMI_PhysicalMemory')
memory_slots = get_all_instances(ns, 'LMI_MemorySlot')
+
+ size = format_memory_size(memory.NumberOfBlocks)
+
slots = ''
if len(phys_memory):
slots += '%d' % len(phys_memory)
@@ -158,11 +178,30 @@ def get_memory_info(ns):
else:
slots += 'N/A'
slots += ' total'
- if memory.NumberOfBlocks >= 1073741824:
- size = '%d GB' % (int(memory.NumberOfBlocks) / 1073741824)
- else:
- size = '%d MB' % (int(memory.NumberOfBlocks) / 1048576)
- result = [
- ('Memory:', size),
- ('Slots:', slots)]
+
+ modules = []
+ for m in phys_memory:
+ module = format_memory_size(m.Capacity)
+ if m.MemoryType:
+ module += ', %s' % ns.LMI_PhysicalMemory.MemoryTypeValues.value_name(
+ m.MemoryType)
+ if m.FormFactor:
+ module += ' (%s)' % ns.LMI_PhysicalMemory.FormFactorValues.value_name(
+ m.FormFactor)
+ if m.ConfiguredMemoryClockSpeed:
+ module += ', %d MHz' % m.ConfiguredMemoryClockSpeed
+ if m.Manufacturer:
+ module += ', %s' % m.Manufacturer
+ if m.BankLabel:
+ module += ', %s' % m.BankLabel
+ if not modules:
+ modules.append(('Modules:', module))
+ else:
+ modules.append(('', module))
+ if not modules:
+ modules.append(('Modules:', 'N/A'))
+
+ result = [('Memory:', size)]
+ result += modules
+ result.append(('Slots:', slots))
return result