背景说明

工作中经常会遇到一次上几十台、几百台服务器的情况

每当到这个时候小伙伴们拿台笔记本和一根网线,一台服务器、一台服务器的去修改idrac IP

为了节约这个工作量,利用dell的racadm工具,写了下面这个脚本。只要运行起这个脚本,后面要做的就只是插拔网线的工作

安装racadm工具包
[root@localhost ~]# curl -s http://linux.dell.com/repo/hardware/dsu/bootstrap.cgi | bash

[root@localhost ~]# yum -y install srvadmin-all

准备工作

在采购时dell会提供一份服务器的sn列表,会根据这个列表规划好每台服务器的idrac IP,我们可以将此转换成以逗号分隔的CSV文件如下:

[root@localhost ~]# cat idrac_ip_list

AAAAAAA,10.10.10.2,255.255.255.0,10.10.10.1

BBBBBBB,10.10.10.3,255.255.255.0,10.10.10.1
脚本
[root@localhost ~]# cat set_idrac_ip.sh

#!/usr/bin/env bash

# @Author         : Eric Winn 

# @Email          : eng.eric.winn@gmail.com 

# @Time           : 2018-07-27 14:47

# @Version        : 1.0

# @File           : set_idrac_ip

# @Software       : PyCharm

# the file of idrac

idrac_ip_list_file=${1}

if [ ! -f "${idrac_ip_list_file}" ]; then

    echo "idrac_ip_list_file is not found!!!!"

    echo "$0 [idrac_ip_list_file]"

    exit 127

fi

# idrac Default infomation

idrac_default_ip=${2:-192.168.0.120}

idrac_default_user=${3:-root}

idrac_default_pass=${4:-calvin}

# racadm bin

racadm_bin=/opt/dell/srvadmin/sbin/racadm

# install check

srvadmin_install="curl -s http://linux.dell.com/repo/hardware/dsu/bootstrap.cgi | bash\nyum -y install srvadmin-all"

test ! `ls ${racadm_bin} 2> /dev/null` && printf "Please run these commands as root to install racadm.\n\e[1;31m${srvadmin_install}\e[0m\n" && exit 1

RACADM="${racadm_bin}  -r $idrac_default_ip -u $idrac_default_user -p $idrac_default_pass"

# idrac history

idrac_sn_history=()

# idrac set

set_idrac_ip(){

    # get SN

    sn=`${RACADM} get BIOS.SysInformation.SystemServiceTag  |grep SystemServiceTag |awk -F '=' '{print $2}'`

    if [ "${sn}s" == "s" ]; then

        echo "Get idrac sn is field!"

        return 1

    fi

    # We only need the first 7 characters

    sn=${sn:0:7}

    echo "sn ======> ${sn}"

    for h_sn in ${idrac_sn_history[*]}

    do

        if [ "$h_sn" == "${sn}" ]; then

            echo "The ${sn} is already set."

            return 0

        fi

    done

    # get new idrac_net from idrac_ip_list_file

    new_idrac_net=(`grep ${sn} $idrac_ip_list_file|awk -F ',' '{print $2,$3,$4}'`)

    if [ "${new_idrac_net}s" == "s" ]; then

    echo "The ${sn} is not in the ${idrac_ip_list_file}"

    return 1

    fi

    echo "Setting the new ip: ${new_idrac_net[*]}"

    # set idrac ip

    ${RACADM} setniccfg -s ${new_idrac_net[*]} | grep successfully

    if [ $? -eq 0 ]; then

        idrac_sn_history=(${idrac_sn_history[*]} ${sn})

        return 0

    else

        echo "Set is field!"

        return 1

    fi

}

# check internet

check_internet() {

    pings=""

    echo -e "Connecting ...\c"

    while [ "${pings}s" == "s" ]

    do

        pings=`ping -c 2 $idrac_default_ip  |awk 'NR==6 {print $4}'`

        if [ "${pings}s" == "s" ]; then

            echo -e ".\c"

        else

            echo

        fi

    done

    return 0

}

# main function

main() {

    while true

    do

        check_internet

        if [ $? -eq 0 ]; then

            echo "Let's starting set"

            set_idrac_ip

            if [ $? -eq 0 ]; then

                echo 

                echo "Now , Please change to a new server"

                sleep 5

            else

            echo 

                echo "Please check it."

                sleep 15

            fi

        fi

    done

}

main
运行

注:后面的idrac_ip是csv文件名

[root@localhost ~]# sh set_idrac_ip.sh idrac_ip 

Connecting ...

Let's starting set

sn ======> AAAAAAA

Setting the new ip: 10.10.10.2 255.255.255.0 10.10.10.1

Static IP configuration enabled and modified successfully                    

Now , Please change to a new server

