MD RAID devices are represented by LMI_MDRAIDStorageExtent class.
Configuration of a MD RAID device is represented by instance of LMI_MDRAIDStorageSetting associated to it. Currently this instance is there only for compatibility with SMI-S, but in future it may be extended to allow detailed configuration of the RAID.
Members of the MD RAID are associated to the LMI_MDRAIDStorageExtent instance by LMI_MDRAIDBasedOn association.
Following instance diagram shows RAID5 /dev/md/myRAID with three devices:
Note the Level property in LMI_MDRAIDStorageExtent, which was added to simplify RAID level calculation, in SMI-S the data redundancy and striping is determined by DataRedundancy, ExtentStripeLength and PackageRedundancy properties.
Currently the MD RAID support is limited to creation and removal of RAIDs. It is not possible to modify existing RAID, e.g. add or remove devices to/from it and/or manage RAID spares.
Use CreateOrModifyMDRAID method. Following example creates MD RAID level 5 named ‘/dev/md/myRAID’ with three members:
# Find the devices we want to add to MD RAID
# (filtering one CIM_StorageExtent.instances()
# call would be faster, but this is easier to read)
sda1 = root.CIM_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/sda1")
sdb1 = root.CIM_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/sdb1")
sdc1 = root.CIM_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/sdc1")
# Create the RAID
(ret, outparams, err) = storage_service.CreateOrModifyMDRAID(
ElementName = "myRAID",
InExtents= [sda1.path, sdb1.path, sdc1.path],
Level=5)
raid = outparams['theelement'].to_instance()
print("RAID", raid.DeviceID,
"level", raid.Level,
"of size", raid.BlockSize * raid.NumberOfBlocks,
"created")
The result is the same as shown in diagram above.
SMI-S applications can use CreateOrModifyElementFromElements method. Following example creates MD RAID level 5 named ‘/dev/md/myRAID’ with three members:
# Find the devices we want to add to MD RAID
# (filtering one CIM_StorageExtent.instances()
# call would be faster, but this is easier to read)
sda1 = root.CIM_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/sda1")
sdb1 = root.CIM_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/sdb1")
sdc1 = root.CIM_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/sdc1")
# Calculate LMI_StorageSetting, e.g. using our helper method
# (SMI-S application can of course use standard caps.CreateSetting()
# and edit it manually)
caps = root.LMI_MDRAIDStorageCapabilities.first_instance()
(ret, outparams, err) = caps.CreateMDRAIDStorageSetting(
InExtents=[sda1.path, sdb1.path, sdc1.path],
Level=5)
setting = outparams ['setting'].to_instance()
# Create the RAID
(ret, outparams, err) = storage_service.CreateOrModifyElementFromElements(
InElements=[sda1.path, sdb1.path, sdc1.path],
Goal=setting,
ElementType = 3) # 3 = StorageExtent
Enumerate LMI_MDRAIDBasedOn associations of the MD RAID extent.
Following code lists all members od /dev/md/myRAID:
# Find the disk
md = root.LMI_StorageExtent.first_instance(
Key="DeviceID", Value="/dev/md/myRAID")
devices = md.associators(AssocClass="LMI_MDRAIDBasedOn")
for dev in devices:
print "Found device", dev.DeviceID
Call DeleteMDRAID method:
md = root.LMI_MDRAIDStorageExtent.first_instance(
Key="DeviceID",
Value="/dev/md/myRAID")
(ret, outparams, err) = storage_service.DeleteMDRAID(
TheElement = md.path)
In future, we might implement: