mirror of
https://github.com/xcat2/confluent.git
synced 2025-02-17 02:58:51 +00:00
Advance storage configuration API
Enumerate disks in an array in disks list. Add array associated with disk to disk data. Show detailed data on arrays and volumes.
This commit is contained in:
parent
7c006b33bc
commit
3945ccd5c3
@ -1253,11 +1253,37 @@ class KeyValueData(ConfluentMessage):
|
||||
else:
|
||||
self.kvpairs = {name: kvdata}
|
||||
|
||||
class Array(ConfluentMessage):
|
||||
def __init__(self, name, disks=None, raid=None, volumes=None,
|
||||
id=None, capacity=None, available=None):
|
||||
self.kvpairs = {
|
||||
name: {
|
||||
'disks': disks,
|
||||
'raid': raid,
|
||||
'id': id,
|
||||
'volumes': volumes,
|
||||
'capacity': capacity,
|
||||
'available': available,
|
||||
}
|
||||
}
|
||||
|
||||
class Volume(ConfluentMessage):
|
||||
def __init__(self, name, volname, size, state, array):
|
||||
self.kvpairs = {
|
||||
name: {
|
||||
'name': volname,
|
||||
'size': size,
|
||||
'state': state,
|
||||
'array': array,
|
||||
}
|
||||
}
|
||||
|
||||
class Disk(ConfluentMessage):
|
||||
valid_states = set([
|
||||
'jbod',
|
||||
'unconfigured',
|
||||
'hotspare',
|
||||
'online',
|
||||
])
|
||||
state_aliases = {
|
||||
'unconfigured good': 'unconfigured',
|
||||
@ -1274,7 +1300,8 @@ class Disk(ConfluentMessage):
|
||||
|
||||
|
||||
def __init__(self, name, label=None, description=None,
|
||||
diskid=None, state=None, serial=None, fru=None):
|
||||
diskid=None, state=None, serial=None, fru=None,
|
||||
array=None):
|
||||
state = self._normalize_state(state)
|
||||
self.kvpairs = {
|
||||
name: {
|
||||
@ -1284,6 +1311,7 @@ class Disk(ConfluentMessage):
|
||||
'state': state,
|
||||
'serial': serial,
|
||||
'fru': fru,
|
||||
'array': array,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1005,12 +1005,24 @@ class IpmiHandler(object):
|
||||
msg.Disk(self.node, disk.name, disk.description,
|
||||
disk.id, disk.status, disk.serial,
|
||||
disk.fru))
|
||||
for arr in scfg.arrays:
|
||||
arrname = '{0}-{1}'.format(*arr.id)
|
||||
for disk in arr.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, arrname))
|
||||
|
||||
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)))
|
||||
for arr in scfg.arrays:
|
||||
for disk in arr.disks:
|
||||
self.output.put(msg.ChildCollection(simplify_name(disk.name)))
|
||||
|
||||
def list_arrays(self):
|
||||
scfg = self.ipmicmd.get_storage_configuration()
|
||||
@ -1018,6 +1030,30 @@ class IpmiHandler(object):
|
||||
for arr in scfg.arrays:
|
||||
self.output.put(msg.ChildCollection('{0}-{1}'.format(*arr.id)))
|
||||
|
||||
def show_array(self, name):
|
||||
scfg = self.ipmicmd.get_storage_configuration()
|
||||
for arr in scfg.arrays:
|
||||
arrname = '{0}-{1}'.format(*arr.id)
|
||||
if arrname == name:
|
||||
vols = []
|
||||
for vol in arr.volumes:
|
||||
vols.append(simplify_name(vol.name))
|
||||
disks = []
|
||||
for disk in arr.disks:
|
||||
disks.append(simplify_name(disk.name))
|
||||
self.output.put(msg.Array(self.node, disks, arr.raid,
|
||||
vols, arrname, arr.capacity,
|
||||
arr.available_capacity))
|
||||
|
||||
def show_volume(self, name):
|
||||
scfg = self.ipmicmd.get_storage_configuration()
|
||||
for arr in scfg.arrays:
|
||||
arrname = '{0}-{1}'.format(*arr.id)
|
||||
for vol in arr.volumes:
|
||||
if name == simplify_name(vol.name):
|
||||
self.output.put(msg.Volume(self.node, vol.name, vol.size,
|
||||
vol.status, arrname))
|
||||
|
||||
def list_volumes(self):
|
||||
scfg = self.ipmicmd.get_storage_configuration()
|
||||
self.output.put(msg.ChildCollection('all'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user