andrew@onlab.us | 1bc346b | 2015-05-21 17:21:16 -0400 | [diff] [blame] | 1 | |
| 2 | """ |
| 3 | Startup related methods for ONOS |
| 4 | |
| 5 | Guidelines: |
| 6 | * Group sequential functionalities together |
| 7 | * Methods should not prohibit cross platform execution |
| 8 | * Return main.TRUE on success or comprehensive error message |
| 9 | on failure (TBD) |
| 10 | """ |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 11 | import time |
andrew@onlab.us | 1bc346b | 2015-05-21 17:21:16 -0400 | [diff] [blame] | 12 | |
| 13 | def __init__( self ): |
| 14 | self.ip = '127.0.0.1' |
| 15 | |
| 16 | def gitPullAndMci( branchName, commitLog=False ): |
| 17 | """ |
| 18 | Pull from branch repository specified and compile changes |
| 19 | If commitLog is True, report commit information |
| 20 | |
| 21 | Any errors / warnings will be handled by respective |
| 22 | driver function calls |
| 23 | """ |
| 24 | co = main.ONOSbench.gitCheckout( branchName ) |
| 25 | gp = main.ONOSbench.gitPull() |
| 26 | ci = main.ONOSbench.cleanInstall() |
| 27 | |
| 28 | if co and gp and ci == main.TRUE: |
| 29 | if commitLog: |
| 30 | main.log.report( 'Commit information - ' ) |
| 31 | main.ONOSbench.getVersion(report=True) |
| 32 | |
| 33 | return main.TRUE |
| 34 | |
| 35 | else: |
| 36 | # TODO: Comprehensive error message |
| 37 | return 'git pull and mci failed' |
| 38 | |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 39 | def initOnosStartupSequence( cellName, appStr, benchIp, mnIp, onosIps ): |
andrew@onlab.us | 1bc346b | 2015-05-21 17:21:16 -0400 | [diff] [blame] | 40 | """ |
| 41 | Startup sequence includes the following: |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 42 | * Create cell file |
| 43 | * Set cell variables on ONOS bench |
| 44 | * Verify cell |
| 45 | * Create ONOS package |
| 46 | * Force install ONOS package |
| 47 | * Start ONOS service |
| 48 | * Start ONOS cli |
andrew@onlab.us | 1bc346b | 2015-05-21 17:21:16 -0400 | [diff] [blame] | 49 | """ |
andrew@onlab.us | 1bc346b | 2015-05-21 17:21:16 -0400 | [diff] [blame] | 50 | |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 51 | # NOTE: leave out create cell file until bug addressed |
| 52 | #cf = main.ONOSbench.createCellFile( benchIp, cellName, mnIp, |
| 53 | # str(appStr), *onosIps ) |
| 54 | numNodes = len(onosIps) |
andrew@onlab.us | 1bc346b | 2015-05-21 17:21:16 -0400 | [diff] [blame] | 55 | |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 56 | sc = main.ONOSbench.setCell( cellName ) |
| 57 | vc = main.ONOSbench.verifyCell() |
| 58 | op = main.ONOSbench.onosPackage() |
| 59 | for addr in onosIps: |
| 60 | oi = main.ONOSbench.onosInstall( node = addr ) |
| 61 | |
| 62 | time.sleep( 5 ) |
| 63 | |
| 64 | iu = main.TRUE |
| 65 | for node in onosIps: |
| 66 | iu = iu and main.ONOSbench.isup( node ) |
| 67 | |
| 68 | cli = main.TRUE |
| 69 | for node in range( 0, numNodes ): |
| 70 | cli = cli and main.CLIs[node].startOnosCli( onosIps[node] ) |
| 71 | |
| 72 | if sc and vc and op and oi and iu and cli == main.TRUE: |
| 73 | return main.TRUE |
| 74 | else: |
| 75 | return main.FALSE |
| 76 | |