4 namespace eval excentis {
13 namespace eval ByteBlower {
23 package require excentis_basic
25 proc Generate.Ports.On.Switch { server trunk baseMac L3Config { ports all } } {
47 set netmask 255.255.255.0
50 if { [llength $L3Config] > 0} {
51 set L3Protocol [
lindex $L3Config 0 ]
52 if { [llength $L3Config] > 1} {
53 set baseIP [
lindex $L3Config 1 ]
55 if { [llength $L3Config] > 2} {
56 set defaultGw [
lindex $L3Config 2 ]
58 if { [llength $L3Config] > 3} {
59 set netmask [
lindex $L3Config 3 ]
64 foreach interface [ $server Interfaces.Get ] {
65 if { [string match trunk-$trunk-* $interface ]} {
66 set portNr [
lindex [
split $interface - ] 2 ]
67 if { [string equal $ports all] || [lsearch $ports $portNr ] != -1} {
69 # puts "Interface $portNr found"
70 # Ok, we found a matching interface.
71 set port [ $server Port.Create $interface ]
73 set baseMac [ ::excentis::basic::Mac.Increment $baseMac ]
74 [ $port Layer2.EthII.Set ] Mac.Set $baseMac
76 if { [ string equal $L3Protocol IPv4 ] } {
77 set l3 [ $port Layer3.IPv4.Set ]
78 if { [string equal $baseIP dhcp ] } {
79 [ $l3 Protocol.Dhcp.Get ] Perform
81 set baseIP [ ::excentis::basic::IP.Increment $baseIP ]
83 $l3 Gateway.Set $defaultGw
84 $l3 Netmask.Set $netmask
87 set l3 [ $port Layer3.IPv6.Set ]
88 if { [string equal $baseIP dhcp ] } {
89 [ $l3 Protocol.Dhcp.Get ] Perform
91 set baseIP [ ::excentis::basic::IPv6.Increment $baseIP ]
92 $l3 Ip.Manual.Add $baseIP
93 # The netmask is ignored.
94 $l3 Gateway.Set $defaultGw
97 lappend portList $port
99 puts "Ignoring port $portNr"
100 lappend portList "null $errorObject"
110 proc Generate.Possible.Ports.On.Switch { server trunk baseMac L3Config { ports all } } {
113 if {[string equal $ports all ]} {
115 set interfaceList [ $server Interfaces.Get ]
117 foreach interface $interfaceList {
118 if { [string match trunk-$trunk-* $interface]} {
119 lappend ports [
lindex [
split $interface - ] end ]
124 while { [llength $ports ] > 0 && [
catch { set result [
Generate.Ports.On.Switch $server $trunk $baseMac $L3Config $ports ] } errorObject ]} {
126 set port [
lindex [
split $errorObject - ] end ]
127 if { [string is digit $port]} {
128 puts "Removing port $port ($errorObject)"
129 set ports [ lremove $ports $port ]