[关闭]
@tony-yin 2017-12-26T16:33:06.000000Z 字数 3890 阅读 713

Disk Common API Design

Disk Megacli


Todo List

  1. Build common API structure
  2. Card type identify
  3. Physical disk info
  4. Logical disk ino
  5. Specific API
  6. Different use process
  7. Unsupport function discard process
  8. Test

API Structure

process file: mcs3-deploy/src/mcs3/raidcardutil.py

  1. class RaidCardToolFactory() // process raid card type to determine which tool
  2. class MegaraidTool() // Megaraid type card
  3. class HBATool() // HBA type card

RaidCardToolFactory类实现了工厂模式,在这个类中通过raid卡信息然后判断实例化具体的工具类;

判断的方式是把目前系统存在的raid卡型号和对应工具制定一个map,然后对应调用;

同一个API对应不同工具都有具体的实现方式;

最后针对不同工具的返回结果集进行统一的处理,这边也需要对不同工具和对应属性key进行一个map构建

对外暴露只有一个API,以get_disk_type为例,调用方式如下:

  1. from mcs3.raidcardutils import RaidCardToolFactory // refer module
  2. tool = RaidCardToolFactory().getTool() // init class
  3. disks = tool.get_disk_type('sda') // invoke function
  4. // return 'HDD' or 'SSD'

API List

get_disk_type

mcs3-smart-monitor.py

path: /mcs3-disk-mon/usr/local/bin/

check_megacli_state

Desc: 检查raid盘的状态

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL -NoLog | grep State
  2. /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep Degraded
  3. /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep Offline
  4. /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep "Critical Disks"
  5. /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -AdpAllInfo -aALL -NoLog | grep "Failed Disks"
  6. /opt/MegaRAID/MegaCli/MegaCli64 pdlist aAll -NoLog | awk -f /usr/local/bin/summary.awk

run

line 159, line 168

Desc: 判断megacli是否安装
Usage:

  1. os.path.exists(MEGACLI_BIN)

config.py

path: /mcs3-deploy/src/mcs3/

set_osd_post_stop_command

Desc: 清除Megacli控制器缓存

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -AdpCacheFlush -Aall -NoLog

util.py

path: /mcs3-deploy/src/mcs3/

get_raid_vd

Desc: 获取raid虚拟驱动器的信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -Aall |grep -Ei "MediaType|Virtual Drive"

consolidate_raid_configure

Desc: 加固一下raid相关配置(覆盖配置),例如电池、写入模式(WT,WB etc)、cache等等

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCMD -Aall |grep Exit | tr -d "\n"
  2. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp WT -L{} -Aall
  3. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp -NoCachedBadBBU -L{} -Aall
  4. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp WT -L{} -Aall
  5. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp DisDskCache -L{} -Aall
  6. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp ADRA -L{} -Aall
  7. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp DIRECT -L{} -Aall

diskutils.py

path: /mcs3-deploy/src/mcs3/

list_local_disks

Desc: 获取本地所有磁盘信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 pdlist aAll -NoLog | awk -f /usr/local/bin/summary.awk

get_physical_disks_status

Desc: 获取所有物理磁盘部分信息(槽号和模式)

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL -NoLog | grep "Slot Number"
  2. /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL -NoLog | grep "Firmware state"

get_disk_serial_num_and_slot_num

Desc: 获取所有物理磁盘部分信息(槽号和序列号)

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 pdlist aAll -NoLog | awk -f /usr/local/bin/summary.awk

cluster_check

path: /mcs3-deploy/bin/cluster_check/

_check_raid_configure

Desc: 获取raid信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -Aall |grep -Ei "Media Type|Virtual Drive"
  2. /opt/MegaRAID/MegaCli/MegaCli64 -LDinfo -L {} -Aall|grep -Ei 'Current Cache Policy|Disk Cache Policy

_check_broken_disk

Desc: 查看raid卡信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -A0 -NoLog |grep -Ei 'Critical Disks|Failed Disks'
  2. /opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -Aall -NoLog|grep -Ei 'Virtual Drive|^State|Enclosure Device|Slot Number|Media Error Count|Other Error Count|Firmware state|flagged a S.M.A.R.T alert'

_check_ssd_duration

Desc: 获取SSD信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 -LDPDinfo -A0| grep -Ei "Virtual Drive|Enclosure Device|Slot Number|Device Id|Inquiry Data|Media Type"

raid_config_tool

path: /mcs3-deploy/bin/

get_PD_info

Desc: 获取物理磁盘信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDList -A0 | grep -Ei 'Enclosure Device|Slot Number|Media Type|Firmware state'

update_disk_group_info

Desc: 获取raid卡相关信息

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 CfgDsply -A0 |grep -Ei'Disk Group|Enclosure Device|Slot Number'

prepare_before_configure

Desc: 删除全局热备

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDHSP -Rmv -PhysDrv [{}:{}] -A0

configure_raid_common

Desc: 在线做raid

Usage:

  1. /opt/MegaRAID/MegaCli/MegaCli64 CfgLdAdd -r{}

Desc: 指定盘做全局热备

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDHSP -Set PhysDrv
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注