• 產品與解決方案
  • 行業解決方案
  • 服務
  • 支持
  • 合作夥伴
  • 關於我們

01-基礎配置舉例

目錄

06-H3C_IRF零配置舉例

本章節下載 06-H3C_IRF零配置舉例  (278.84 KB)

06-H3C_IRF零配置舉例

H3C IRF零配置典型舉例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

資料版本:6W100-20200330

產品版本:Release 7585P05

 

Copyright © 2020 bobty下载软件 版權所有,保留一切權利。

非經本公司書麵許可,任何單位和個人不得擅自摘抄、複製本文檔內容的部分或全部,並不得以任何形式傳播。

除bobty下载软件 的商標外,本手冊中出現的其它公司的商標、產品標識及商品名稱,由各自權利人擁有。

本文檔中的信息可能變動,恕不另行通知。

 



1  簡介

本文檔主要介紹了如何通過自動配置和Python功能使設備自動組成IRF。

2  配置前提

本文檔中的配置均是在實驗室環境下進行的配置和驗證,配置前設備的所有參數均采用出廠時的缺省配置。如果您已經對設備進行了配置,為了保證配置效果,請確認現有配置和以下舉例中的配置不衝突。

本文檔假設使用的設備均處於獨立運行模式。

本文檔假設您已了解IRF、Python和自動配置的特性。

3  使用限製

隻有相同型號的機框之間才能建立IRF。建議您在進行IRF零配置時的所有成員設備上均使用相同的單板配置方案,即選用的單板數量及型號、安裝槽位號、以及對應 單板的工作模式設置等都保持一致。

4  配置舉例

4.1  組網需求

圖1所示,某公司兩台設備Device A和Device B放置在距離網絡管理員較遠的地方,所有設備的物理連接已經完成。為了簡少網絡配置的工作量,需要該公司的管理員通過設備的IRF零配置功能對兩台設備進行一定的初始配置。現要求通過IRF零配置實現以下功能:

·            Device A和Device B自動組成IRF。

·            網絡管理員能夠通過Telnet方式遠程登錄Device A和Device B組成的IRF設備。

·            登錄Device A和Device B虛擬成的IRF設備時需要密碼認證。

圖1 IRF零配置組網圖

4.2  配置思路

·            為了保證IRF零配置的成功執行,需要在Device A和Device B上電啟動之前按圖1所示將網絡環境搭建完成,將進行IRF零配置所需的文件準備好並存儲在HTTP服務器上,同時要保證DHCP服務器上已經配置完成。Device A和Device B啟動時會先從HTTP server下載Python腳本,然後根據Python腳本中的命令控製整個IRF零配置的流程。關於IRF零配置的所需文件的詳細介紹,請參見“4.3.2  準備HTTP Server上的配置文件

·            當設備初次上電會自動進入自動配置的流程;當設備中不存在下次啟動配置文件的時候,設備啟動以後也可以進入到自動配置的流程。

·            為了使設備能成功組成IRF,必須保證Device A和Device B所使用的軟件版本相同,所以Python腳本中添加了為Device A和Device B加載相同的啟動軟件版本的內容。

4.3  配置步驟

4.3.1  Device C的配置

# 啟動DHCP服務,創建名稱為1的DHCP地址池,配置地址池動態分配IP地址的網段為192.168.1.0/24。

<DeviceC> system-view

[DeviceC] dhcp enable

[DeviceC] dhcp server ip-pool 1

[DeviceC-dhcp-pool-1] network 192.168.1.0 24

# 配置DHCP客戶端遠程啟動文件為HTTP形式的URL。

[DeviceC-dhcp-pool-1] bootfile-name http://192.168.1.40/device.py

[DeviceC-dhcp-pool-1] quit

4.3.2  準備HTTP Server上的配置文件

(1)       創建Python腳本device.py並保存到HTTP服務器上。Python腳本是設備進行IRF零配置操作的主要文件,需要用戶自行準備並保存在HTTP服務器上。Python腳本需要完成的主要操作:

·            判斷Flash是否存在足夠的存儲空間(請用戶根據實際情況進行判斷);

·            從HTTP服務器下載配置文件;

·            從HTTP服務器下載啟動軟件包;

·            從HTTP服務器下載sn.txt文件;

·            配置設備下次啟動時使用的啟動軟件包;

·            解析sn.txt文件並修改設備的IRF成員編號;