批量自动化配置Dell服务器idrac管理口IP的更多相关文章

  1. 联想 lenove 3750 M4服务器更改启动项和管理口IP

    联想 lenove 3750 M4服务器更改启动项和管理口IP 注: 因为在机房拍照的原因,再加上工作比较忙:整理成文档的时候有的过程已经忘记了,所以有的步骤可能会缺失,里面的选项都已经用中文方式表达 ...

  2. Linux下搭建Oracle11g RAC(2)----配置DNS服务器,确认SCAN IP可以被解析

    从Oracle 11gR2开始,引入SCAN(Single Client Access Name) IP的概念,相当于在客户端和数据库之间增加一层虚拟的网络服务层,即是SCAN IP和SCAP IP  ...

  3. DELL服务器iDRAC相关设置

    iDRAC又称为Integrated Dell Remote Access Controller,也就是集成戴尔远程控制卡 iDRAC卡相当于是附加在服务器上的一台小电脑,通过与服务器主板上的管理芯片 ...

  4. zabbix3.2通过snmp v2采集Dell服务器iDRAC口信息监控硬件

    模板下载 https://files.cnblogs.com/files/LuckWJL/zbx_export_templates.xml 模板源代码 <?xml version="1 ...

  5. Dell服务器iDrac口默认账号密码和IP

    https://blog.csdn.net/artdao1987/article/details/79875528

  6. 戴尔 R730xd 服务器更改管理口密码 图文教程

    一.开机根据提示按F2进入配置界面 - 选择中间的iDRAC Setting选项,回车确认 二.进入之后选择 user configuration 选项 三.在change password 处键入新 ...

  7. DELL服务器管理工具和RACADM介绍

    DELL服务器管理工具和RACADM介绍 一.Dell服务器管理工具介绍 Dell对服务器(DELL PowerEdge)的管理主要提供了三种管理工具,分别是Dell Remote Access Co ...

  8. dell服务器快速设置idrac

    前提:将服务器专用的idrac网络接口,连接到网络上 1.登录到服务器(即被监控的服务器). 2.安装客户端工具 yum  install  OpenIPMI OpenIPMI-devel OpenI ...

  9. puppet开源的软件自动化配置和部署工具——本质就是CS,服务端统一管理配置

    1.  概述 puppet是一个开源的软件自动化配置和部署工具,它使用简单且功能强大,正得到了越来越多地关注,现在很多大型IT公司均在使用puppet对集群中的软件进行管理和部署,如google利用p ...

随机推荐

  1. 观察者模式(Observer模式)

    模式的定义与特点 观察者(Observer)模式的定义:指多个对象间存在一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并被自动更新.这种模式有时又称作发布-订阅模式.模型- ...

  2. [WAF攻防]从WAF攻防角度重看sql注入

    从WAF攻防角度重看sql注入 攻防都是在对抗中逐步提升的,所以如果想攻,且攻得明白,就必须对防有深刻的了解 sql注入的大体流程 Fuzz测试找到注入点 对注入点进行过滤检测,及WAF绕过 构建pa ...

  3. MySQL数据库本地事务原理

    在经典的数据库理论里,本地事务具备四大特征: 原子性 事务中的所有操作都是以原子的方式执行的,要么全部成功,要么全部失败: 一致性 事务执行前后,所有的数据都应该处于一致性状态---即要满足数据库表的 ...

  4. Python中open函数怎么操作文件--9

    转:https://www.tuicool.com/wx/vYjaYnV 在 Python 中,如果想要操作文件,首先需要创建或者打开指定的文件,并创建一个文件对象,而这些工作可以通过内置的 open ...

  5. 学习Java第4天

    今天所作的工作: 1.类 2.类的构造方法 3.静态变量 4.类的主方法 5.对象 今天没有完成昨天的工作安排,因为发现进入类之后的编程思想发生的变化,相对与c++的逻辑既有较大的相似性又有不同的性质 ...

  6. linux apache软件安装

    安装提示 Linux下,源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(make install). 过程中用到"configure --prefix=安装 ...

  7. Codeforces Round #740 Div. 2

    题目跳转链接 A. Simply Strange Sort 题意 定义一个函数\(f_{i}\) : 如果\(a_i \ge a_{i+1}\) swap(\(a_i\) \(a_{i+1}\)) 定 ...

  8. String类为什么可以直接赋值

    在研究String直接赋值与new String的区别之前我们需要先了解java中的字符串常量池的概念 字符串常量池 String类是我们平常项目中使用频率非常高的一种对象类型,jvm为了提升性能和减 ...

  9. HttpClient的NoHttpResponse问题

       调用第三方接口时会报NoHttpResponse异常,原因是上次的连接已经断掉了,但是客户端并未知道,复用上次连接就报错了,所以要解决这个问题,就是要校验上次链接是否断掉了  1. httpCl ...

  10. lua语言:时间

    转载请注明来源:https://www.cnblogs.com/hookjc/ 时间库函数 1.用数值表示时间值 用数字值来表示时间值,实际上时间值的本质就是一个数字值.例如:d = 11312864 ...