def __enter__(self): """ Instantiates a tcp client and connects to target application The methods executes the following actions 1. Builds a rpyc connection to the target host 2. Copies appInfo file from remote host to a temporary filesystem path in localhost 3. Loads AppInfo object from the copied file 4. Establishes a tcp connection to the target application """ from xpedite.transport.remote import deliver self.remote.__enter__() self.proxy = deliver(self.remote.connection, self.proxy) result = self.gatherFiles(self.appInfo.path) if len(result) != 1: errmsg = 'Failed to gather app info file {} from remote host {} - got {}'.format( self.appInfo.path, self.ip, result) LOGGER.error(errmsg) raise Exception(errmsg) self.appInfo = AppInfo(result[0]) LOGGER.debug('Copied appinfo files from remote host to %s', self.appInfo.path) Environment.__enter__(self) LOGGER.debug( 'initializing remote environment - delivered proxy to %s ', self.ip) return self
def buildTargetApp(args, remote): """ Deliver a target application to the remote host if running remotely """ from xpedite.profiler.app import TargetApp from xpedite.transport.remote import deliver targetApp = TargetApp(args) if remote: targetApp = deliver(remote.connection, targetApp) return targetApp
def makeTargetApp(self, context): """ Deliver a target application to the remote host if running remotely """ from xpedite.profiler.app import TargetApp from xpedite.transport.remote import deliver args = ([self.binary, '-c', '0', '-m', str(context.threadCount), '-t', str(context.txnCount)]) targetApp = TargetApp(args) if self.remote: targetApp = deliver(self.remote.connection, targetApp) return targetApp