Add SimpleStorageCollection and SimpleStorage classes

This commit is contained in:
Uggla 2016-03-31 22:47:10 +02:00
parent cf12504b66
commit 3a60af5373
3 changed files with 67 additions and 2 deletions

View File

@ -9,7 +9,7 @@ Manager id {{ manager_index }}:
UUID : {{ manager.get_uuid() }}
Type : {{ manager.get_type() }}
Firmware version : {{ manager.get_firmware_version() }}
State : {{ manager.get_status() }}
Status : State : {{ manager.get_status().Health }} / Health : {{ manager.get_status().Health }}
Ethernet Interface :
{%- if manager.ethernet_interfaces_collection %}
{%- for ethernetinterface_index in manager.ethernet_interfaces_collection.ethernet_interfaces_dict | sort %}

View File

@ -49,5 +49,20 @@ Ethernet Interface :
{%- else %}
This system has no ethernet interface
{%- endif %}
Simple Storage :
{%- if system.simple_storage_collection %}
{%- for simplestorage_index in system.simple_storage_collection.simple_storage_dict | sort %}
{%- set ss = system.simple_storage_collection.simple_storage_dict[simplestorage_index] %}
Simple Storage id {{ simplestorage_index }} :
{{ ss.get_name() }}
Status : State : {{ system.get_status().Health }} / Health : {{ system.get_status().Health }}
{%- for dev in ss.get_devices() %}
Device id {{ loop.index }} : {{ dev.Name }} {{ dev.Manufacturer }} {{ dev.Model }}
{%- endfor %}
{%- endfor %}
{%- else %}
This system has no simple storage
{%- endif %}
--------------------------------------------------------------------------------
{% endfor %}

View File

@ -441,6 +441,15 @@ class Systems(Device):
# This means we don't have Processors detailed data
self.processors_collection = None
try:
self.simple_storage_collection = \
SimpleStorageCollection(
self.get_link_url('SimpleStorage'),
connection_parameters)
except AttributeError:
# This means we don't have Processors detailed data
self.simple_storage_collection = None
def reset_system(self):
'''Force reset of the system.
@ -746,7 +755,7 @@ class EthernetInterfaces(Base):
class ProcessorsCollection(BaseCollection):
'''Class to manage redfish ProcessorsColkection data.'''
'''Class to manage redfish ProcessorsCollection data.'''
def __init__(self, url, connection_parameters):
super(ProcessorsCollection,
self).__init__(url, connection_parameters)
@ -796,3 +805,44 @@ class Processors(Base):
return self.data.TotalThreads
except AttributeError:
return "Not available"
class SimpleStorageCollection(BaseCollection):
'''Class to manage redfish SimpleStorageCollection data.'''
def __init__(self, url, connection_parameters):
super(SimpleStorageCollection,
self).__init__(url, connection_parameters)
self.simple_storage_dict = {}
for link in self.links:
index = re.search(r'SimpleStorage/(\w+)', link)
self.simple_storage_dict[index.group(1)] = \
SimpleStorage(link, connection_parameters)
class SimpleStorage(Base):
'''Class to manage redfish SimpleStorage'''
def get_status(self):
'''Get storage status
:returns: storage status or "Not available"
:rtype: dict
'''
try:
return self.data.Status
except AttributeError:
return "Not available"
def get_devices(self):
'''Get storage devices
:returns: storage devices or "Not available"
:rtype: list of dict
'''
try:
return self.data.Devices
except AttributeError:
return "Not available"