Tcl脚本调用高层API实现仪表使用和主机创建配置的自动化测试用例

#设置Chassis的基本参数,包括IP地址,端口的数量等等
set chassisAddr 10.132.238.190
set islot 1
set portList {11 12} ;#端口的排列顺序是port1, port2

if { [catch {
    #加载STC API Lib
  
    cd ../Source
    #加载HLAPI Lib
    source ./CSTC.tcl
    SetLogOption -Debug Enable   
    # 开始连接机器
    TestDevice chassis1 $chassisAddr

    # 开始预留两个端口
    for {set i 0} {$i <[llength $portList]} {incr i} {
        chassis1 CreateTestPort -PortLocation $islot/[lindex $portList $i] -PortName port[expr $i+1] -PortType Ethernet
    }

  #port1 CreateSubInt -SubIntName vlan1
    # 配置vlan子接口
    #vlan1 ConfigVlanIf -VlanTag 300

    # 创建Host对象        
    port1 CreateHost -HostName host1 -IpVersion ipv4 -Ipv4Addr 192.168.34.242 -Ipv4AddrGateway 192.168.34.1 \
          -Ipv4AddrPrefixLen 24 -FlagPing enable
    port2 CreateHost -HostName host2 -I