一袋锤子解决问题
hammers的Python项目详细描述
Percussive maintenance.
收集各种工具来保持船的形状。不是特别聪明的工具,但对第一次传球很好。
- 中子资源收割机
^{tt1}$
Reclaims idle floating IPs and cleans up stale ports.
- 矛盾的反讽/中子mac
^{tt2}$
The Ironic subnet must be provided—directly via ID or determined from a config—otherwise the script would think that they are in conflict.
- 依附于节点的不死生物实例
^{tt3}$
Nova instances that have been put to rest but still cling to Ironic nodes, preventing the next generation from being…ensouled? Checks for the inconsistency and fixed it.
- 在IPMI错误后清除
^{tt4}$
Resets Ironic nodes in error state with a known, common error. Records those resets on the node metadata (^{tt5}$ field) and refuses after a magic number of attempts.
- 更新孤立的资源提供程序
^{tt6}$
Detects and updates resource providers whose UUID has not been updated to match a recreated Nova compute node.
常用选项:
- --slack<json-options>-如果提供,用于将通知发布到slack
- --osrc<rc-file>-输入操作系统身份验证变量的另一种方法
设置/配置
- 获取代码
mkdir -p /root/scripts/hammers
cd /root/scripts/hammers
git clone https://github.com/ChameleonCloud/hammers.git
- 创造环境
virtualenv /root/scripts/hammers/venv /root/scripts/hammers/venv/bin/pip install -r /root/scripts/hammers/hammers/requirements.txt /root/scripts/hammers/venv/bin/pip install -e /root/scripts/hammers/hammers
- 为OpenStack和Slack设置凭据
下面的cronjob假设os var文件位于/root/adminrc,而slack vars位于/root/scripts/slack.json。slack文件是一个json,它有一个根键"webhook",这个根键是一个要发布到的url(保守秘密!)还有另一个根键"hostname_name",它是fqdns到漂亮名字的映射。示例:
{"webhook":"https://hooks.slack.com/services/...super-seekrit...","hostname_names":{"m01-07.chameleon.tacc.utexas.edu":"CHI@TACC","m01-03.chameleon.tacc.utexas.edu":"KVM@TACC","admin01.uc.chameleoncloud.org":"CHI@UC"}}
- 将cronjob添加到puppet:
$slack_json_loc='/root/scripts/slack.json'$osrc_loc='/root/adminrc'$venv_bin='/root/scripts/hammers/venv/bin'cron{'hammers-neutronreaper-ip':command=>"$venv_bin/neutron-reaper delete ip 14 --dbversion ocata --slack $slack_json_loc --osrc $osrc_loc [--kvm if at KVM site] 2>&1 | /usr/bin/logger -t hammers-neutronreaper-ip",user=>'root',hour=>5,minute=>20,}cron{'hammers-ironicerrorresetter':command=>"$venv_bin/ironic-error-resetter info --slack $slack_json_loc --osrc $osrc_loc 2>&1 | /usr/bin/logger -t hammers-ironicerrorresetter",user=>'root',hour=>5,minute=>25,}cron{'hammers-conflictmacs':command=>"$venv_bin/conflict-macs info --slack $slack_json_loc --osrc $osrc_loc --ignore-from-ironic-conf /etc/ironic/ironic.conf 2>&1 | /usr/bin/logger -t hammers-conflictmacs",user=>'root',hour=>5,minute=>30,}cron{'hammers-undeadinstances':command=>"$venv_bin/undead-instances info --slack $slack_json_loc --osrc $osrc_loc 2>&1 | /usr/bin/logger -t hammers-undeadinstances",user=>'root',hour=>5,minute=>35,}cron{'hammers-orphanresourceproviders':command=>"$venv_bin/orphan-resource-providers info --slack $slack_json_loc 2>&1 | /usr/bin/logger -t hammers-orphanresourceproviders",user=>'root',hour=>5,minute=>40,}