diff options
author | Peter Schiffer <pschiffe@redhat.com> | 2014-01-29 16:24:50 +0100 |
---|---|---|
committer | Peter Schiffer <pschiffe@redhat.com> | 2014-02-05 15:29:44 +0100 |
commit | a74db316c3f54c979fd2bac9d512f7b5b2fedf3d (patch) | |
tree | 2ed0d761aca8212bb587f2ddc18f89e37d63737d | |
parent | 0dd4b5f7ab3b2b12f8058e16edcbf4031684a61a (diff) | |
download | openlmi-scripts-a74db316c3f54c979fd2bac9d512f7b5b2fedf3d.tar.gz openlmi-scripts-a74db316c3f54c979fd2bac9d512f7b5b2fedf3d.tar.xz openlmi-scripts-a74db316c3f54c979fd2bac9d512f7b5b2fedf3d.zip |
Hardware: added memory module information
-rw-r--r-- | commands/hardware/lmi/scripts/hardware/__init__.py | 53 |
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 |