| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. |
| tierno | 9a61c6b | 2016-09-08 10:57:02 +0200 | [diff] [blame] | 5 | # This file is part of openvim |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. You may obtain |
| 10 | # a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | # License for the specific language governing permissions and limitations |
| 18 | # under the License. |
| 19 | # |
| 20 | # For those usages not covered by the Apache License, Version 2.0 please |
| 21 | # contact with: nfvlabs@tid.es |
| 22 | ## |
| 23 | |
| 24 | # |
| 25 | #author Alfonso Tierno |
| 26 | # |
| 27 | #script to test openvim with the creation of flavors and interfaces, openflow rules |
| 28 | #using images already inserted |
| 29 | # |
| 30 | |
| 31 | function usage(){ |
| 32 | echo -e "usage: ${BASH_SOURCE[0]} [OPTIONS] \n test openvim " |
| 33 | echo -e " OPTIONS:" |
| 34 | echo -e " -f --force does not prompt for confirmation" |
| 35 | echo -e " -v --same-vlan use this if the parameter 'of_controller_nets_with_same_vlan'" |
| 36 | echo -e " is not false at openvimd.cfg to avoid test unrealizable openflow nets" |
| 37 | echo -e " -h --help shows this help" |
| 38 | echo -e " -c --create create management network and two images (valid for test mode)" |
| 39 | echo |
| 40 | echo "This script test openvim, creating flavors, images, vms, de-attaching dataplane port" |
| 41 | echo "from one network to other and testing openflow generated rules." |
| 42 | echo "By default (unless -c option) uses and already created management network and two valid images." |
| 43 | echo "If -c option is set, it creates the network and images with fake content (only usefull for" |
| 44 | echo "openvim in 'test' mode) This is speccified in this shell variables:" |
| 45 | echo " VIM_TEST_NETWORK_INTERNET name of the mamagement network to use" |
| 46 | echo " VIM_TEST_IMAGE_PATH path of a vm image to use, the image is created if not exist" |
| 47 | echo " VIM_TEST_IMAGE_PATH_EXTRA path of another vm image to use, the image is created if not exist" |
| 48 | } |
| 49 | |
| 50 | #detect if is called with a source to use the 'exit'/'return' command for exiting |
| 51 | [[ ${BASH_SOURCE[0]} != $0 ]] && echo "Do not execute this script as SOURCE" >&2 && return 1 |
| 52 | |
| 53 | #check correct arguments |
| 54 | force=n |
| 55 | same_vlan=n |
| 56 | create=n |
| 57 | for param in $* |
| 58 | do |
| 59 | if [[ $param == -h ]] || [[ $param == --help ]] |
| 60 | then |
| 61 | usage |
| 62 | exit 0 |
| 63 | elif [[ $param == -v ]] || [[ $param == --same-vlan ]] |
| 64 | then |
| 65 | same_vlan=y |
| 66 | elif [[ $param == -f ]] || [[ $param == --force ]] |
| 67 | then |
| 68 | force=y |
| 69 | elif [[ $param == -c ]] || [[ $param == --create ]] |
| 70 | then |
| 71 | create=y |
| 72 | else |
| 73 | echo "invalid argument '$param'?" && usage >&2 && exit 1 |
| 74 | fi |
| 75 | done |
| 76 | |
| 77 | #detect if environment variables are set |
| 78 | fail="" |
| 79 | [[ $create == n ]] && [[ -z $VIM_TEST_NETWORK_INTERNET ]] && echo "VIM_TEST_NETWORK_INTERNET not defined" >&2 && fail=1 |
| 80 | [[ $create == n ]] && [[ -z $VIM_TEST_IMAGE_PATH ]] && echo "VIM_TEST_IMAGE_PATH not defined" >&2 && fail=1 |
| 81 | [[ $create == n ]] && [[ -z $VIM_TEST_IMAGE_PATH_EXTRA ]] && echo "VIM_TEST_IMAGE_PATH_EXTRA not defined" >&2 && fail=1 |
| 82 | [[ -n $fail ]] && exit 1 |
| 83 | |
| 84 | [[ $create == y ]] && [[ -z $VIM_TEST_IMAGE_PATH ]] && VIM_TEST_IMAGE_PATH="/test/path/of/image1" |
| 85 | [[ $create == y ]] && [[ -z $VIM_TEST_IMAGE_PATH_EXTRA ]] && VIM_TEST_IMAGE_PATH_EXTRA="/test/path2/of/image2" |
| 86 | TODELETE="" |
| 87 | export _exit=delete_and_exit |
| 88 | |
| 89 | function delete_and_exit(){ |
| 90 | echo |
| 91 | [[ $force != y ]] && read -e -p " Press enter to delete the deployed things " kk |
| 92 | echo |
| 93 | for f in $TODELETE |
| 94 | do |
| 95 | openvim ${f%%:*}-delete ${f##*:} -f |
| 96 | done |
| 97 | exit $1 |
| 98 | } |
| 99 | |
| 100 | |
| 101 | function is_valid_uuid(){ |
| 102 | echo "$1" | grep -q -E '^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$' && return 0 |
| 103 | return 1 |
| 104 | } |
| 105 | |
| 106 | function process_cmd(){ |
| 107 | # test the result of the previos command, if fails execute the $_exit command |
| 108 | # params: |
| 109 | # uuid <variable> <result...> : test that the first word of <result> is a valid uuid, stored it at <variable>. Print uuid |
| 110 | # fail <reason> <result...> : test that the previous command has failed. If not print the <reason> why it needs to fail |
| 111 | # ok <result...> : test that the previos command has not failed. Print OK |
| 112 | cmd_result=$? |
| 113 | if [[ $1 == uuid ]] |
| 114 | then |
| 115 | [[ $cmd_result == 0 ]] || ! shift 2 || ! echo "FAIL: $*" >&2 || $_exit 1 |
| 116 | is_valid_uuid $3 || ! shift 2 || ! echo "FAIL: $*" >&2 || $_exit 1 |
| 117 | eval $2=$3 |
| 118 | echo $3 |
| 119 | elif [[ $1 == fail ]] |
| 120 | then |
| 121 | [[ $cmd_result != "0" ]] || ! echo "NOT FAIL: $2" >&2 || $_exit 1 |
| 122 | echo "fail OK" |
| 123 | elif [[ $1 == ok ]] |
| 124 | then |
| 125 | [[ $cmd_result == 0 ]] || ! shift 1 || ! echo "FAIL: $*" >&2 || $_exit 1 |
| 126 | echo OK |
| 127 | fi |
| 128 | |
| 129 | } |
| 130 | |
| 131 | function test_of_rules(){ |
| 132 | #test the number of rules of a network, wait until 10 seconds |
| 133 | timeout_=10 |
| 134 | while true |
| 135 | do #it can take some seconds to get it ready |
| 136 | result=`openvim openflow-net-list $1` |
| 137 | nb_rules=`echo $result | grep actions -o | wc -l` |
| 138 | [[ $nb_rules == $2 ]] && echo "OK" && break |
| 139 | [[ $timeout_ == 0 ]] && echo "FAIL $result" >&2 && $_exit 1 |
| 140 | sleep 1 |
| 141 | timeout_=$((timeout_ - 1)) |
| 142 | done |
| 143 | } |
| 144 | |
| 145 | echo " Test VIM with 3 VM deployments. It delete the created items at the end" |
| 146 | echo " " |
| 147 | [[ $force != y ]] && read -e -p "Press enter to continue, CTRL+C to abort " kk |
| 148 | |
| 149 | |
| 150 | printf "%-50s" "1 get ${VIM_TEST_IMAGE_PATH##*/} image: " |
| 151 | image1=`openvim image-list -F"path=${VIM_TEST_IMAGE_PATH}" | gawk '{print $1}'` |
| 152 | if is_valid_uuid $image1 |
| 153 | then |
| 154 | echo $image1 |
| 155 | else |
| 156 | #create the image |
| 157 | echo not found |
| 158 | printf "%-50s" " b create ${VIM_TEST_IMAGE_PATH##*/} image: " |
| 159 | result=`openvim image-create --name=test-image1 --path=${VIM_TEST_IMAGE_PATH} --description=for-test` |
| 160 | process_cmd uuid image1 $result |
| 161 | TODELETE="image:$image1 $TODELETE" |
| 162 | fi |
| 163 | |
| 164 | printf "%-50s" "2 get ${VIM_TEST_IMAGE_PATH_EXTRA##*/} image: " |
| 165 | image2=`openvim image-list -F"path=${VIM_TEST_IMAGE_PATH_EXTRA}" | gawk '{print $1}'` |
| 166 | if is_valid_uuid $image2 |
| 167 | then |
| 168 | echo $image2 |
| 169 | else |
| 170 | #create the image |
| 171 | echo not found |
| 172 | printf "%-50s" " b create ${VIM_TEST_IMAGE_PATH_EXTRA##*/} image: " |
| 173 | result=`openvim image-create --name=test-image1 --path=${VIM_TEST_IMAGE_PATH_EXTRA} --description=for-test` |
| 174 | process_cmd uuid image2 $result |
| 175 | TODELETE="image:$image2 $TODELETE" |
| 176 | fi |
| 177 | |
| 178 | if [[ $create == y ]] |
| 179 | then |
| 180 | printf "%-50s" "3 create management network: " |
| 181 | result=`openvim net-create "name: test_mgmt_net |
| 182 | type: bridge_man"` |
| 183 | process_cmd uuid network_eth0 $result |
| 184 | TODELETE="net:$network_eth0 $TODELETE" |
| 185 | else |
| 186 | printf "%-50s" "3 get ${VIM_TEST_NETWORK_INTERNET} network: " |
| 187 | result=`openvim net-list -F"name=$VIM_TEST_NETWORK_INTERNET"` |
| 188 | process_cmd uuid network_eth0 $result |
| 189 | fi |
| 190 | |
| 191 | printf "%-50s" "4 insert flavor1: " |
| 192 | result=`openvim flavor-create ' |
| 193 | --- |
| 194 | flavor: |
| 195 | name: flavor1 |
| 196 | description: flavor to test openvim |
| 197 | extended: |
| 198 | processor_ranking: 205 |
| 199 | numas: |
| 200 | - memory: 8 |
| 201 | paired-threads: 5 |
| 202 | interfaces: |
| 203 | - name: xe0 |
| 204 | dedicated: "yes" |
| 205 | bandwidth: "10 Gbps" |
| 206 | vpci: "0000:00:10.0" |
| 207 | #mac_address: "10:10:10:10:10:12" |
| 208 | - name: xe1 |
| 209 | dedicated: "no" |
| 210 | bandwidth: "10 Gbps" |
| 211 | vpci: "0000:00:11.0" |
| 212 | mac_address: "10:10:10:10:10:13" |
| 213 | '` |
| 214 | process_cmd uuid flavor1 $result |
| 215 | TODELETE="flavor:$flavor1 $TODELETE" |
| 216 | |
| 217 | printf "%-50s" "5 insert net_ptp: " |
| 218 | result=`openvim net-create ' |
| 219 | --- |
| 220 | network: |
| 221 | name: test_net_ptp |
| 222 | type: ptp |
| 223 | '` |
| 224 | process_cmd uuid net_ptp $result |
| 225 | TODELETE="net:$net_ptp $TODELETE" |
| 226 | |
| 227 | printf "%-50s" " b insert net_data: " |
| 228 | result=`openvim net-create ' |
| 229 | --- |
| 230 | network: |
| 231 | name: test_net_data |
| 232 | type: data |
| 233 | '` |
| 234 | process_cmd uuid net_data $result |
| 235 | TODELETE="net:$net_data $TODELETE" |
| 236 | |
| 237 | printf "%-50s" "6 insert net_bind network bound to net_data: " |
| 238 | result=`openvim net-create 'name: test_net_binded |
| 239 | type: data |
| 240 | bind_net: test_net_data'` |
| 241 | process_cmd uuid net_bind $result |
| 242 | TODELETE="net:$net_bind $TODELETE" |
| 243 | |
| 244 | printf "%-50s" "7 insert bridge network net2: " |
| 245 | result=`openvim net-create ' |
| 246 | --- |
| 247 | network: |
| 248 | name: test_bridge_net2 |
| 249 | type: bridge_data'` |
| 250 | process_cmd uuid network2 $result |
| 251 | TODELETE="net:$network2 $TODELETE" |
| 252 | |
| 253 | printf "%-50s" "8 add VM1 dataplane not connected: " |
| 254 | result=`openvim vm-create " |
| 255 | --- |
| 256 | server: |
| 257 | name: test_VM1 |
| 258 | descrition: US or server with 1 SRIOV 1 PASSTHROUGH |
| 259 | imageRef: '$image1' |
| 260 | flavorRef: '$flavor1' |
| 261 | networks: |
| 262 | - name: mgmt0 |
| 263 | vpci: '0000:00:0a.0' |
| 264 | uuid: ${network_eth0} |
| 265 | mac_address: '10:10:10:10:10:10' |
| 266 | - name: eth0 |
| 267 | vpci: '0000:00:0b.0' |
| 268 | uuid: '$network2' |
| 269 | mac_address: '10:10:10:10:10:11' |
| 270 | "` |
| 271 | process_cmd uuid server1 $result |
| 272 | TODELETE="vm:$server1 $TODELETE" |
| 273 | |
| 274 | printf "%-50s" "9 add VM2 oversubscribe flavor: " |
| 275 | result=`openvim vm-create " |
| 276 | --- |
| 277 | server: |
| 278 | name: test_VM2 |
| 279 | descrition: US or server with direct network attach |
| 280 | imageRef: '$image1' |
| 281 | flavorRef: '$flavor1' |
| 282 | networks: |
| 283 | - name: mgmt0 |
| 284 | vpci: '0000:00:0a.0' |
| 285 | uuid: ${network_eth0} |
| 286 | mac_address: '10:10:10:10:11:10' |
| 287 | - name: eth0 |
| 288 | vpci: '0000:00:0b.0' |
| 289 | uuid: '$network2' |
| 290 | mac_address: '10:10:10:10:11:11' |
| 291 | extended: |
| 292 | processor_ranking: 205 |
| 293 | numas: |
| 294 | - memory: 8 |
| 295 | threads: 10 |
| 296 | interfaces: |
| 297 | - name: xe0 |
| 298 | dedicated: 'yes:sriov' |
| 299 | bandwidth: '10 Gbps' |
| 300 | vpci: '0000:00:11.0' |
| 301 | mac_address: '10:10:10:10:11:12' |
| 302 | uuid: '$net_ptp' |
| 303 | devices: |
| 304 | - type: disk |
| 305 | imageRef: '$image2' |
| 306 | "` |
| 307 | process_cmd uuid server2 $result |
| 308 | TODELETE="vm:$server2 $TODELETE" |
| 309 | |
| 310 | printf "%-50s" "10 test VM with repeated vpci: " |
| 311 | result=`openvim vm-create " |
| 312 | --- |
| 313 | server: |
| 314 | name: test_VMfail |
| 315 | descrition: repeated mac address |
| 316 | imageRef: '$image1' |
| 317 | flavorRef: '$flavor1' |
| 318 | networks: |
| 319 | - name: mgmt0 |
| 320 | vpci: '0000:00:10.0' |
| 321 | uuid: ${network_eth0} |
| 322 | "` |
| 323 | process_cmd fail "Duplicate vpci 0000:00:10.0" $result |
| 324 | |
| 325 | printf "%-50s" " b test VM with repeated mac address: " |
| 326 | result=`openvim vm-create " |
| 327 | --- |
| 328 | server: |
| 329 | name: test_VMfail |
| 330 | descrition: repeated mac address |
| 331 | imageRef: '$image1' |
| 332 | flavorRef: '$flavor1' |
| 333 | networks: |
| 334 | - name: mgmt0 |
| 335 | vpci: '0000:00:0a.0' |
| 336 | uuid: ${network_eth0} |
| 337 | mac_address: '10:10:10:10:10:10' |
| 338 | "` |
| 339 | process_cmd fail "Duplicate mac 10:10:10:10:10:10" $result |
| 340 | |
| 341 | |
| 342 | printf "%-50s" " c test VM with wrong iface name at networks: " |
| 343 | result=`openvim vm-create " |
| 344 | --- |
| 345 | server: |
| 346 | name: test_VMfail |
| 347 | descrition: repeated mac address |
| 348 | imageRef: '$image1' |
| 349 | flavorRef: '$flavor1' |
| 350 | networks: |
| 351 | - name: missing |
| 352 | type: PF |
| 353 | uuid: '$net_ptp' |
| 354 | "` |
| 355 | process_cmd fail "wrong iface name at networks" $result |
| 356 | |
| 357 | |
| 358 | printf "%-50s" " d test VM with wrong iface type at networks: " |
| 359 | result=`openvim vm-create " |
| 360 | --- |
| 361 | server: |
| 362 | name: test_VMfail |
| 363 | descrition: repeated mac address |
| 364 | imageRef: '$image1' |
| 365 | flavorRef: '$flavor1' |
| 366 | networks: |
| 367 | - name: xe0 |
| 368 | type: VF |
| 369 | uuid: '$net_ptp' |
| 370 | "` |
| 371 | process_cmd fail "wrong iface type at networks" $result |
| 372 | |
| 373 | |
| 374 | printf "%-50s" "11 add VM3 dataplane connected: " |
| 375 | result=`openvim vm-create " |
| 376 | --- |
| 377 | server: |
| 378 | name: test_VM3 |
| 379 | descrition: US or server with 2 dataplane connected |
| 380 | imageRef: '$image1' |
| 381 | flavorRef: '$flavor1' |
| 382 | networks: |
| 383 | - name: mgmt0 |
| 384 | vpci: '0000:00:0a.0' |
| 385 | uuid: ${network_eth0} |
| 386 | mac_address: '10:10:10:10:12:10' |
| 387 | - name: eth0 |
| 388 | vpci: '0000:00:0b.0' |
| 389 | uuid: '$network2' |
| 390 | type: virtual |
| 391 | mac_address: '10:10:10:10:12:11' |
| 392 | - name: xe0 |
| 393 | type: PF |
| 394 | uuid: '$net_data' |
| 395 | - name: xe1 |
| 396 | type: VF |
| 397 | uuid: '$net_ptp' |
| 398 | mac_address: '10:10:10:10:12:13' |
| 399 | "` |
| 400 | process_cmd uuid server3 $result |
| 401 | TODELETE="vm:$server3 $TODELETE" |
| 402 | |
| 403 | printf "%-50s" "12 check 2 openflow rules for net_ptp: " |
| 404 | test_of_rules $net_ptp 2 |
| 405 | |
| 406 | printf "%-50s" "13 check net-down net_ptp: " |
| 407 | result=`openvim net-down -f ${net_ptp}` |
| 408 | process_cmd ok $result |
| 409 | |
| 410 | printf "%-50s" " b check 0 openflow rules for net_ptp: " |
| 411 | test_of_rules $net_ptp 0 |
| 412 | |
| 413 | printf "%-50s" " c check net-up net_ptp: " |
| 414 | result=`openvim net-up -f ${net_ptp}` |
| 415 | process_cmd ok $result |
| 416 | |
| 417 | printf "%-50s" " d check 2 openflow rules for net_ptp: " |
| 418 | test_of_rules $net_ptp 2 |
| 419 | |
| 420 | printf "%-50s" "14 check 0 openflow rules for net_data: " |
| 421 | test_of_rules $net_data 0 |
| 422 | |
| 423 | [[ $force != y ]] && read -e -p " Test control plane, and server2:xe0 to server3:xe1 connectivity. Press enter to continue " kk |
| 424 | |
| 425 | printf "%-50s" "15 get xe0 iface uuid from server1: " |
| 426 | result=`openvim port-list -F"device_id=${server1}&name=xe0"` |
| 427 | process_cmd uuid server1_xe0 $result |
| 428 | |
| 429 | printf "%-50s" " b get xe1 iface uuid from server1: " |
| 430 | result=`openvim port-list -F"device_id=${server1}&name=xe1"` |
| 431 | process_cmd uuid server1_xe1 $result |
| 432 | |
| 433 | printf "%-50s" " c get xe0 iface uuid from server3: " |
| 434 | result=`openvim port-list -F"device_id=${server3}&name=xe0"` |
| 435 | process_cmd uuid server3_xe0 $result |
| 436 | |
| 437 | printf "%-50s" " d get xe1 iface uuid from server3: " |
| 438 | result=`openvim port-list -F"device_id=${server3}&name=xe1"` |
| 439 | process_cmd uuid server3_xe1 $result |
| 440 | |
| 441 | printf "%-50s" " e get xe0 iface uuid from server3: " |
| 442 | result=`openvim port-list -F"device_id=${server2}&name=xe0"` |
| 443 | process_cmd uuid server2_xe0 $result |
| 444 | |
| 445 | printf "%-50s" "16 test ptp 3connex server1:xe0 -> net_ptp: " |
| 446 | result=`openvim port-edit $server1_xe0 "network_id: $net_ptp" -f` |
| 447 | process_cmd fail "Can not connect 3 interfaces to ptp network" |
| 448 | |
| 449 | printf "%-50s" "17 attach server1:xe0 to net_data: " |
| 450 | result=`openvim port-edit $server1_xe0 "network_id: $net_data" -f` |
| 451 | process_cmd ok $result |
| 452 | |
| 453 | printf "%-50s" "18 check 2 openflow rules for net_data: " |
| 454 | test_of_rules $net_data 2 |
| 455 | |
| 456 | [[ $force != y ]] && read -e -p " Test server1:xe0 to server3:xe0 connectivity. Press enter to continue " kk |
| 457 | |
| 458 | if [[ $same_vlan == n ]] |
| 459 | then |
| 460 | |
| 461 | printf "%-50s" "19 attach server1:xe1 to net-data: " |
| 462 | result=`openvim port-edit $server1_xe1 "network_id: $net_data" -f` |
| 463 | process_cmd ok $result |
| 464 | |
| 465 | printf "%-50s" " b check 9 openflow rules for net_data: " |
| 466 | test_of_rules $net_data 9 |
| 467 | |
| 468 | [[ $force != y ]] && read -e -p " Test server1:xe0,server1:xe1,server3:xe0 connectivity. Press enter to continue " kk |
| 469 | |
| 470 | printf "%-50s" " c re-attach server3:xe1 to net-data: " |
| 471 | result=`openvim port-edit $server3_xe1 "network_id: $net_data" -f` |
| 472 | process_cmd ok $result |
| 473 | |
| 474 | printf "%-50s" " d check 16 openflow rules for net_data: " |
| 475 | test_of_rules $net_data 16 |
| 476 | |
| 477 | printf "%-50s" " e check 0 openflow rules for net_ptp: " |
| 478 | test_of_rules $net_ptp 0 |
| 479 | |
| 480 | [[ $force != y ]] && read -e -p " Test server1:xe0,server1:xe1,server3:xe0,server3:xe1 connectivity. Press enter to continue " kk |
| 481 | |
| 482 | printf "%-50s" " f detach server1:xe1 from net-data: " |
| 483 | result=`openvim port-edit $server1_xe1 "network_id: null" -f ` |
| 484 | process_cmd ok $result |
| 485 | |
| 486 | printf "%-50s" " g detach server3:xe1 to net-data: " |
| 487 | result=`openvim port-edit $server3_xe1 "network_id: null" -f` |
| 488 | process_cmd ok $result |
| 489 | |
| 490 | printf "%-50s" " h check 2 openflow rules for net_data: " |
| 491 | test_of_rules $net_data 2 |
| 492 | |
| 493 | else |
| 494 | echo "19 skipping unrealizable test because --same_vlan option " |
| 495 | fi |
| 496 | |
| 497 | printf "%-50s" "20 check 2 openflow rules for net_data: " |
| 498 | test_of_rules $net_data 2 |
| 499 | |
| 500 | printf "%-50s" " a attach server2:xe0 to net_bind: " |
| 501 | result=`openvim port-edit $server2_xe0 "network_id: $net_bind" -f` |
| 502 | process_cmd ok $result |
| 503 | |
| 504 | printf "%-50s" " b check 6 openflow rules for net_data: " |
| 505 | #type src_net src_port => dst_port dst_net |
| 506 | #unicast net_data server1:xe0 => server3:xe0 net_data |
| 507 | #unicast net_data server3:xe0 => server1:xe0 net_data |
| 508 | #unicast net_data server1:xe0 => server2:xe0 net_bind |
| 509 | #unicast net_data server3:xe0 => server2:xe0 net_bind |
| 510 | #broadcast net_data server1:xe0 => server3:xe0,server2:xe0 net_data,net_bind |
| 511 | #broadcast net_data server3:xe0 => server1:xe0,server2:xe0 net_data,net_bind |
| 512 | test_of_rules $net_data 6 |
| 513 | |
| 514 | |
| 515 | printf "%-50s" " c check 3 openflow rules for net_bind: " |
| 516 | #type src_net src_port => dst_port dst_net |
| 517 | #unicast net_bind server2:xe0 => server1:xe0 net_data |
| 518 | #unicast net_bind server2:xe0 => server3:xe0 net_data |
| 519 | #broadcast net_bind server2:xe0 => server1:xe0,server3:xe0 net_data,net_data |
| 520 | test_of_rules $net_bind 3 |
| 521 | |
| 522 | printf "%-50s" " d attach server1:xe1 to net_bind: " |
| 523 | result=`openvim port-edit $server1_xe1 "network_id: $net_bind" -f` |
| 524 | process_cmd ok $result |
| 525 | |
| 526 | printf "%-50s" " e check 8 openflow rules for net_data: " |
| 527 | #type src_net src_port => dst_port dst_net |
| 528 | #unicast net_data server1:xe0 => server3:xe0 net_data |
| 529 | #unicast net_data server3:xe0 => server1:xe0 net_data |
| 530 | #unicast net_data server1:xe0 => server2:xe0 net_bind |
| 531 | #unicast net_data server1:xe0 => server1:xe1 net_bind |
| 532 | #unicast net_data server3:xe0 => server2:xe0 net_bind |
| 533 | #unicast net_data server3:xe0 => server1:xe1 net_bind |
| 534 | #broadcast net_data server1:xe0 => server3:xe0,server2:xe0,server1:xe1 net_data,net_bind,net_bind |
| 535 | #broadcast net_data server3:xe0 => server1:xe0,server2:xe0,server1:xe1 net_data,net_bind,net_bind |
| 536 | test_of_rules $net_data 8 |
| 537 | |
| 538 | |
| 539 | printf "%-50s" " f check 8 openflow rules for net_bind: " |
| 540 | test_of_rules $net_bind 8 |
| 541 | |
| 542 | printf "%-50s" " d put net_data down: " |
| 543 | result=`openvim net-down $net_data -f` |
| 544 | process_cmd ok $result |
| 545 | |
| 546 | printf "%-50s" " e check 0 openflow rules for net_data: " |
| 547 | test_of_rules $net_data 0 |
| 548 | |
| 549 | printf "%-50s" " e check 2 openflow rules for net_bind: " |
| 550 | test_of_rules $net_bind 2 |
| 551 | |
| 552 | |
| 553 | |
| 554 | echo |
| 555 | echo DONE |
| 556 | |
| 557 | $_exit 0 |
| 558 | |