Add ChassisCollection, Chassis classes and chassis template
This commit is contained in:
parent
3a60af5373
commit
14314c99ab
@ -12,6 +12,7 @@ redfish-client ::
|
|||||||
redfish-client [options] config show
|
redfish-client [options] config show
|
||||||
redfish-client [options] config showall
|
redfish-client [options] config showall
|
||||||
redfish-client [options] manager getinfo [<manager_name>]
|
redfish-client [options] manager getinfo [<manager_name>]
|
||||||
|
redfish-client [options] chassis getinfo [<manager_name>]
|
||||||
redfish-client [options] system getinfo [<manager_name>]
|
redfish-client [options] system getinfo [<manager_name>]
|
||||||
redfish-client (-h | --help)
|
redfish-client (-h | --help)
|
||||||
redfish-client --version
|
redfish-client --version
|
||||||
@ -266,6 +267,10 @@ if __name__ == '__main__':
|
|||||||
# Display manager information using jinja2 template
|
# Display manager information using jinja2 template
|
||||||
render_template("manager_info.template")
|
render_template("manager_info.template")
|
||||||
|
|
||||||
|
def display_chassis_info(redfish_data):
|
||||||
|
# Display system information using jinja2 template
|
||||||
|
render_template("chassis_info.template")
|
||||||
|
|
||||||
def display_system_info(redfish_data):
|
def display_system_info(redfish_data):
|
||||||
# Display system information using jinja2 template
|
# Display system information using jinja2 template
|
||||||
render_template("system_info.template")
|
render_template("system_info.template")
|
||||||
@ -437,6 +442,7 @@ if __name__ == '__main__':
|
|||||||
logger.debug("system commands")
|
logger.debug("system commands")
|
||||||
display_system_info(redfish_data)
|
display_system_info(redfish_data)
|
||||||
elif arguments['chassis'] is True:
|
elif arguments['chassis'] is True:
|
||||||
pass
|
logger.debug("chassis commands")
|
||||||
|
display_chassis_info(redfish_data)
|
||||||
logger.info("Client session terminated")
|
logger.info("Client session terminated")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
72
redfish-client/templates/chassis_info.template
Normal file
72
redfish-client/templates/chassis_info.template
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
Redfish API version : {{ r.get_api_version() }}
|
||||||
|
{{ r.Root.get_name() }}
|
||||||
|
|
||||||
|
Chassis information :
|
||||||
|
=====================
|
||||||
|
{% for chassis_index in r.Chassis.chassis_dict | sort %}
|
||||||
|
{%- set chassis = r.Chassis.chassis_dict[chassis_index] %}
|
||||||
|
Chassis id {{ chassis_index }}:
|
||||||
|
Manufacturer : {{ chassis.get_manufacturer() }}
|
||||||
|
Model : {{ chassis.get_model() }}
|
||||||
|
Chassis Type : {{ chassis.get_chassis_type() }}
|
||||||
|
PartNumber : {{ chassis.get_part_number() }}
|
||||||
|
SKU : {{ chassis.get_sku() }}
|
||||||
|
Serial : {{ chassis.get_serial_number() }}
|
||||||
|
AssetTag : {{ chassis.get_asset_tag() }}
|
||||||
|
Status : State : {{ chassis.get_status().Health }} / Health : {{ chassis.get_status().Health }}
|
||||||
|
{#
|
||||||
|
Hostname : {{ system.get_hostname() }}
|
||||||
|
Bios version : {{ system.get_bios_version() }}
|
||||||
|
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 %}
|
||||||
|
{%- set ei = system.ethernet_interfaces_collection.ethernet_interfaces_dict[ethernetinterface_index] %}
|
||||||
|
Ethernet Interface id {{ ethernetinterface_index }} :
|
||||||
|
{{ ei.get_name() }}
|
||||||
|
FQDN : {{ ei.get_fqdn() }}
|
||||||
|
Mac address : {{ ei.get_mac() }}
|
||||||
|
Address ipv4 : {{ ei.get_ipv4() | join(', ') }}
|
||||||
|
Address ipv6 : {{ ei.get_ipv6() | join(', ') }}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- 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 %}
|
@ -27,7 +27,7 @@ CPU details :
|
|||||||
Threads : {{ cpu.get_threads() }}
|
Threads : {{ cpu.get_threads() }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
Available memory : {{ system.get_memory() }}
|
Available memory : {{ system.get_memory() }} GB
|
||||||
Status : State : {{ system.get_status().Health }} / Health : {{ system.get_status().Health }}
|
Status : State : {{ system.get_status().Health }} / Health : {{ system.get_status().Health }}
|
||||||
Power : {{ system.get_power() }}
|
Power : {{ system.get_power() }}
|
||||||
Description : {{ system.get_description() }}
|
Description : {{ system.get_description() }}
|
||||||
|
@ -254,7 +254,9 @@ class RedfishConnection(object):
|
|||||||
self.connection_parameters
|
self.connection_parameters
|
||||||
)
|
)
|
||||||
|
|
||||||
# self.Chassis
|
self.Chassis = types.ChassisCollection(self.Root.get_link_url("Chassis"),
|
||||||
|
self.connection_parameters
|
||||||
|
)
|
||||||
|
|
||||||
# self.EventService
|
# self.EventService
|
||||||
# self.AccountService
|
# self.AccountService
|
||||||
|
@ -846,3 +846,42 @@ class SimpleStorage(Base):
|
|||||||
return self.data.Devices
|
return self.data.Devices
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return "Not available"
|
return "Not available"
|
||||||
|
|
||||||
|
|
||||||
|
class ChassisCollection(BaseCollection):
|
||||||
|
'''Class to manage redfish ChassisCollection data.'''
|
||||||
|
def __init__(self, url, connection_parameters):
|
||||||
|
super(ChassisCollection, self).__init__(url, connection_parameters)
|
||||||
|
|
||||||
|
self.chassis_dict = {}
|
||||||
|
|
||||||
|
for link in self.links:
|
||||||
|
index = re.search(r'Chassis/(\w+)', link)
|
||||||
|
self.chassis_dict[index.group(1)] = Chassis(link, connection_parameters)
|
||||||
|
|
||||||
|
|
||||||
|
class Chassis(Device):
|
||||||
|
'''Class to manage redfish Chassis data.'''
|
||||||
|
def __init__(self, url, connection_parameters):
|
||||||
|
'''Class constructor'''
|
||||||
|
super(Chassis, self).__init__(url, connection_parameters)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
def get_chassis_type(self):
|
||||||
|
'''Get chassis type
|
||||||
|
|
||||||
|
:returns: chassis type or "Not available"
|
||||||
|
:rtype: string
|
||||||
|
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
return self.data.ChassisType
|
||||||
|
except AttributeError:
|
||||||
|
return "Not available"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user