·            配置設備下次啟動時使用的配置文件;

·            重新啟動設備。

Python腳本的具體內容如下(Python腳本中標注有簡單的中文注釋,使用時請將中文注釋刪除):

#!usr/bin/python

 

import comware

from time import strftime,gmtime,sleep

import signal

import os

import string

import commands

import hashlib

 

#python_config_file_mode

#'python_static'

#python_serial_number

#U can use 2 modes to obtain the config file

#- 'python_static'

#- 'python_serial_number'

python_config_file_mode = "python_serial_number"

 

#配置本次軟件升級設備flash所需的最小剩餘空間,單位為KB

#Required space to copy config kickstart and system image in KB

required_space = 150000

 

#配置HTTP服務器的相關參數:用戶名、密碼、HTTP服務器IP地址、VPN實例名稱、登錄的超時時間

#transfer information

username = ""

password = ""

hostname = "192.168.1.40"

protocol = "http"

vrf = ""

config_timeout = 120

irf_timeout = 120

image_timeout = 2100

 

#HTTP服務器的下載路徑

#Server File Path

server_path = ""

 

#下載到本地設備時,存放到Flash根目錄下

#Loacl File path

local_path = "flash:/"

 

#下載到設備之後的配置文件名

#Local config name

config_local_name = "startup.cfg"

 

#HTTP服務器上的配置文件名

#Server config name

config_server_name = "startup.cfg"

 

#下載到本地的啟動軟件包

#Local boot name

boot_local_name = "s10500.ipe"

 

#HTTP服務器上的啟動軟件包

#Server boot name

boot_server_name = "s10500.ipe"

 

#下載到本地的SN文件名

#Local irf name

irf_local_name = "sn.txt"

 

#HTTP服務器上的sn文件名

#Server irf name

irf_server_name = "sn.txt"

 

#設備本地上記錄升級日誌的log文件名

python_log_name = ""

 

#在設備上記錄升級日誌的方法

#Write Log File

def write2Log(info):

  global python_log_name, local_path

  if python_log_name == "":

    try:

      python_log_name = "%s%s_python_%s_script.log" %(local_path, strftime("%Y%m%d%H%M%S", gmtime()), os.getpid())

    except Exception as inst:

      print inst

  fd = open(python_log_name, "a")

  fd.write(info)

  fd.flush()

  fd.close()

 

#獲取設備的chassis號和slot號,與前麵定義的local_path變量,共同計算出文件本地的存放路徑

# get path according to the Chassis and Slot

def getPath(chassisID, slotID):

  global local_path

  path = ""

  obj = comware.get_self_slot()

  if (obj[0] == chassisID) and (obj[1] == slotID):

    return local_path

  if chassisID != -1:

    path = "chassis%d#" % chassisID

  if slotID != -1:

    path = "%sslot%d#%s" %(path, slotID, local_path)

  return path

 

#刪除下載到本地的文件

#Remove File

def removeFile(filename):

  try:

    os.remove(filename)

  except os.error:

    pass

 

#計算該設備需要刪除的文件數量

#Cleanup one device temp files

def cleanDeviceFiles(str, oDevNode):

  global config_local_name, boot_local_name, irf_local_name

  sFilePath = getPath(oDevNode[0], oDevNode[1])

  if str == "error":

    removeFile("%s%s" %(sFilePath, config_local_name))

  removeFile("%s%s" %(sFilePath, boot_local_name))

  removeFile("%s%s" %(sFilePath, irf_local_name))

  removeFile("%s%s.md5" %(sFilePath, config_local_name))

  removeFile("%s%s.md5" %(sFilePath, boot_local_name))

  removeFile("%s%s.md5" %(sFilePath, irf_local_name))

  write2Log("\ndelete %s all files\n" %sFilePath)

  print "\ndelete %s all files" %sFilePath

 

#Cleanup files

def cleanupFiles(str):

  aSlotRange = []

  if ("get_standby_slot" in dir(comware)):

    aSlotRange = aSlotRange + comware.get_standby_slot()

 

  aSlotRange.append(comware.get_self_slot())

  i = 0

  while i < len(aSlotRange):

    if(aSlotRange[i] != None):

      cleanDeviceFiles(str, aSlotRange[i])

    i = i + 1

 

#計算設備flash上的剩餘空間大小

#Verify if free space is available to download config, boot-loader image

