blob: 5410c3236e72ee2ac9f4e9f27368cacb0cacedd6 [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.us19b5e042015-06-05 13:14:02 -040046 except Exception:
47 main.log.error( 'Uncaught exception error while ' +
48 'activating applications: ' + str(app) )
49 return main.FALSE
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040050
51 return main.TRUE
52
andrew@onlab.us9da18f22015-05-28 21:10:24 -040053def deactivate( apps, nodeToDeactivateFrom=0 ):
54 """
55 Deactivate specified applications from node specified
56
57 """
58 main.log.report( 'deactivate implment me' )
59
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040060def isAppInstallSuccess():
61 """
62 Check the app list across clusters to determine
63 that apps have been installed successfully
64
65 """
66
andrew@onlab.us9da18f22015-05-28 21:10:24 -040067 main.log.report( 'isAppInstallSuccess implement me' )
andrew@onlab.us2bcfd8f2015-05-28 19:17:51 -040068