Cameron Franke | 2ea90e5 | 2015-01-21 10:04:16 -0800 | [diff] [blame] | 1 | # ScaleOutTemplate |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
| 7 | import sys |
| 8 | import os |
| 9 | |
| 10 | |
| 11 | class ScaleOutTemplate: |
| 12 | def __init__(self): |
| 13 | self.default = '' |
| 14 | |
| 15 | def CASE1(self, main): |
| 16 | |
| 17 | global cluster_count |
| 18 | cluster_count = 1 |
| 19 | |
| 20 | checkout_branch = main.params['GIT']['checkout'] |
| 21 | git_pull = main.params['GIT']['autopull'] |
| 22 | cell_name = main.params['ENV']['cellName'] |
| 23 | BENCH_ip = main.params['BENCH']['ip1'] |
| 24 | BENCH_user = main.params['BENCH']['user'] |
| 25 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 26 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 27 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 28 | MN1_ip = main.params['MN']['ip1'] |
| 29 | |
| 30 | main.log.step("Cleaning Enviornment...") |
| 31 | main.ONOSbench.onos_uninstall(ONOS1_ip) |
| 32 | main.ONOSbench.onos_uninstall(ONOS2_ip) |
| 33 | main.ONOSbench.onos_uninstall(ONOS3_ip) |
| 34 | |
| 35 | main.step("Git checkout and pull "+checkout_branch) |
| 36 | if git_pull == 'on': |
| 37 | checkout_result = main.ONOSbench.git_checkout(checkout_branch) |
| 38 | pull_result = main.ONOSbench.git_pull() |
| 39 | |
| 40 | else: |
| 41 | checkout_result = main.TRUE |
| 42 | pull_result = main.TRUE |
| 43 | main.log.info("Skipped git checkout and pull") |
| 44 | |
| 45 | mvn_result = main.ONOSbench.clean_install() |
| 46 | |
| 47 | main.step("Set cell for ONOS cli env") |
| 48 | main.ONOS1cli.set_cell(cell_name) |
| 49 | main.ONOS2cli.set_cell(cell_name) |
| 50 | main.ONOS3cli.set_cell(cell_name) |
| 51 | |
| 52 | main.step("Creating ONOS package") |
| 53 | package_result = main.ONOSbench.onos_package() #no file or directory |
| 54 | |
| 55 | main.step("Installing ONOS package") |
| 56 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 57 | |
| 58 | cell_name = main.params['ENV']['cellName'] |
| 59 | main.step("Applying cell file to environment") |
| 60 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 61 | main.step("verify cells") |
| 62 | verify_cell_result = main.ONOSbench.verify_cell() |
| 63 | |
| 64 | main.step("Set cell for ONOS cli env") |
| 65 | main.ONOS1cli.set_cell(cell_name) |
| 66 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 67 | |
| 68 | |
| 69 | def CASE2(self, main): |
| 70 | |
| 71 | ''' |
| 72 | Increase number of nodes and initiate CLI |
| 73 | ''' |
| 74 | import time |
| 75 | |
| 76 | global cluster_count |
| 77 | |
| 78 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 79 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 80 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 81 | #ONOS4_ip = main.params['CTRL']['ip4'] |
| 82 | #ONOS5_ip = main.params['CTRL']['ip5'] |
| 83 | #ONOS6_ip = main.params['CTRL']['ip6'] |
| 84 | #ONOS7_ip = main.params['CTRL']['ip7'] |
| 85 | cell_name = main.params['ENV']['cellName'] |
| 86 | scale = int(main.params['SCALE']) |
| 87 | |
| 88 | #Cluster size increased everytime the case is defined |
| 89 | cluster_count += scale |
| 90 | |
| 91 | main.log.report("Increasing cluster size to "+ |
| 92 | str(cluster_count)) |
| 93 | install_result = main.FALSE |
| 94 | |
| 95 | if scale == 2: |
| 96 | if cluster_count == 3: |
| 97 | main.log.info("Installing nodes 2 and 3") |
| 98 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 99 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
| 100 | cli2 = main.ONOS1cli.start_onos_cli(ONOS2_ip) |
| 101 | cli3 = main.ONOS1cli.start_onos_cli(ONOS3_ip) |
| 102 | |
| 103 | ''' |
| 104 | elif cluster_count == 5: |
| 105 | |
| 106 | main.log.info("Installing nodes 4 and 5") |
| 107 | node4_result = main.ONOSbench.onos_install(node=ONOS4_ip) |
| 108 | node5_result = main.ONOSbench.onos_install(node=ONOS5_ip) |
| 109 | install_result = node4_result and node5_result |
| 110 | time.sleep(5) |
| 111 | |
| 112 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 113 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 114 | |
| 115 | elif cluster_count == 7: |
| 116 | |
| 117 | main.log.info("Installing nodes 4 and 5") |
| 118 | node6_result = main.ONOSbench.onos_install(node=ONOS6_ip) |
| 119 | node7_result = main.ONOSbench.onos_install(node=ONOS7_ip) |
| 120 | install_result = node6_result and node7_result |
| 121 | time.sleep(5) |
| 122 | |
| 123 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
| 124 | main.ONOS7cli.start_onos_cli(ONOS7_ip) |
| 125 | ''' |
| 126 | if scale == 1: |
| 127 | if cluster_count == 2: |
| 128 | main.log.info("Installing node 2") |
| 129 | install2_result = main.ONOSbench.onos_install(node=ONOS2_ip) |
| 130 | cli2 = main.ONOS1cli.start_onos_cli(ONOS2_ip) |
| 131 | |
| 132 | if cluster_count == 3: |
| 133 | main.log.info("Installing node 3") |
| 134 | install3_result = main.ONOSbench.onos_install(node=ONOS3_ip) |
| 135 | cli3 = main.ONOS1cli.start_onos_cli(ONOS3_ip) |
| 136 | |