def verifyfreespace(path):

  global required_space

  try:

    s = os.statvfs(path)

    freespace = (s.f_bavail * s.f_frsize) /1024

    write2Log("\nthe %s free space is %s" %(path, freespace))

    print "\n####the %s free space is %s####" %(path, freespace)

    if required_space > freespace:

      write2Log("\nthe %s space is not enough" % path)

      print "\n####the %s space is not enough####" % path

      return False

  except Exception as inst:

    write2Log("\nverify %s free space exception: %s" % (path, inst))

    print "\n####verify %s free space exception: %s####" % (path, inst)

    return False

  return True

 

#判斷設備上的剩餘空間是否充足

#verify device freespace

def verifyDeviceFree(obj):

  path = getPath(obj[0], obj[1])

  if True != verifyfreespace(path):

    return False

  return True

 

#check all mpu free space

def verifyAllFreeSpace():

  aSlotRange = []

  if ("get_standby_slot" in dir(comware)):

    aSlotRange = aSlotRange + comware.get_standby_slot()

 

  aSlotRange.append(comware.get_self_slot())

  bAllEnough = True

  i = 0

  while i < len(aSlotRange):

    if(aSlotRange[i] != None) and (True != verifyDeviceFree(aSlotRange[i])):

      bAllEnough = False

    i = i + 1

  return bAllEnough

 

def doExit(str):

  if str == "success":

    write2Log("\nThe script is running success!")

    print "\n#### The script is running success! ####"

    cleanupFiles("success")

    comd = "reboot force"

    comware.CLI(comd, False)

    exit(0)

  if str == "error":

    write2Log("\nThe script is running failed!")

    print "\n#### The script is running failed! ####"

    cleanupFiles("error")

    exit(1)

  else:

    exit(0)

 

#獲取軟件升級時chassis號和slot號參數

#get Chassis and Slot

def getChassisSlot(style):

  if style == "master":

    obj = comware.get_self_slot()

  if len(obj) <= 0:

    write2Log("\nget %s chassis and slot failed" % style)

    print "\n####get %s chassis and slot failed####" % style

    return None

  return obj

 

#獲取啟動軟件包發生錯誤返回的信息

#signal terminal handler function

def sig_handler_no_exit(signum, function):

  write2Log("\nSIGTERM Handler while configuring boot-loader variables")

  print "\n####SIGTERM Handler while configuring boot-loader variables####"

 

#軟件升級過程發生錯誤時返回的信息

#signal terminal handler

def sigterm_handler(signum, function):

  write2Log("\nSIGTERM Handler")

  print "\n####SIGTERM Handler####"

  cleanupFiles("error")

  doExit("error")

 

#從HTTP服務器上下載文件

#transfer file

def doCopyFile(src = "", des = "", login_timeout = 10):

  global username, password, hostname, protocol, vrf

  print "INFO: Starting Copy of %s" % src

  try:

    removeFile(des)

    obj = comware.Transfer(protocol, hostname, src, des, vrf, login_timeout, username, password)

    if obj.get_error() != None:

      write2Log("\ncopy %s failed: %s" % (src, obj.get_error()))

      print "\n####copy %s failed: %s####" % (src, obj.get_error())

      return False

  except Exception as inst:

    write2Log("\ncopy %s exception: %s" % (src, inst))

    print "\n####copy %s exception: %s####" % (src, inst)

    return False

  write2Log("\ncopy file %s to %s success" % (src, des))

  print "INFO: Completed Copy of %s" % src

  return True

 

#Get MD5SUM from md5ConfigFile

def getMD5SumGiven(keyword, filename):

  try:

    file = open(filename, "r")

    line = file.readline()

    while "" != line:

      if not string.find(line, keyword, 0, len(keyword)):

        line = line.split("=")

        line = line[1]

        line = line.strip()

        file.close()

        return line

      line = file.readline()

    file.close()

  except Exception as inst:

    write2Log("\nget %s md5 exception: %s" % (filename, inst))

    print "\n####get %s md5 exception: %s####" % (filename, inst)

  return ""

 

#verify MD5SUM of the file

