blob: 3e205d6df65355a5945838267ed161b756a8be74 [file] [log] [blame]
andrew@onlab.us9da18f22015-05-28 21:10:24 -04001"""
2Methods related to application interaction
3
4"""
5
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -04006
7def __init__( self ):
8 self.ip = '127.0.0.1'
9
10def 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.us9da18f22015-05-28 21:10:24 -040018 main.log.error( 'Please pass in a list of strings for args' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040019 return main.FALSE
20
21 if not isinstance( nodeToActivateFrom, ( int ) ) or \
22 nodeToActivateFrom < 0:
andrew@onlab.us9da18f22015-05-28 21:10:24 -040023 main.log.error( 'Incorrect node specified' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040024 return main.FALSE
25
andrew@onlab.us9da18f22015-05-28 21:10:24 -040026 # 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.us2bcfd8f2015-05-28 19:17:51 -040031 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.us9da18f22015-05-28 21:10:24 -040035 main.log.error( 'Invalid app name given' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040036 return main.FALSE
andrew@onlab.us9da18f22015-05-28 21:10:24 -040037
38 try:
39 # NOTE: assumes node 1 is always activating application
40 appOutput = main.CLIs[nodeToActivateFrom].activateApp(
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040041 main.appList[app] )
andrew@onlab.us9da18f22015-05-28 21:10:24 -040042 except KeyError:
43 main.log.error( 'There was an error with the key '+
andrew@onlab.usd2d36fc2015-05-29 14:27:54 -040044 str(app) + '. Check the appList dictionary' )
andrew@onlab.us9da18f22015-05-28 21:10:24 -040045 return main.FALSE
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040046
47 return main.TRUE
48
andrew@onlab.us9da18f22015-05-28 21:10:24 -040049def deactivate( apps, nodeToDeactivateFrom=0 ):
50 """
51 Deactivate specified applications from node specified
52
53 """
54 main.log.report( 'deactivate implment me' )
55
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040056def isAppInstallSuccess():
57 """
58 Check the app list across clusters to determine
59 that apps have been installed successfully
60
61 """
62
andrew@onlab.us9da18f22015-05-28 21:10:24 -040063 main.log.report( 'isAppInstallSuccess implement me' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040064