{"id":148297,"date":"2019-06-26T09:49:25","date_gmt":"2019-06-26T01:49:25","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=148297"},"modified":"2019-06-20T09:50:58","modified_gmt":"2019-06-20T01:50:58","slug":"dell-idrac-ip","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/dell-idrac-ip.html","title":{"rendered":"\u6279\u91cf\u81ea\u52a8\u5316\u914d\u7f6eDell\u670d\u52a1\u5668idrac\u7ba1\u7406\u53e3IP"},"content":{"rendered":"
\u80cc\u666f\u8bf4\u660e<\/strong><\/span><\/div>\n

\u5de5\u4f5c\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u6b21\u4e0a\u51e0\u5341\u53f0\u3001\u51e0\u767e\u53f0\u670d\u52a1\u5668\u7684\u60c5\u51b5<\/p>\n

\u6bcf\u5f53\u5230\u8fd9\u4e2a\u65f6\u5019\u5c0f\u4f19\u4f34\u4eec\u62ff\u53f0\u7b14\u8bb0\u672c\u548c\u4e00\u6839\u7f51\u7ebf\uff0c\u4e00\u53f0\u670d\u52a1\u5668\u3001\u4e00\u53f0\u670d\u52a1\u5668\u7684\u53bb\u4fee\u6539idrac IP<\/p>\n

\u4e3a\u4e86\u8282\u7ea6\u8fd9\u4e2a\u5de5\u4f5c\u91cf\uff0c\u5229\u7528dell\u7684racadm\u5de5\u5177\uff0c\u5199\u4e86\u4e0b\u9762\u8fd9\u4e2a\u811a\u672c\u3002\u53ea\u8981\u8fd0\u884c\u8d77\u8fd9\u4e2a\u811a\u672c\uff0c\u540e\u9762\u8981\u505a\u7684\u5c31\u53ea\u662f\u63d2\u62d4\u7f51\u7ebf\u7684\u5de5\u4f5c<\/p>\n

\u5b89\u88c5racadm\u5de5\u5177\u5305<\/strong><\/span><\/div>\n
\r\n[root@localhost ~]# curl -s http:\/\/linux.dell.com\/repo\/hardware\/dsu\/bootstrap.cgi | bash\r\n\r\n[root@localhost ~]# yum -y install srvadmin-all\r\n<\/pre>\n

\u200b<\/p>\n

\u51c6\u5907\u5de5\u4f5c<\/strong><\/span><\/div>\n

\u5728\u91c7\u8d2d\u65f6dell\u4f1a\u63d0\u4f9b\u4e00\u4efd\u670d\u52a1\u5668\u7684sn\u5217\u8868\uff0c\u4f1a\u6839\u636e\u8fd9\u4e2a\u5217\u8868\u89c4\u5212\u597d\u6bcf\u53f0\u670d\u52a1\u5668\u7684idrac IP\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6b64\u8f6c\u6362\u6210\u4ee5\u9017\u53f7\u5206\u9694\u7684CSV\u6587\u4ef6\u5982\u4e0b\uff1a<\/p>\n

\r\n[root@localhost ~]# cat idrac_ip_list\r\n\r\nAAAAAAA,10.10.10.2,255.255.255.0,10.10.10.1\r\n\r\nBBBBBBB,10.10.10.3,255.255.255.0,10.10.10.1\r\n<\/pre>\n
\u811a\u672c<\/strong><\/span><\/div>\n
\r\n[root@localhost ~]# cat set_idrac_ip.sh\r\n\r\n#!\/usr\/bin\/env bash\r\n\r\n# @Author         : Eric Winn \r\n\r\n# @Email          : eng.eric.winn@gmail.com \r\n\r\n# @Time           : 2018-07-27 14:47\r\n\r\n# @Version        : 1.0\r\n\r\n# @File           : set_idrac_ip\r\n\r\n# @Software       : PyCharm\r\n\r\n# the file of idrac\r\n\r\nidrac_ip_list_file=${1}\r\n\r\nif [ ! -f \"${idrac_ip_list_file}\" ]; then\r\n\r\n    echo \"idrac_ip_list_file is not found!!!!\"\r\n\r\n    echo \"$0 [idrac_ip_list_file]\"\r\n\r\n    exit 127\r\n\r\nfi\r\n\r\n# idrac Default infomation\r\n\r\nidrac_default_ip=${2:-192.168.0.120}\r\n\r\nidrac_default_user=${3:-root}\r\n\r\nidrac_default_pass=${4:-calvin}\r\n\r\n# racadm bin\r\n\r\nracadm_bin=\/opt\/dell\/srvadmin\/sbin\/racadm\r\n\r\n# install check\r\n\r\nsrvadmin_install=\"curl -s http:\/\/linux.dell.com\/repo\/hardware\/dsu\/bootstrap.cgi | bash\\nyum -y install srvadmin-all\"\r\n\r\ntest ! `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\r\n\r\nRACADM=\"${racadm_bin}  -r $idrac_default_ip -u $idrac_default_user -p $idrac_default_pass\"\r\n\r\n# idrac history\r\n\r\nidrac_sn_history=()\r\n\r\n# idrac set\r\n\r\nset_idrac_ip(){\r\n\r\n    # get SN\r\n\r\n    sn=`${RACADM} get BIOS.SysInformation.SystemServiceTag  |grep SystemServiceTag |awk -F '=' '{print $2}'`\r\n\r\n    if [ \"${sn}s\" == \"s\" ]; then\r\n\r\n        echo \"Get idrac sn is field!\"\r\n\r\n        return 1\r\n\r\n    fi\r\n\r\n    # We only need the first 7 characters\r\n\r\n    sn=${sn:0:7}\r\n\r\n    echo \"sn ======> ${sn}\"\r\n\r\n    for h_sn in ${idrac_sn_history[*]}\r\n\r\n    do\r\n\r\n        if [ \"$h_sn\" == \"${sn}\" ]; then\r\n\r\n            echo \"The ${sn} is already set.\"\r\n\r\n            return 0\r\n\r\n        fi\r\n\r\n    done\r\n\r\n    # get new idrac_net from idrac_ip_list_file\r\n\r\n    new_idrac_net=(`grep ${sn} $idrac_ip_list_file|awk -F ',' '{print $2,$3,$4}'`)\r\n\r\n    if [ \"${new_idrac_net}s\" == \"s\" ]; then\r\n\r\n    echo \"The ${sn} is not in the ${idrac_ip_list_file}\"\r\n\r\n    return 1\r\n\r\n    fi\r\n\r\n    echo \"Setting the new ip: ${new_idrac_net[*]}\"\r\n\r\n    # set idrac ip\r\n\r\n    ${RACADM} setniccfg -s ${new_idrac_net[*]} | grep successfully\r\n\r\n    if [ $? -eq 0 ]; then\r\n\r\n        idrac_sn_history=(${idrac_sn_history[*]} ${sn})\r\n\r\n        return 0\r\n\r\n    else\r\n\r\n        echo \"Set is field!\"\r\n\r\n        return 1\r\n\r\n    fi\r\n\r\n}\r\n\r\n# check internet\r\n\r\ncheck_internet() {\r\n\r\n    pings=\"\"\r\n\r\n    echo -e \"Connecting ...\\c\"\r\n\r\n    while [ \"${pings}s\" == \"s\" ]\r\n\r\n    do\r\n\r\n        pings=`ping -c 2 $idrac_default_ip  |awk 'NR==6 {print $4}'`\r\n\r\n        if [ \"${pings}s\" == \"s\" ]; then\r\n\r\n            echo -e \".\\c\"\r\n\r\n        else\r\n\r\n            echo\r\n\r\n        fi\r\n\r\n    done\r\n\r\n    return 0\r\n\r\n}\r\n\r\n# main function\r\n\r\nmain() {\r\n\r\n    while true\r\n\r\n    do\r\n\r\n        check_internet\r\n\r\n        if [ $? -eq 0 ]; then\r\n\r\n            echo \"Let's starting set\"\r\n\r\n            set_idrac_ip\r\n\r\n            if [ $? -eq 0 ]; then\r\n\r\n                echo \r\n\r\n                echo \"Now , Please change to a new server\"\r\n\r\n                sleep 5\r\n\r\n            else\r\n\r\n            echo \r\n\r\n                echo \"Please check it.\"\r\n\r\n                sleep 15\r\n\r\n            fi\r\n\r\n        fi\r\n\r\n    done\r\n\r\n}\r\n\r\nmain\r\n<\/pre>\n
\u8fd0\u884c<\/strong><\/span><\/div>\n

\u6ce8\uff1a\u540e\u9762\u7684idrac_ip\u662fcsv\u6587\u4ef6\u540d<\/p>\n

\r\n\r\n[root@localhost ~]# sh set_idrac_ip.sh idrac_ip \r\n\r\nConnecting ...\r\n\r\nLet's starting set\r\n\r\nsn ======> AAAAAAA\r\n\r\nSetting the new ip: 10.10.10.2 255.255.255.0 10.10.10.1\r\n\r\nStatic IP configuration enabled and modified successfully                    \r\n\r\nNow , Please change to a new server\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u5de5\u4f5c\u4e2d\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u6b21\u4e0a\u51e0\u5341\u53f0\u3001\u51e0\u767e\u53f0\u670d\u52a1\u5668\u7684\u60c5\u51b5 \u6bcf\u5f53\u5230\u8fd9\u4e2a\u65f6\u5019\u5c0f\u4f19\u4f34\u4eec\u62ff\u53f0\u7b14\u8bb0\u672c\u548c\u4e00\u6839\u7f51\u7ebf\uff0c\u4e00\u53f0\u670d\u52a1\u5668\u3001\u4e00\u53f0 […]<\/p>\n","protected":false},"author":1479,"featured_media":148300,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-148297","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/148297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=148297"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/148297\/revisions"}],"predecessor-version":[{"id":148734,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/148297\/revisions\/148734"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/148300"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=148297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=148297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=148297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}