#!/bin/bash # This example script creates bonding network devices based on synthetic NIC # (the virtual network adapter usually provided by Hyper-V) and the matching # VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can # function as one network device, and fail over to the synthetic NIC if VF is # down. # # Usage: # - After configured vSwitch and vNIC with SRIOV, start Linux virtual # machine (VM) # - Run this scripts on the VM. It will create configuration files in # distro specific directory. # - Reboot the VM, so that the bonding config are enabled. # # The config files are DHCP by default. You may edit them if you need to change # to Static IP or change other settings. # global sysdir := '/sys/class/net' global netvsc_cls := '{f8615163-df3e-46c5-913f-f2d2f965ed0e}' global bondcnt := '0' # Detect Distro if test -f /etc/redhat-release { global cfgdir := '/etc/sysconfig/network-scripts' global distro := 'redhat' } elif grep -q 'Ubuntu' /etc/issue { global cfgdir := '/etc/network' global distro := 'ubuntu' } elif grep -q 'SUSE' /etc/issue { global cfgdir := '/etc/sysconfig/network' global distro := 'suse' } else { echo "Unsupported Distro" exit 1 } echo Detected Distro: $distro, or compatible # Get a list of ethernet names global list_eth := '('`cd $sysdir && ls -d */ | cut -d/ -f1 | grep -v bond`) global eth_cnt := $(#list_eth[@]) echo List of net devices: # Get the MAC addresses for (( i=0; i < $eth_cnt; i++ )) do list_mac[$i]=`cat $sysdir/${list_eth[$i]}/address` echo ${list_eth[$i]}, ${list_mac[$i]} done # Find NIC with matching MAC for (( i=0; i < $eth_cnt-1; i++ )) do for (( j=i+1; j < $eth_cnt; j++ )) do if [ "${list_mac[$i]}" = "${list_mac[$j]}" ] then list_match[$i]=${list_eth[$j]} break fi done done proc create_eth_cfg_redhat { var fn = "$cfgdir/ifcfg-$1" rm -f $fn echo DEVICE=$1 >>$fn echo TYPE=Ethernet >>$fn echo BOOTPROTO=none >>$fn echo ONBOOT=yes >>$fn echo NM_CONTROLLED=no >>$fn echo PEERDNS=yes >>$fn echo IPV6INIT=yes >>$fn echo MASTER=$2 >>$fn echo SLAVE=yes >>$fn } proc create_eth_cfg_pri_redhat { create_eth_cfg_redhat $1 $2 } proc create_bond_cfg_redhat { var fn = "$cfgdir/ifcfg-$1" rm -f $fn echo DEVICE=$1 >>$fn echo TYPE=Bond >>$fn echo BOOTPROTO=dhcp >>$fn echo ONBOOT=yes >>$fn echo NM_CONTROLLED=no >>$fn echo PEERDNS=yes >>$fn echo IPV6INIT=yes >>$fn echo BONDING_MASTER=yes >>$fn echo BONDING_OPTS='"'mode=active-backup miimon=100 primary=$2'"' >>$fn } proc create_eth_cfg_ubuntu { var fn = "$cfgdir/interfaces" echo $'\n'auto $1 >>$fn echo iface $1 inet manual >>$fn echo bond-master $2 >>$fn } proc create_eth_cfg_pri_ubuntu { var fn = "$cfgdir/interfaces" create_eth_cfg_ubuntu $1 $2 echo bond-primary $1 >>$fn } proc create_bond_cfg_ubuntu { var fn = "$cfgdir/interfaces" echo $'\n'auto $1 >>$fn echo iface $1 inet dhcp >>$fn echo bond-mode active-backup >>$fn echo bond-miimon 100 >>$fn echo bond-slaves none >>$fn } proc create_eth_cfg_suse { var fn = "$cfgdir/ifcfg-$1" rm -f $fn echo BOOTPROTO=none >>$fn echo STARTMODE=auto >>$fn } proc create_eth_cfg_pri_suse { create_eth_cfg_suse $1 } proc create_bond_cfg_suse { var fn = "$cfgdir/ifcfg-$1" rm -f $fn echo BOOTPROTO=dhcp >>$fn echo STARTMODE=auto >>$fn echo BONDING_MASTER=yes >>$fn echo BONDING_SLAVE_0=$2 >>$fn echo BONDING_SLAVE_1=$3 >>$fn echo BONDING_MODULE_OPTS='''mode=active-backup miimon=100 primary=$2''' >>$fn } proc create_bond { var bondname = "bond$bondcnt" var primary = '' var secondary = '' var class_id1 = $[cat $sysdir/$1/device/class_id !2 >/dev/null] var class_id2 = $[cat $sysdir/$2/device/class_id !2 >/dev/null] if test $class_id1 = $netvsc_cls { primary := $2 secondary := $1 } elif test $class_id2 = $netvsc_cls { primary := $1 secondary := $2 } else { return 0 } echo $'\nBond name:' $bondname echo configuring $primary create_eth_cfg_pri_$distro $primary $bondname echo configuring $secondary create_eth_cfg_$distro $secondary $bondname echo creating: $bondname with primary slave: $primary create_bond_cfg_$distro $bondname $primary $secondary let bondcnt=bondcnt+1 } for (( i=0; i < $eth_cnt-1; i++ )) do if [ -n "${list_match[$i]}" ] then create_bond ${list_eth[$i]} ${list_match[$i]} fi done (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:sysdir) op:Equal rhs:{(/sys/class/net)} spids:[53])] spids: [53] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:netvsc_cls) op: Equal rhs: {(Lit_LBrace "{") (f8615163-df3e-46c5-913f-f2d2f965ed0e) (Lit_RBrace "}")} spids: [56] ) ] spids: [56] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:bondcnt) op:Equal rhs:{(0)} spids:[61])] spids: [61] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(/etc/redhat-release)} {(Lit_Other "]")}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:cfgdir) op: Equal rhs: {(/etc/sysconfig/network-scripts)} spids: [82] ) ] spids: [82] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:distro) op:Equal rhs:{(redhat)} spids:[86])] spids: [86] ) ] spids: [-1 79] ) (if_arm cond: [(C {(grep)} {(-q)} {(SQ )} {(/etc/issue)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:cfgdir) op: Equal rhs: {(/etc/network)} spids: [104] ) ] spids: [104] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:distro) op:Equal rhs:{(ubuntu)} spids:[108])] spids: [108] ) ] spids: [89 101] ) (if_arm cond: [(C {(grep)} {(-q)} {(SQ )} {(/etc/issue)})] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:cfgdir) op: Equal rhs: {(/etc/sysconfig/network)} spids: [126] ) ] spids: [126] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:distro) op:Equal rhs:{(suse)} spids:[130])] spids: [130] ) ] spids: [111 123] ) ] else_action: [(C {(echo)} {(DQ ("Unsupported Distro"))}) (C {(exit)} {(1)})] spids: [133 147] ) (C {(echo)} {(Detected)} {(Distro) (Lit_Other ":")} {($ VSub_Name "$distro") (Lit_Comma ",")} {(or)} {(compatible)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:list_eth) op: Equal rhs: { (ArrayLiteralPart words: [ { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (C {(cd)} {($ VSub_Name "$sysdir")}) (Pipeline children: [ (C {(ls)} {(-d)} {(Lit_Other "*") (/)}) (C {(cut)} {(-d/)} {(-f1)}) (C {(grep)} {(-v)} {(bond)}) ] negated: False ) ] op_id: Op_DAmp ) ] ) left_token: spids: [170 199] ) } ] ) } spids: [168] ) ] spids: [168] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:eth_cnt) op: Equal rhs: { (BracedVarSub token: prefix_op: VSub_Pound bracket_op: (WholeArray op_id:Lit_At) spids: [203 209] ) } spids: [202] ) ] spids: [202] ) (C {(echo)} {(List)} {(of)} {(net)} {(devices) (Lit_Other ":")}) (ForExpr init: (BinaryAssign op_id:Arith_Equal left:(LhsName name:i) right:(ArithWord w:{(Lit_Digits 0)})) cond: (ArithBinary op_id: Arith_Less left: (ArithVarRef name:i) right: (ArithWord w:{($ VSub_Name "$eth_cnt")}) ) update: (UnaryAssign op_id:Node_PostDPlus child:(LhsName name:i)) body: (DoGroup children: [ (C {(list_mac) (Lit_Other "[") ($ VSub_Name "$i") (Lit_Other "]") (Lit_Other "=") (CommandSubPart command_list: (CommandList children: [ (C {(cat)} {($ VSub_Name "$sysdir") (/) (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [262 267] ) (/address) } ) ] ) left_token: spids: [257 269] ) } ) (C {(echo)} { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [274 279] ) (Lit_Comma ",") } { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [282 287] ) } ) ] spids: [249 289] ) ) (ForExpr init: (BinaryAssign op_id:Arith_Equal left:(LhsName name:i) right:(ArithWord w:{(Lit_Digits 0)})) cond: (ArithBinary op_id: Arith_Less left: (ArithVarRef name:i) right: (ArithBinary op_id: Arith_Minus left: (ArithWord w:{($ VSub_Name "$eth_cnt")}) right: (ArithWord w:{(Lit_Digits 1)}) ) ) update: (UnaryAssign op_id:Node_PostDPlus child:(LhsName name:i)) body: (DoGroup children: [ (ForExpr init: (BinaryAssign op_id: Arith_Equal left: (LhsName name:j) right: (ArithBinary op_id: Arith_Plus left: (ArithVarRef name:i) right: (ArithWord w:{(Lit_Digits 1)}) ) ) cond: (ArithBinary op_id: Arith_Less left: (ArithVarRef name:j) right: (ArithWord w:{($ VSub_Name "$eth_cnt")}) ) update: (UnaryAssign op_id:Node_PostDPlus child:(LhsName name:j)) body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [355 360] ) ) } {(Lit_Other "=")} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$j")})) spids: [366 371] ) ) } {(Lit_Other "]")} ) ] action: [ (C {(list_match) (Lit_Other "[") ($ VSub_Name "$i") (Lit_Other "]") (Lit_Other "=") (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$j")})) spids: [385 390] ) } ) (ControlFlow token:) ] spids: [-1 377] ) ] spids: [-1 396] ) ] spids: [347 399] ) ) ] spids: [319 401] ) ) (FuncDef name: create_eth_cfg_redhat body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/ifcfg-) ($ VSub_Number "$1")} spids: [413] ) ] spids: [411] ) (C {(rm)} {(-f)} {($ VSub_Name "$fn")}) (SimpleCommand words: [{(echo)} {(Lit_VarLike "DEVICE=") ($ VSub_Number "$1")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[432])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "TYPE=") (Ethernet)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[441])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BOOTPROTO=") (none)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[450])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "ONBOOT=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[459])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "NM_CONTROLLED=") (no)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[468])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "PEERDNS=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[477])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "IPV6INIT=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[486])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "MASTER=") ($ VSub_Number "$2")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[495])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "SLAVE=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[504])] ) ] spids: [408] ) spids: [404 407] ) (FuncDef name: create_eth_cfg_pri_redhat body: (BraceGroup children: [(C {(create_eth_cfg_redhat)} {($ VSub_Number "$1")} {($ VSub_Number "$2")})] spids: [514] ) spids: [510 513] ) (FuncDef name: create_bond_cfg_redhat body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/ifcfg-) ($ VSub_Number "$1")} spids: [535] ) ] spids: [533] ) (C {(rm)} {(-f)} {($ VSub_Name "$fn")}) (SimpleCommand words: [{(echo)} {(Lit_VarLike "DEVICE=") ($ VSub_Number "$1")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[554])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "TYPE=") (Bond)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[563])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BOOTPROTO=") (dhcp)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[572])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "ONBOOT=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[581])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "NM_CONTROLLED=") (no)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[590])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "PEERDNS=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[599])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "IPV6INIT=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[608])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BONDING_MASTER=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[617])] ) (SimpleCommand words: [ {(echo)} {(Lit_VarLike "BONDING_OPTS=") (EscapedLiteralPart token:) (Lit_VarLike "mode=") (active-backup) } {(Lit_VarLike "miimon=") (100)} {(Lit_VarLike "primary=") ($ VSub_Number "$2") (EscapedLiteralPart token:) } ] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[635])] ) ] spids: [530] ) spids: [526 529] ) (FuncDef name: create_eth_cfg_ubuntu body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/interfaces)} spids: [650] ) ] spids: [648] ) (SimpleCommand words: [{(echo)} {(SQ ) (auto)} {($ VSub_Number "$1")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[665])] ) (SimpleCommand words: [{(echo)} {(iface)} {($ VSub_Number "$1")} {(inet)} {(manual)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[679])] ) (SimpleCommand words: [{(echo)} {(bond-master)} {($ VSub_Number "$2")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[689])] ) ] spids: [645] ) spids: [641 644] ) (FuncDef name: create_eth_cfg_pri_ubuntu body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/interfaces)} spids: [704] ) ] spids: [702] ) (C {(create_eth_cfg_ubuntu)} {($ VSub_Number "$1")} {($ VSub_Number "$2")}) (SimpleCommand words: [{(echo)} {(bond-primary)} {($ VSub_Number "$1")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[723])] ) ] spids: [699] ) spids: [695 698] ) (FuncDef name: create_bond_cfg_ubuntu body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/interfaces)} spids: [738] ) ] spids: [736] ) (SimpleCommand words: [{(echo)} {(SQ ) (auto)} {($ VSub_Number "$1")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[753])] ) (SimpleCommand words: [{(echo)} {(iface)} {($ VSub_Number "$1")} {(inet)} {(dhcp)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[767])] ) (SimpleCommand words: [{(echo)} {(bond-mode)} {(active-backup)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[777])] ) (SimpleCommand words: [{(echo)} {(bond-miimon)} {(100)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[787])] ) (SimpleCommand words: [{(echo)} {(bond-slaves)} {(none)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[797])] ) ] spids: [733] ) spids: [729 732] ) (FuncDef name: create_eth_cfg_suse body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/ifcfg-) ($ VSub_Number "$1")} spids: [812] ) ] spids: [810] ) (C {(rm)} {(-f)} {($ VSub_Name "$fn")}) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BOOTPROTO=") (none)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[831])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "STARTMODE=") (auto)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[840])] ) ] spids: [807] ) spids: [803 806] ) (FuncDef name: create_eth_cfg_pri_suse body: (BraceGroup children:[(C {(create_eth_cfg_suse)} {($ VSub_Number "$1")})] spids:[850]) spids: [846 849] ) (FuncDef name: create_bond_cfg_suse body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:fn) op: Equal rhs: {($ VSub_Name "$cfgdir") (/ifcfg-) ($ VSub_Number "$1")} spids: [869] ) ] spids: [867] ) (C {(rm)} {(-f)} {($ VSub_Name "$fn")}) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BOOTPROTO=") (dhcp)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[888])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "STARTMODE=") (auto)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[897])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BONDING_MASTER=") (yes)}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[906])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BONDING_SLAVE_0=") ($ VSub_Number "$2")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[915])] ) (SimpleCommand words: [{(echo)} {(Lit_VarLike "BONDING_SLAVE_1=") ($ VSub_Number "$3")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[924])] ) (SimpleCommand words: [ {(echo)} {(Lit_VarLike "BONDING_MODULE_OPTS=") (EscapedLiteralPart token:) (Lit_VarLike "mode=") (active-backup) } {(Lit_VarLike "miimon=") (100)} {(Lit_VarLike "primary=") ($ VSub_Number "$2") (EscapedLiteralPart token:) } ] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{($ VSub_Name "$fn")} spids:[942])] ) ] spids: [864] ) spids: [860 863] ) (FuncDef name: create_bond body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:bondname) op: Equal rhs: {(bond) ($ VSub_Name "$bondcnt")} spids: [957] ) ] spids: [955] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:primary) op:Equal spids:[964])] spids: [962] ) (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:secondary) op:Equal spids:[969])] spids: [967] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:class_id1) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {(cat)} {($ VSub_Name "$sysdir") (/) ($ VSub_Number "$1") (/device/class_id)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [984] ) ] ) ] ) left_token: spids: [976 986] ) } spids: [975] ) ] spids: [973] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:class_id2) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {(cat)} {($ VSub_Name "$sysdir") (/) ($ VSub_Number "$2") (/device/class_id)} ] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [1000] ) ] ) ] ) left_token: spids: [992 1002] ) } spids: [991] ) ] spids: [989] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$class_id1"))} {(Lit_Other "=")} {(DQ ($ VSub_Name "$netvsc_cls"))} {(Lit_Other "]")} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:primary) op: Equal rhs: {($ VSub_Number "$2")} spids: [1026] ) ] spids: [1026] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:secondary) op: Equal rhs: {($ VSub_Number "$1")} spids: [1030] ) ] spids: [1030] ) ] spids: [-1 1023] ) (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$class_id2"))} {(Lit_Other "=")} {(DQ ($ VSub_Name "$netvsc_cls"))} {(Lit_Other "]")} ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:primary) op: Equal rhs: {($ VSub_Number "$1")} spids: [1054] ) ] spids: [1054] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:secondary) op: Equal rhs: {($ VSub_Number "$2")} spids: [1058] ) ] spids: [1058] ) ] spids: [1034 1051] ) ] else_action: [(ControlFlow token: arg_word:{(0)})] spids: [1062 1070] ) (C {(echo)} {(SQ <"Bond name:">)} {($ VSub_Name "$bondname")}) (C {(echo)} {(configuring)} {($ VSub_Name "$primary")}) (C {(create_eth_cfg_pri_) ($ VSub_Name "$distro")} {($ VSub_Name "$primary")} {($ VSub_Name "$bondname")} ) (C {(echo)} {(configuring)} {($ VSub_Name "$secondary")}) (C {(create_eth_cfg_) ($ VSub_Name "$distro")} {($ VSub_Name "$secondary")} {($ VSub_Name "$bondname")} ) (C {(echo)} {(creating) (Lit_Other ":")} {($ VSub_Name "$bondname")} {(with)} {(primary)} {(slave) (Lit_Other ":")} {($ VSub_Name "$primary")} ) (C {(create_bond_cfg_) ($ VSub_Name "$distro")} {($ VSub_Name "$bondname")} {($ VSub_Name "$primary")} {($ VSub_Name "$secondary")} ) (C {(let)} {(Lit_VarLike "bondcnt=") (bondcnt) (Lit_Other "+") (1)}) ] spids: [952] ) spids: [948 951] ) (ForExpr init: (BinaryAssign op_id:Arith_Equal left:(LhsName name:i) right:(ArithWord w:{(Lit_Digits 0)})) cond: (ArithBinary op_id: Arith_Less left: (ArithVarRef name:i) right: (ArithBinary op_id: Arith_Minus left: (ArithWord w:{($ VSub_Name "$eth_cnt")}) right: (ArithWord w:{(Lit_Digits 1)}) ) ) update: (UnaryAssign op_id:Node_PostDPlus child:(LhsName name:i)) body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(-n)} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [1189 1194] ) ) } {(Lit_Other "]")} ) ] action: [ (C {(create_bond)} { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [1205 1210] ) } { (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{($ VSub_Name "$i")})) spids: [1212 1217] ) } ) ] spids: [-1 1200] ) ] spids: [-1 1220] ) ] spids: [1179 1222] ) ) ] )