def verifyMD5sumofFile(md5sumgiven, filename):

  if md5sumgiven == "":

    write2Log("\nverify %s md5 error: the %s md5 file is error" %(filename, filename))

    print "\n####verify %s md5 error: the %s md5 file is error####" %(filename, filename)

    return False

  try:

    m = hashlib.md5()

    f = open(filename, 'rb')

    buffer = 8192

    while 1:

      chunk = f.read(buffer)

      if not chunk:

        break

      m.update(chunk)

    f.close()

    md5calculated = m.hexdigest()

  except Exception as inst:

    write2Log("\nverify %s md5 exception: %s" % (filename, inst))

    print "\n####verify %s md5 exception: %s####" % (filename, inst)

    return False

  if md5sumgiven == md5calculated:

    return True

  write2Log("\nverify %s md5 error: md5sumgiven is %s filemd5 is %s" %(filename, md5sumgiven, md5calculated))

  print "\n####verify %s md5 error: md5sumgiven is %s filemd5 is %s####" %(filename, md5sumgiven, md5calculated)

  return False

 

#Check MD5 file

def checkFile(src, dest):

  src = "%s.md5" % src

  destmd5 = "%s.md5" % dest

  bFlag = doCopyFile(src, destmd5, 120)

  if (True == bFlag) and (True == verifyMD5sumofFile(getMD5SumGiven("md5sum", destmd5), dest)):

    write2Log("\ncheckFile success: %s" % destmd5)

    print "\n####checkFile success: %s####" % destmd5

    return True

  elif (True != bFlag):

    write2Log("\n%s is not exist! Don't verify the MD5 file!" % destmd5)

    print "INFO: %s is not exist! Don't verify the MD5 file!" % destmd5

    return True

  return False

 

#Get config file according to the mode

def getCfgFileName():

  global config_server_name

  if (python_config_file_mode == "python_serial_number") and (os.environ.has_key('DEV_SERIAL')):

    config_server_name = "%s.cfg" % os.environ['DEV_SERIAL']

    return config_server_name

  else:

    return config_server_name

 

#copy file to all standby slot

def syncFileToStandby(sSrcFile, sFileName):

  try:

    aSlotRange = []

    if ("get_standby_slot" in dir(comware)):

      aSlotRange = aSlotRange + comware.get_standby_slot()

      

    i = 0

    while i < len(aSlotRange):

      if(aSlotRange[i] != None):

        sDestFile = "%s%s" %(getPath(aSlotRange[i][0], aSlotRange[i][1]), sFileName)

        removeFile(sDestFile)

        open(sDestFile,"wb").write(open(sSrcFile,"rb").read())

        write2Log("\nsync file to standby %s" % (sDestFile))

        print "\n####sync file to standby %s####" % (sDestFile)

      i = i + 1

  except Exception as inst:

    write2Log("\nsync file to standby %s exception: %s" % (sSrcFile, inst))

    print "\n####sync file to standby %s exception: %s####" % (sSrcFile, inst)

 

#根據腳本開始處定義的全局變量,下載啟動軟件包、配置文件、sn文件等

#Procedure to copy config file using global information

def copyAndCheckFile(src, dest, timeout):

  global server_path, local_path

  srcTmp = "%s%s" % (server_path, src)

  sDestFile = "%s%s" % (local_path, dest)

  if (True == doCopyFile(srcTmp, sDestFile, timeout)) and (True == checkFile(srcTmp, sDestFile)):

    syncFileToStandby(sDestFile, dest)

    return True

  else:

    srcTmp = "%sdefault_%s" %(server_path, src)

    if (True == doCopyFile(srcTmp, sDestFile, timeout)) and (True == checkFile(srcTmp, sDestFile)):

      syncFileToStandby(dest)

      return True

  return False

 

# split the Chassis and Slot

def splitChassisSlot(chassisID, slotID):

  chassis_slot = ""

  if chassisID != -1:

    chassis_slot = " chassis %d"  % chassisID

  if slotID != -1:

    chassis_slot = "%s slot %d" %(chassis_slot, slotID)

  return chassis_slot

 

#從HTTP服務器上下載啟動軟件包

def copyBootImage():

  global image_timeout, local_path, boot_server_name, boot_local_name

  src = "%s" % boot_server_name

  return copyAndCheckFile(src, boot_local_name, image_timeout)

 

#從HTTP服務器上下載配置文件

def copyCfgFile():

  global config_timeout, local_path, config_local_name

  src = "%s" % getCfgFileName()

  return copyAndCheckFile(src, config_local_name, config_timeout)

 

#從HTTP服務器上下載sn.txt文件

