def testConnect(self): "Test connection through nameserver" ns = PyroUtil.connectNameServer("localhost", 5000, "mmp-secret-key") print("Connected to nameserver") for i, app in enumerate(self.apps): # what is localport?? # tunnel=PyroUtil.sshTunnel(remoteHost='localhost',userName='******'%(2000+i),localPort=2000+i,remotePort=4000+i,sshClient='ssh',options='-oStrictHostKeyChecking=no',sshHost='') # print('Tunnel established') a = PyroUtil.connectApp(ns, PyroUtil.getNSAppName(self.jobname, app.__class__.__name__)) print("Connected to App through Pyro") self.assert_(a) appsig = a.getApplicationSignature() print(appsig) tunnel.terminate()
def testConnect(self): 'Test connection through nameserver' ns=PyroUtil.connectNameServer('localhost',5000,'mmp-secret-key') print('Connected to nameserver') for i,app in enumerate(self.apps): # what is localport?? #tunnel=PyroUtil.sshTunnel(remoteHost='localhost',userName='******'%(2000+i),localPort=2000+i,remotePort=4000+i,sshClient='ssh',options='-oStrictHostKeyChecking=no',sshHost='') #print('Tunnel established') a=PyroUtil.connectApp(ns,PyroUtil.getNSAppName(self.jobname,app.__class__.__name__)) print('Connected to App through Pyro') self.assert_(a) appsig=a.getApplicationSignature() print(appsig) tunnel.terminate()
def main(): global host global jobmanname host = 'ksm.fsv.cvut.cz' port = 9090 hkey ="" nshost=None ssh = False#ssh flag (set to tru if ssh tunnel need to be established) log = logging.getLogger() try: opts, args = getopt.getopt(sys.argv[1:], "h:j:p:k:u:n:r:t") # print(opts, args) except getopt.GetoptError as err: # print help information and exit: print(str(err)) # will print something like "option -a not recognized" usage() sys.exit(2) for o, a in opts: # if o in ("-p"): # port = int(a) # elif o in ("-h"): # host = a if o in ("-j"): jobmanname = a elif o in ("-k"): hkey = a elif o in ("-t"): ssh = True elif o in ("-u"): username = a elif o in ("-n"): nshost = a elif o in ("-r"): nsport = int(a) else: assert False, "unhandled option" # print("huhu:"+host+str(port)) if (not nshost): usage() sys.exit(2) #locate nameserver ns = PyroUtil.connectNameServer(nshost, nsport, hkey) # locate remote jobManager application, request remote proxy jobManUri = ns.lookup(jobmanname) #get local port of jabmanager (from uri) jobmannatport = int(re.search('(\d+)$',str(jobManUri)).group(0)) #extablish secure ssh tunnel connection if ssh: (host, jobmannatport, jobManNatHost, port) = PyroUtil.getNSConnectionInfo(ns, jobmanname) tunnel = PyroUtil.sshTunnel(remoteHost=host, userName=username, localPort=jobmannatport, remotePort=port, sshClient='ssh') jobMan = PyroUtil.connectApp(ns, jobmanname) #ssh flag (set to True if ssh tunnel need to be established) ssh = False curses.wrapper(processor, jobMan) if ssh: tunnel.terminate()
else: sshHost = apprecord[conf.appIndx_SshHost] try: tunnel = PyroUtil.sshTunnel( remoteHost=apprecord[conf.appIndx_ServerName], userName=apprecord[conf.appIndx_UserName], localPort=apprecord[conf.appIndx_NATPort], remotePort=apprecord[conf.appIndx_RemotePort], sshClient=apprecord[conf.appIndx_SshClient], options=apprecord[conf.appIndx_Options], sshHost=sshHost) # connect to individual applications app = PyroUtil.connectApp( ns, PyroUtil.getNSAppName(conf.jobname, apprecord[conf.appIndx_Name])) if app: appsig = app.getApplicationSignature() msg = "Successfully connected to %-30s (%4.2f s)" % ( appsig, timeTime.time() - starti) conf.log.info(msg) conf.log.info("Time elapsed %f s" % (timeTime.time() - starti)) else: msg = "Unable to connect to " + apprecord[conf.appIndx_Name] conf.log.error(msg) results.append(msg) finally: conf.log.debug("Closing ssh tunnel") if tunnel: tunnel.terminate()
#Find if we need different ssh server for authentication if apprecord[conf.appIndx_SshHost] == '': sshHost = apprecord[conf.appIndx_ServerName] else: sshHost = apprecord[conf.appIndx_SshHost] try: tunnel = PyroUtil.sshTunnel(remoteHost=apprecord[conf.appIndx_ServerName], userName=apprecord[conf.appIndx_UserName], localPort=apprecord[conf.appIndx_NATPort], remotePort=apprecord[conf.appIndx_RemotePort], sshClient=apprecord[conf.appIndx_SshClient], options=apprecord[conf.appIndx_Options], sshHost=sshHost) # connect to individual applications app = PyroUtil.connectApp(ns, PyroUtil.getNSAppName(conf.jobname, apprecord[conf.appIndx_Name])) if app: appsig=app.getApplicationSignature() msg = "Successfully connected to %-30s (%4.2f s)"%(appsig, timeTime.time()-starti) conf.logger.info(msg) conf.logger.info("Time elapsed %f s" % (timeTime.time()-starti) ) else: msg = "Unable to connect to " + apprecord[conf.appIndx_Name] conf.logger.error(msg) results.append(msg) finally: conf.logger.debug("Closing ssh tunnel") if tunnel: tunnel.terminate() print ("=========SUMMARY============") for r in results:
port_col = 35 user_col = 41 time_col = 70 #locate nameserver ns = PyroUtil.connectNameServer(nshost, nsport, hkey) # locate remote jobManager application, request remote proxy jobManUri = ns.lookup(jobmanname) #get local port of jabmanager (from uri) jobmannatport = int(re.search('(\d+)$',str(jobManUri)).group(0)) #extablish secure ssh tunnel connection if ssh: tunnel = PyroUtil.sshTunnel(remoteHost=host, userName=username, localPort=jobmannatport, remotePort=port, sshClient='ssh') jobMan = PyroUtil.connectApp(ns, jobmanname) #ssh flag (set to True if ssh tunnel need to be established) ssh = False curses.wrapper(processor, jobMan) if ssh: tunnel.terminate() ###########################################################
userName=cConf.tracerUser, localPort=cConf.tracerNatPort, remotePort=cConf.tracerPort, sshClient=cConf.sshClient, options=cConf.options, sshHost=cConf.sshHost) comsolTunnel = PyroUtil.sshTunnel(remoteHost=cConf.mieServer, userName=cConf.mieUser, localPort=cConf.mieNatPort, remotePort=cConf.miePort, sshClient=cConf.sshClient, options=cConf.options, sshHost=cConf.sshHost) mieApp = PyroUtil.connectApp(ns, cConf.mieID) tracerApp = PyroUtil.connectApp(ns, cConf.tracerID) comsolApp = PyroUtil.connectApp(ns, cConf.comsolID) # Point data conversion to false. Speeds up testing #tracerApp._convertPointData = False #does not work over pyro4... not exposed logger.info('Applications loaded:') print(mieApp) print(tracerApp) print(comsolApp) # Connect fields logger.info('Connecting Fields...') # old way to connect fields: fHeatSurf = comsolApp.getField(FieldID.FID_Thermal_absorption_surface, 0)
def main(): global host global jobmanname host = 'ksm.fsv.cvut.cz' port = 9090 hkey ="" ssh = False#ssh flag (set to tru if ssh tunnel need to be established) logger = logging.getLogger() try: opts, args = getopt.getopt(sys.argv[1:], "h:j:p:k:u:n:r:t") print(opts, args) except getopt.GetoptError as err: # print help information and exit: print(str(err)) # will print something like "option -a not recognized" usage() sys.exit(2) for o, a in opts: if o in ("-p"): port = int(a) elif o in ("-h"): host = a elif o in ("-j"): jobmanname = a elif o in ("-k"): hkey = a elif o in ("-t"): ssh = True elif o in ("-u"): username = a elif o in ("-n"): nshost = a elif o in ("-r"): nsport = int(a) else: assert False, "unhandled option" print("huhu:"+host+str(port)) #locate nameserver ns = PyroUtil.connectNameServer(nshost, nsport, hkey) # locate remote jobManager application, request remote proxy jobManUri = ns.lookup(jobmanname) #get local port of jabmanager (from uri) jobmannatport = int(re.search('(\d+)$',str(jobManUri)).group(0)) #extablish secure ssh tunnel connection if ssh: tunnel = PyroUtil.sshTunnel(remoteHost=host, userName=username, localPort=jobmannatport, remotePort=port, sshClient='ssh') jobMan = PyroUtil.connectApp(ns, jobmanname) #ssh flag (set to True if ssh tunnel need to be established) ssh = False curses.wrapper(processor, jobMan) if ssh: tunnel.terminate()
remotePort=cConf.tracerPort, sshClient=cConf.sshClient, options=cConf.options, sshHost=cConf.sshHost) comsolTunnel = PyroUtil.sshTunnel(remoteHost=cConf.mieServer, userName=cConf.mieUser, localPort=cConf.mieNatPort, remotePort=cConf.miePort, sshClient=cConf.sshClient, options=cConf.options, sshHost=cConf.sshHost) mieApp = PyroUtil.connectApp(ns, cConf.mieID) tracerApp = PyroUtil.connectApp(ns, cConf.tracerID) comsolApp = PyroUtil.connectApp(ns, cConf.comsolID) # Point data conversion to false. Speeds up testing #tracerApp._convertPointData = False #does not work over pyro4... not exposed logger.info('Applications loaded:') print(mieApp) print(tracerApp) print(comsolApp) # Connect fields logger.info('Connecting Fields...') # old way to connect fields: