Welcome to megacli-python’s documentation!

Python library for MegaCli

This is a simple Python library that wraps around MegaCli to provide an OO interface.

class megacli.MegaCLI(cli_path='/opt/MegaRAID/MegaCli/MegaCli64')
adapters()

Get MegaRAID adapters

Returns:a list of all installed MegaRAID adapters
Return type:list
bbu()

Get battery backup units

Returns:a list of all installed BBUs
Return type:list
check_init(drive, adapter)

Returns initialization status of a logical drive

Parameters:
  • drive (string) – specifies the logical drive to check
  • adapter (int) – specifies the drive’s controller
  • full (bool) – specifies whether to do a full initialize
Returns:

MegaCLI command output

Return type:

string

clear_foreign(adapter)

Clear foreign configs from an adapter

Parameters:adapter (int) – specifies the foreign config’s controller
Returns:MegaCLI command output
Return type:string
create_ld(raid_level, devices, adapter, write_policy=None, read_policy=None, cache_policy=None, cached_bad_bbu=None, size=None, stripe_size=None, hot_spares=[], after_ld=None, force=False)

Create a new logical drive

Parameters:
  • raid_level (int) – specifies the RAID level. Valid arguments: 0, 1, 5, 6 or 10.
  • devices (list) – specifies the drive enclosures and slot numbers to construct the drive group. E.g.: [‘E0:S0’, ‘E1:S1’, …]
  • write_policy (string) – specifies the device write policy. Valid arguments: WT (write through) or WB (write back)
  • read_policy (string) – specifies the device read policy. Valid arguments: NORA (no read ahead), RA (read ahead), ADRA (adaptive read ahead).
  • cache_policy (string) – specifies the device cache policy. Valid arguments: Direct, Cached.
  • cached_bad_bbu (bool) – specifies whether to use write cache when BBU is bad.
  • size (int) – specifies the capacity for the virtual drive in MB.
  • stripe_size (int) – specifies the stripe size. Valid arguments: 8, 16, 32, 64, 128, 256, 512, or 1024.
  • hot_spares (list) – specifies the device hot spares. E.g.: [‘E5:S5’, ..]
  • after_ld (string) – specifies which free slot should be used.
  • force (bool) – whether to force or not the creation of the logical drive
Returns:

MegaCLI command output

Return type:

string

enclosures()

Get enclosures

Returns:a list of all available enclosures
Return type:list
execute(cmd)

Execute a MegaCLI command

Parameters:cmd (string) – command line arguments for MegaCLI
Returns:MegaCLI command output
Return type:int
logicaldrives()

Get logical drives

Returns:a list of all configured logical drives
Return type:list
make_pd_good(drive, adapter)

Set a drive from ‘bad’ to ‘unconfigured, good’

Parameters:
  • drive (string) – specifies the enclosure:drive to set to ‘good’
  • adapter (int) – specifies the drive’s controller
Returns:

MegaCLI command output

Return type:

string

physicaldrives()

Get physical drives

Returns:a list of all installed physical drives
Return type:list
remove_ld(drive, adapter, force=False)

Delete a logical drive

Parameters:
  • drive (int) – specifies the drive to remove
  • adapter (int) – specifies the drive’s controller
  • force (bool) – specifies whether to force or not the removal of the drive
Returns:

MegaCLI command output

Return type:

string

start_init(drive, adapter, full=False)

Initializes a logical drive

Parameters:
  • drive (string) – specifies the logical drive to initialize
  • adapter (int) – specifies the drive’s controller
  • full (bool) – specifies whether to do a full initialize
Returns:

MegaCLI command output

Return type:

string

stop_init(drive, adapter)

Stops initialization on a logical drive

Parameters:
  • drive (string) – specifies the logical drive to stop initializion
  • adapter (int) – specifies the drive’s controller
  • full (bool) – specifies whether to do a full initialize
Returns:

MegaCLI command output

Return type:

string

Indices and tables