def copyIrfStack():

  global irf_timeout, local_path, irf_local_name, irf_server_name

  src = "%s" % irf_server_name

  return copyAndCheckFile(src, irf_local_name, config_timeout)

 

#執行boot-loader命令,為設備指定下次主用啟動文件

# Procedure to Install Boot Image

def installBoot(chassis_slot, sFile, style):

  result = None

  write2Log("\ninstall%s%s begin" %(chassis_slot, style))

  print "INFO: Install%s%s Start, Please Wait..." %(chassis_slot, style)

  comd = "boot-loader file %s%s%s" % (sFile, chassis_slot, style)

  try:

    result = comware.CLI(comd, False)

    if result == None:

      write2Log("\nboot-loader file %s%s%s failed" % (sFile, chassis_slot, style))

      print "\n####boot-loader file %s%s%s failed####" % (sFile, chassis_slot, style)

      return False

  except Exception as inst:

    write2Log("\nboot-loader %s exception: %s" % (sFile, inst))

    print "\n####boot-loader %s exception: %s####" % (sFile, inst)

    return False

  return True

 

#Procedure to install boot image

def installBootImage():

  global boot_local_name

  aSlotRange = [comware.get_self_slot()]

  if ("get_standby_slot" in dir(comware)):

    aSlotRange = aSlotRange + comware.get_standby_slot()

  bInstallOk = True

  i = 0

  while i < len(aSlotRange):

    sFile = "%s%s" %(getPath(aSlotRange[0][0], aSlotRange[0][1]), boot_local_name)

    if False == installBoot(splitChassisSlot(aSlotRange[i][0], aSlotRange[i][1]), sFile, " main"):

      bInstallOk = False

    i = i + 1

  return bInstallOk

 

#執行startup saved-configuration命令為設備指定下次啟動配置文件

def startupCfg():

  global local_path, config_local_name

  result = None

  dest = "%s%s" %(local_path, config_local_name)

  write2Log("\nstartup saved-configuration %s begin" %dest)

  print "INFO: Startup Saved-configuration Start"

  comd = "startup saved-configuration %s main" % dest

  try:

    result = comware.CLI(comd, False)

    if result == None:

      write2Log("\nstartup saved-configuration %s failed" % dest)

      print "\n####startup saved-configuration %s failed####" % dest

      return False

  except Exception as inst:

    write2Log("\nstartup %s exception: %s" % (dest, inst))

    print "\n####startup %s exception: %s####" % (dest, inst)

    return False

  write2Log("\nstartup saved-configuration %s success" % dest)

  print "INFO: Completed Startup Saved-configuration"

  return True

 

def getIrfCfg(line, num):

  line = line.split()

  number = None

  if 3 == len(line):

    number = line[num]

  else :

    number = None

  return number

 

def getMemberID():

  aMemId = comware.get_self_slot()

  memId = None

  if aMemId[0] == -1 :

    memId = aMemId[1]

  else :

    memId = aMemId[0]

  return memId

 

def getNewMemberID():

  global irf_local_name, local_path, env

  filename = "%s%s" %(local_path, irf_local_name)

  serNum = os.environ['DEV_SERIAL']

  reNum = None

  try:

    file = open(filename, "r")

    line = file.readline()

    while "" != line:

      if (serNum == getIrfCfg(line, 0)):

        file.close()

        reNum = getIrfCfg(line, 2)

        return reNum

      line = file.readline()

    file.close()

  except Exception as inst:

    write2Log("\nget renumberID exception: %s" % inst)

    print "\n####get renumberID exception: %s####" % inst

  write2Log("\nget %s renumberID failed" % filename)

  print "\n#### get %s renumberID failed ####" % filename

  return reNum

 

#判斷設備是否是處於已經建立IRF

def isIrfDevice():

  try:

    result = comware.CLI("display irf", False)

    if result == None:

      return False

  except Exception as inst:

    return False

  return True

 

#解析sn.txt文件並使用renumber修改設備的IRF成員編號

def getIrfComd():

  comd = None

  newMemberID = getNewMemberID()

  aMemId = comware.get_self_slot()

  if None == newMemberID:

    return None

  if False == isIrfDevice():

    comd = "system-view ; irf member %s ; chassis convert mode irf" % newMemberID

  else:

    comd = "system-view ; irf member %s renumber %s" % (getMemberID(), newMemberID)

  return comd

 

