Add ProcessorsCollection and Processors classes
This commit is contained in:
parent
25a5f12287
commit
cf12504b66
@ -14,12 +14,27 @@ SKU : {{ system.get_sku() }}
|
||||
Serial : {{ system.get_serial_number() }}
|
||||
Hostname : {{ system.get_hostname() }}
|
||||
Bios version : {{ system.get_bios_version() }}
|
||||
State : {{ system.get_status() }}
|
||||
CPU number : {{ system.get_cpucount() }}
|
||||
CPU model : {{ system.get_cpumodel() }}
|
||||
|
||||
{%- if system.processors_collection %}
|
||||
CPU details :
|
||||
{%- for cpu_index in system.processors_collection.processors_dict | sort %}
|
||||
{%- set cpu = system.processors_collection.processors_dict[cpu_index] %}
|
||||
Processor id {{ cpu_index }} :
|
||||
Speed : {{ cpu.get_speed() }}
|
||||
Cores : {{ cpu.get_cores() }}
|
||||
Threads : {{ cpu.get_threads() }}
|
||||
{% endfor %}
|
||||
{%- endif %}
|
||||
Available memory : {{ system.get_memory() }}
|
||||
Status : State : {{ system.get_status().Health }} / Health : {{ system.get_status().Health }}
|
||||
Power : {{ system.get_power() }}
|
||||
Description : {{ system.get_description() }}
|
||||
Chassis : {{ system.get_chassis() | join(', ') }}
|
||||
Managers : {{ system.get_managers() | join(', ') }}
|
||||
{#
|
||||
IndicatorLED : {{ system.get_indicatorled() }}
|
||||
|
||||
Ethernet Interface :
|
||||
{%- if system.ethernet_interfaces_collection %}
|
||||
{%- for ethernetinterface_index in system.ethernet_interfaces_collection.ethernet_interfaces_dict | sort %}
|
||||
@ -34,10 +49,5 @@ Ethernet Interface :
|
||||
{%- else %}
|
||||
This system has no ethernet interface
|
||||
{%- endif %}
|
||||
Managed Chassis :
|
||||
{{ system.get_managed_chassis() | join(', ') }}
|
||||
Managed System :
|
||||
{{ system.get_managed_systems() | join(', ') }}
|
||||
----------------------------
|
||||
#}
|
||||
--------------------------------------------------------------------------------
|
||||
{% endfor %}
|
106
redfish/types.py
106
redfish/types.py
@ -423,6 +423,24 @@ class Systems(Device):
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.ethernet_interfaces_collection = \
|
||||
EthernetInterfacesCollection(
|
||||
self.get_link_url('EthernetInterfaces'),
|
||||
connection_parameters)
|
||||
except AttributeError:
|
||||
# This means we don't have EthernetInterfaces
|
||||
self.ethernet_interfaces_collection = None
|
||||
|
||||
try:
|
||||
self.processors_collection = \
|
||||
ProcessorsCollection(
|
||||
self.get_link_url('Processors'),
|
||||
connection_parameters)
|
||||
except AttributeError:
|
||||
# This means we don't have Processors detailed data
|
||||
self.processors_collection = None
|
||||
|
||||
def reset_system(self):
|
||||
'''Force reset of the system.
|
||||
|
||||
@ -503,6 +521,42 @@ class Systems(Device):
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
def get_cpucount(self):
|
||||
'''Get the number of cpu in the system.
|
||||
|
||||
:returns: number of cpu or "Not available"
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
try:
|
||||
return self.data.ProcessorSummary.Count
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
def get_cpumodel(self):
|
||||
'''Get the cpu model available in the system.
|
||||
|
||||
:returns: cpu model or "Not available"
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
try:
|
||||
return self.data.ProcessorSummary.Model
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
def get_memory(self):
|
||||
'''Get the memory available in the system.
|
||||
|
||||
:returns: memory available or "Not available"
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
try:
|
||||
return self.data.MemorySummary.TotalSystemMemoryGiB
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
def get_chassis(self):
|
||||
'''Get chassis ids used by the system
|
||||
|
||||
@ -690,3 +744,55 @@ class EthernetInterfaces(Base):
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
|
||||
class ProcessorsCollection(BaseCollection):
|
||||
'''Class to manage redfish ProcessorsColkection data.'''
|
||||
def __init__(self, url, connection_parameters):
|
||||
super(ProcessorsCollection,
|
||||
self).__init__(url, connection_parameters)
|
||||
|
||||
self.processors_dict = {}
|
||||
|
||||
for link in self.links:
|
||||
index = re.search(r'Processors/(\w+)', link)
|
||||
self.processors_dict[index.group(1)] = \
|
||||
Processors(link, connection_parameters)
|
||||
|
||||
|
||||
class Processors(Base):
|
||||
'''Class to manage redfish Processors.'''
|
||||
def get_speed(self):
|
||||
'''Get processor speed
|
||||
|
||||
:returns: processor speed or "Not available"
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
try:
|
||||
return self.data.MaxSpeedMHz
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
def get_cores(self):
|
||||
'''Get processor cores number
|
||||
|
||||
:returns: cores number or "Not available"
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
try:
|
||||
return self.data.TotalCores
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
||||
def get_threads(self):
|
||||
'''Get processor threads number
|
||||
|
||||
:returns: threads number or "Not available"
|
||||
:rtype: string
|
||||
|
||||
'''
|
||||
try:
|
||||
return self.data.TotalThreads
|
||||
except AttributeError:
|
||||
return "Not available"
|
||||
|
Loading…
x
Reference in New Issue
Block a user