From 9e8b2dd973961a9313f00802655dfeda2643a63f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 26 Sep 2018 15:29:29 -0400 Subject: [PATCH] Begin storage configuration support Start by adding a storage oriented configuration area, and have it be able to list and show detail on disks. --- confluent_server/confluent/core.py | 16 +++++++++- confluent_server/confluent/messages.py | 17 ++++++++++- .../plugins/hardwaremanagement/ipmi.py | 29 ++++++++++++++++++- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index bb0fb72b..40ee408e 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -1,7 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2014 IBM Corporation -# Copyright 2015-2017 Lenovo +# Copyright 2015-2018 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -196,6 +196,20 @@ def _init_core(): }), }, }, + 'storage': { + 'arrays': PluginCollection({ + 'pluginattrs': ['hardwaremanagement.method'], + 'default': 'ipmi', + }), + 'drives': PluginCollection({ + 'pluginattrs': ['hardwaremanagement.method'], + 'default': 'ipmi', + }), + 'volumes': PluginCollection({ + 'pluginattrs': ['hardwaremanagement.method'], + 'default': 'ipmi', + }) + }, 'system': { 'all': PluginRoute({ 'pluginattrs': ['hardwaremanagement.method'], diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 010880bb..828a33cd 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -523,7 +523,6 @@ class InputConfigChangeSet(InputExpression): [node], attrs[attr]))[0][1] return endattrs - class InputAttributes(ConfluentMessage): # This is particularly designed for attributes, where a simple string # should become either a string value or a dict with {'expression':} to @@ -1241,6 +1240,22 @@ class KeyValueData(ConfluentMessage): else: self.kvpairs = {name: kvdata} +class Disk(ConfluentMessage): + + def __init__(self, name, label=None, description=None, + diskid=None, status=None, serial=None, fru=None): + self.kvpairs = { + name: { + 'label': label, + 'description': description, + 'diskid': diskid, + 'status': status, + 'serial': serial, + 'fru': fru, + } + } + + class LEDStatus(ConfluentMessage): readonly = True diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index f6b2b32a..fd6ccd19 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -1,5 +1,5 @@ # Copyright 2014 IBM Corporation -# Copyright 2015-2017 Lenovo +# Copyright 2015-2018 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -496,6 +496,8 @@ class IpmiHandler(object): self.identify() elif self.element[0] == 'sensors': self.handle_sensors() + elif self.element[:2] == ['configuration', 'storage']: + self.handle_storage() elif self.element[0] == 'configuration': self.handle_configuration() elif self.element[:3] == ['inventory', 'firmware', 'updates']: @@ -926,6 +928,15 @@ class IpmiHandler(object): newinf['name'] = dstr invitems.append(newinf) + def handle_storage(self): + if self.element[-1] == '': + self.element = self.element[:-1] + storelem = self.element[2:] + if storelem[0] == 'drives': + if len(storelem) == 1: + return self.list_disks() + return self.show_disk(storelem[1]) + def handle_sensors(self): if self.element[-1] == '': self.element = self.element[:-1] @@ -949,6 +960,22 @@ class IpmiHandler(object): return True return False + def show_disk(self, name): + scfg = self.ipmicmd.get_storage_configuration() + for disk in scfg.disks: + if (name == 'all' or simplify_name(disk.name) == name or + disk == name): + self.output.put( + msg.Disk(self.node, disk.name, disk.description, + disk.id, disk.status, disk.serial, + disk.fru)) + + def list_disks(self): + scfg = self.ipmicmd.get_storage_configuration() + self.output.put(msg.ChildCollection('all')) + for disk in scfg.disks: + self.output.put(msg.ChildCollection(simplify_name(disk.name))) + def list_sensors(self): try: sensors = self.ipmicmd.get_sensor_descriptions()