def stackIrfCfg():

  global env

  if (not os.environ.has_key('DEV_SERIAL')):

    write2Log("\nenviron variable 'DEV_SERIAL' is not found!")

    print "\n####environ variable 'DEV_SERIAL' is not found!####"

    return False

  comd = getIrfComd()

  if None == comd:

    return False

  result = None

  write2Log("\nstartup stack irf begin")

  print "INFO: Startup stack irf Start"

  try:

    result = comware.CLI(comd, False)

    if result == None:

      write2Log("\nstartup stack irf failed: %s" % comd)

      print "\n####startup stack irf failed: %s####" %comd

      return False

  except Exception as inst:

    write2Log("\nstartup stack irf exception: %s command: %s" % (inst, comd))

    print "\n####startup stack irf exception: %s command: %s####" % (inst, comd)

    return False

  write2Log("\nstartup stack irf success")

  print "INFO: Completed Startup Stack Irf"

  return True

 

#check if all standby slots are ready

def ifAllStandbyReady():

  if (("get_slot_range" in dir(comware)) == False):

    return True

      

  aSlotRange = comware.get_slot_range()

  bAllReady = True

  for i in range(aSlotRange["MinSlot"], aSlotRange["MaxSlot"]):

    oSlotInfo =  comware.get_slot_info(i)

    if (oSlotInfo != None) and (oSlotInfo["Role"] == "Standby") and (oSlotInfo["Status"] == "Fail"):

      bAllReady = False

      write2Log("\nSlot %s is not ready!" %i)

      print "\n####Slot %s is not ready!####" %i

  return bAllReady

 

#if have any standby slot was not ready sleep for waiting

def waitStandbyReady():

  while ifAllStandbyReady() == False:

    sleep(10)

 

#python main

 

#when download file user can stop script

waitStandbyReady()

signal.signal(signal.SIGTERM, sigterm_handler)

 

if (True == verifyAllFreeSpace()) and (True == copyBootImage()) and (True == copyCfgFile()) and (True == copyIrfStack()):

  #after download file user can not stop script

  signal.signal(signal.SIGTERM, sig_handler_no_exit)

  if (True == installBootImage()) and (True == startupCfg()) and (True == stackIrfCfg()):

    doExit("success")

doExit("error")

 

(2)       創建配置文件serial_number.cfg(serial_number 為進行IRF零配置設備的序列號,例如下麵所使用的配置文件名稱)並在保存到HTTP服務器上。配置文件包含了所有設備建立IRF、通過Telnet方式遠程登錄、登錄時密碼認證的相關命令。文件內容如下:

·            210235A045B05B0004354.cfg:

#

telnet server enable

#

 irf mac-address persistent timer

 irf auto-update enable

 undo irf link-delay

 irf member 1 priority 1

 irf mode enhanced

#

irf-port 1/2

 port group mdc 1 interface Ten-GigabitEthernet1/0/1

#

interface Ten-GigabitEthernet1/0/1

 port link-mode bridge

#

interface M-GigabitEthernet0/0/0

 ip address 192.168.0.63 255.255.255.0

#

line vty 0 63

 user-role network-admin

 set authentication password simple 123

#

·            210235A045B05B0004350.cfg:

#

telnet server enable

#

 irf mac-address persistent timer

 irf auto-update enable

 undo irf link-delay

 irf member 2 priority 1

 irf mode enhanced

#

irf-port 2/1

 port group mdc 1 interface Ten-GigabitEthernet1/0/1

#

interface Ten-GigabitEthernet1/0/1

 port link-mode bridge

#

interface M-GigabitEthernet0/0/0

 ip address 192.168.0.63 255.255.255.0

#

line vty 0 63

 user-role network-admin

 set authentication password simple 123

#

(3)       創建sn.txt文件並保存在HTTP服務器上。每個設備的主控板都有序列號,sn.txt文件將序列號和成員編號做一對一的映射,以便Pythone腳本能夠自動給設備配置指定的成員編號。設備通過運行Python腳本來解析sn.txt文件,然後修改設備的IRF成員編號,並根據自身的成員編號來完成相應的IRF配置。文件內容如下:

sn                         Irf group                  Irf number

210235A045B05B0004354          100                           1

210235A045B05B0004350          100                           2

