2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-04-30 04:17:45 +00:00

Begin storage configuration support

Start by adding a storage oriented configuration area, and have it be
able to list and show detail on disks.
This commit is contained in:
Jarrod Johnson
2018-09-26 15:29:29 -04:00
parent 99fdb20f87
commit 9e8b2dd973
3 changed files with 59 additions and 3 deletions

View File

@@ -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'],

View File

@@ -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

View File

@@ -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()