andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 1 | """ |
| 2 | Methods related to application interaction |
| 3 | |
| 4 | """ |
| 5 | |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 6 | |
| 7 | def __init__( self ): |
| 8 | self.ip = '127.0.0.1' |
| 9 | |
| 10 | def activate( apps, nodeToActivateFrom=0 ): |
| 11 | """ |
| 12 | Activate specified applications from node specified |
| 13 | |
| 14 | Ex) apps = ['metrics', 'fwd'] |
| 15 | nodeToActivateFrom = range( 0, nodes ) |
| 16 | """ |
| 17 | if isinstance( apps, ( int, basestring ) ): |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 18 | main.log.error( 'Please pass in a list of strings for args' ) |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 19 | return main.FALSE |
| 20 | |
| 21 | if not isinstance( nodeToActivateFrom, ( int ) ) or \ |
| 22 | nodeToActivateFrom < 0: |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 23 | main.log.error( 'Incorrect node specified' ) |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 24 | return main.FALSE |
| 25 | |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 26 | # TODO: Start log capture and listen for exceptions |
| 27 | # and errors. Also investigate possible keywords |
| 28 | # to listen for when activating applications |
| 29 | |
| 30 | |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 31 | for app in apps: |
| 32 | # Check if app str in appList is in the main scope |
| 33 | # definition main.appList |
| 34 | if app not in main.appList: |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 35 | main.log.error( 'Invalid app name given' ) |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 36 | return main.FALSE |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 37 | |
| 38 | try: |
| 39 | # NOTE: assumes node 1 is always activating application |
| 40 | appOutput = main.CLIs[nodeToActivateFrom].activateApp( |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 41 | main.appList[app] ) |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 42 | except KeyError: |
| 43 | main.log.error( 'There was an error with the key '+ |
andrew@onlab.us | d2d36fc | 2015-05-29 14:27:54 -0400 | [diff] [blame] | 44 | str(app) + '. Check the appList dictionary' ) |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 45 | return main.FALSE |
andrew@onlab.us | 19b5e04 | 2015-06-05 13:14:02 -0400 | [diff] [blame] | 46 | except Exception: |
| 47 | main.log.error( 'Uncaught exception error while ' + |
| 48 | 'activating applications: ' + str(app) ) |
| 49 | return main.FALSE |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 50 | |
| 51 | return main.TRUE |
| 52 | |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 53 | def deactivate( apps, nodeToDeactivateFrom=0 ): |
| 54 | """ |
| 55 | Deactivate specified applications from node specified |
| 56 | |
| 57 | """ |
| 58 | main.log.report( 'deactivate implment me' ) |
| 59 | |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 60 | def isAppInstallSuccess(): |
| 61 | """ |
| 62 | Check the app list across clusters to determine |
| 63 | that apps have been installed successfully |
| 64 | |
| 65 | """ |
| 66 | |
andrew@onlab.us | 9da18f2 | 2015-05-28 21:10:24 -0400 | [diff] [blame] | 67 | main.log.report( 'isAppInstallSuccess implement me' ) |
andrew@onlab.us | 2bcfd8f | 2015-05-28 19:17:51 -0400 | [diff] [blame] | 68 | |