sn.txt文件中的sn列為設備機框的序列號(serial number),可以通過粘貼在設備機框後麵板上的標簽查看其序列號,也可以通過在設備上執行display device manuinfo命令進行查看。sn.txt文件中的Irf group列是用來標記IRF組的數字,用戶可以自行編輯,不會對設備的配置產生影響。sn.txt文件中的Irf number列為設備在IRF組中的成員編號。

(4)       將軟件啟動包s10500.ipe保存在HTTP服務器上。軟件啟動包是設備啟動、運行的必備軟件,使用自動配置進行軟件升級,使現有設備(包括主用主控板和備用主控板)的啟動軟件版本一致,以保證Device A和Device B能夠成功建立IRF。

4.3.3  HTTP Server的配置

啟動HTTP管理軟件,開啟HTTP服務(配置過程略)。

4.4  驗證配置

下麵以Telnet方式登錄Device A為例驗證設備是否成功完成自動配置,Device B和Device A驗證效果相同,不再贅述。

# 登錄設備並輸入密碼進行身份驗證。

Password:

******************************************************************************

* Copyright (c) 2004-2019 New H3C Technologies Co., Ltd. All rights reserved.*

* Without the owner's prior written consent,                                 *

* no decompiling or reverse-engineering shall be allowed.                    *

******************************************************************************

 

<DeviceA>

以上信息表明輸入密碼通過身份驗證後,設備登錄成功。

# 顯示IRF中所有成員設備的相關信息。

<DeviceA> display irf

MemberID  Slot  Role    Priority  CPU-Mac         Description

   1      1     Standby 1         00e0-fc0f-8c02  ---

 *+2      1     Master  1         00e0-fc0f-8c14  ---

--------------------------------------------------

 * indicates the device is the master.

 + indicates the device through which the user logs in.

 

 The Bridge MAC of the IRF is: 000c-1000-1111

 Auto upgrade                : yes

 Mac persistent              : 6 min

 Domain ID                   : 0

 Auto merge                  : yes

 IRF mode                    : enhanced

以上顯示信息表明IRF已經成功建立。

4.5  配置文件

·            Device A和Device B:

#

telnet server enable

#

 irf mac-address persistent timer

 irf auto-update enable

 undo irf link-delay

 irf member 1 priority 1

 irf member 2 priority 1

 irf mode enhanced

#

irf-port 1/2

port group mdc 1 interface Ten-GigabitEthernet1/0/1

#

irf-port 2/1

 

 port group mdc 1 interface Ten-GigabitEthernet1/0/1

#

interface Ten-GigabitEthernet1/0/1

 port link-mode bridge

#

 

interface M-GigabitEthernet0/0/0

 ip address 192.168.0.63 255.255.255.0

#

line vty 0 63

 user-role network-admin

 set authentication password hash $h$6$40hhbS6PeVJORuQu$X/9nQ9PSpPbtGDukVYGOW2Ao

9yJaekVbzovWv23pEKCVwzqqRP8Elnm1qRm4TEIbAetmwQG5gWyREMC3zRCOaQ==

#

·            Device C:

#

 dhcp enable

#

dhcp server ip-pool 1

 network 192.168.1.0 mask 255.255.255.0

 bootfile-name http://192.168.1.40/device.py

#

5  故障的診斷與排除

5.1  Python腳本無法正常運行

1. 故障現象

進入自動配置流程後,屏幕上打印出“File "autocfgjuQccA", line 5”,腳本中的import signal命令出錯。

2. 故障排除

請檢查腳本裏麵的命令前麵是否出現了多餘的空格或字符,請不要隨便修改腳本格式。

5.2  md5文件獲取失敗

1. 故障現象

從HTTP Server上獲取配置文件和程序文件是提示md5文件獲取失敗或未獲取到md5文件。

2. 故障排除

md5文件用於檢查HTTP Server上配置文件和程序文件的正確性。腳本中會有md5文件檢查的步驟,當HTTP Server上沒有配置文件和程序文件對應的md5文件時,會提示未獲取到md5文件,此步驟就會被忽略,繼續執行下麵的腳本,無需關注;當HTTP Server上有配置文件和程序文件對應的md5文件時,請確保md5文件的正確性。

6  相關資料

·            H3C S10500係列交換機 基礎配置指導-R758X

·            H3C S10500係列交換機 基礎命令參考-R758X

·            H3C S10500係列交換機 虛擬化技術配置指導-R758X

·            H3C S10500係列交換機 虛擬化技術命令參考-R758X

不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!

BOB登陆
官網
聯係我們