Retrieve first part of manager data.

- Update type.py with new manager functions and manage exceptions.
- Retrieve some basic manager data from client getinfo.
This commit is contained in:
Uggla 2016-01-03 19:58:46 +01:00
parent 6c4bb1480a
commit 4b2b4ad5c6
2 changed files with 66 additions and 10 deletions

View File

@ -233,7 +233,7 @@ if __name__ == '__main__':
simulator = False
enforceSSL = True
try:
print 'Gathering data from manager, please wait...'
print('Gathering data from manager, please wait...\n')
# TODO : Add a rotating star showing program is running ?
# Could be a nice exercice for learning python. :)
logger.info('Gathering data from manager')
@ -249,8 +249,20 @@ if __name__ == '__main__':
sys.stderr.write(str(e.advices))
sys.exit(1)
print('Redfish API version : %s \n' % remote_mgmt.get_api_version())
print('Managers information :\n')
# Display manager information
# TODO : Use a templating system
print('Redfish API version : %s' % remote_mgmt.get_api_version())
print(remote_mgmt.Root.get_name())
print('\n')
print('Managers information :')
print('----------------------')
for manager_index in sorted(remote_mgmt.Managers.managers_dict):
manager = remote_mgmt.Managers.managers_dict[manager_index]
print('\nManager id {} :').format(manager_index)
print('UUID : {}').format(manager.get_uuid())
print('Type : {}').format(manager.get_type())
print('Firmware version : {}').format(manager.get_firmware_version())
print('State : {}').format(manager.get_status())

View File

@ -182,6 +182,17 @@ class Root(Base):
'''
return getattr(self.root.Links.Systems, '@odata.id')
def get_name(self):
'''Get root name
:returns: string -- root name or "Not available"
'''
try:
return self.data.Name
except AttributeError:
return "Not available"
class SessionService(Base):
'''Class to manage redfish SessionService data.'''
@ -209,18 +220,51 @@ class Managers(Base):
pass
def get_firmware_version(self):
'''Get bios version of the system.
'''Get firmware version of the manager
:returns: string -- bios version
:returns: string -- bios version or "Not available"
'''
try:
# Returned by proliant
return self.data.FirmwareVersion
except:
# Returned by mockup.
# Hopefully this kind of discrepencies will be fixed with Redfish 1.0 (August)
return self.data.FirmwareVersion
except AttributeError:
# We are here because the attribute could be not defined.
# This is the case with the mockup for manager 2 and 3
return "Not available"
def get_type(self):
'''Get manager type
:returns: string -- manager type or "Not available"
'''
try:
return self.data.ManagerType
except AttributeError:
return "Not available"
def get_uuid(self):
'''Get manager type
:returns: string -- manager uuid or "Not available"
'''
try:
return self.data.UUID
except AttributeError:
return "Not available"
def get_status(self):
'''Get manager status
:returns: string -- manager status or "Not available"
'''
try:
return self.data.Status.State
except AttributeError:
return "Not available"
class ManagersCollection(BaseCollection):