Пример #1
0
    def setUp(self):
        nshost, nsport = 'localhost', 5000
        # 2000+i: ssh forwarder (forwards to localhost:3000+i); username testuser-2001 (number is port number), password is always mmp-secret-key
        # 3000+i: mupif application server
        # 4000+i: natport
        # 5000:   nameserver

        # setup nameserver

        self.nsloop = multiprocessing.Process(target=Pyro4.naming.startNSloop,
                                              kwargs=dict(host=nshost,
                                                          port=nsport,
                                                          hmac=self.hkey))
        self.nsloop.start()
        time.sleep(2)  # some time for nameserver to start

        # setup apps
        self.apps = LocalApp(
            "/dev/null"
        ),  # CelsianApp("/dev/null"),MicressApp("/dev/null"),MmpraytracerApp("/dev/null")
        for i, app in enumerate(self.apps):
            # start "remote" servers (locally)
            print('Starting', app)
            PyroUtil.runAppServer(server='localhost',
                                  port=3000 + i,
                                  nathost='localhost',
                                  natport=4000 + i,
                                  nshost=nshost,
                                  nsport=nsport,
                                  nsname=PyroUtil.getNSAppName(
                                      self.jobname, app.__class__.__name__),
                                  hkey=self.hkey,
                                  app=app)
Пример #2
0
    def setUp(self):
        nshost, nsport = "localhost", 5000
        # 2000+i: ssh forwarder (forwards to localhost:3000+i); username testuser-2001 (number is port number), password is always mmp-secret-key
        # 3000+i: mupif application server
        # 4000+i: natport
        # 5000:   nameserver

        # setup nameserver

        self.nsloop = multiprocessing.Process(
            target=Pyro4.naming.startNSloop, kwargs=dict(host=nshost, port=nsport, hmac=self.hkey)
        )
        self.nsloop.start()
        time.sleep(2)  # some time for nameserver to start

        # setup apps
        self.apps = (
            LocalApp("/dev/null"),
        )  # CelsianApp("/dev/null"),MicressApp("/dev/null"),MmpraytracerApp("/dev/null")
        for i, app in enumerate(self.apps):
            # start "remote" servers (locally)
            print("Starting", app)
            PyroUtil.runAppServer(
                server="localhost",
                port=3000 + i,
                nathost="localhost",
                natport=4000 + i,
                nshost=nshost,
                nsport=nsport,
                nsname=PyroUtil.getNSAppName(self.jobname, app.__class__.__name__),
                hkey=self.hkey,
                app=app,
            )
Пример #3
0
 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()
Пример #4
0
 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()
Пример #5
0
import conf
from mupif import Application
from mupif import PyroUtil

#nameserver app name
appname='local'

class local(Application.Application):
    """
    Mupif interface to Local dummy task

    """
    def __init__(self, file):
        super(local, self).__init__(file) #call basereturn
    def getApplicationSignature(self):
        return "local@"+ socket.gethostbyaddr(socket.gethostname())[0]+" version 1.0"

#create application
app = local("/dev/null")
# run the application server
appRecord = [item for item in conf.apps if item[0] == appname][0]
PyroUtil.runAppServer(server=appRecord[conf.appIndx_ServerName],
                      port=appRecord[conf.appIndx_RemotePort], 
                      nathost=conf.nathost, natport=appRecord[conf.appIndx_NATPort], 
                      nshost=conf.nshost, nsport=conf.nsport, 
                      nsname=PyroUtil.getNSAppName(conf.jobname, appname), hkey=conf.hkey, app=app)




Пример #6
0
appname = 'micress'


class micress(Application.Application):
    """
    Mupif interface to micress (microstructure evolution simulation tool) 

    """
    def __init__(self, file):
        super(micress, self).__init__(file)  #call base
        return

    def getApplicationSignature(self):
        return "Micress@" + socket.gethostbyaddr(
            socket.gethostname())[0] + " version 1.0"


#create application
app = micress("/dev/null")
# run the application server
appRecord = conf.apps['micress']
PyroUtil.runAppServer(server=appRecord.serverName,
                      port=appRecord.remotePort,
                      nathost=conf.nathost,
                      natport=appRecord.natPort,
                      nshost=conf.nshost,
                      nsport=conf.nsport,
                      appName=PyroUtil.getNSAppName(conf.jobname, appname),
                      hkey=conf.hkey,
                      app=app)
Пример #7
0
import conf
from mupif import Application
from mupif import PyroUtil

#nameserver app name
appname='local'

class local(Application.Application):
    """
    Mupif interface to Local dummy task

    """
    def __init__(self, file):
        super(local, self).__init__(file) #call basereturn
    def getApplicationSignature(self):
        return "local@"+ socket.gethostbyaddr(socket.gethostname())[0]+" version 1.0"

#create application
app = local("/dev/null")
# run the application server
appRecord = conf.apps['local']
PyroUtil.runAppServer(server=appRecord.serverName,
                      port=appRecord.remotePort, 
                      nathost=conf.nathost, natport=appRecord.natPort, 
                      nshost=conf.nshost, nsport=conf.nsport, 
                      appName=PyroUtil.getNSAppName(conf.jobname, appname), hkey=conf.hkey, app=app)




Пример #8
0

class local(Application.Application):
    """
    Mupif interface to Local dummy task

    """

    def __init__(self, file):
        super(local, self).__init__(file)  # call basereturn

    def getApplicationSignature(self):
        return "local@" + socket.gethostbyaddr(socket.gethostname())[0] + " version 1.0"


# create application
app = local("/dev/null")
# run the application server
appRecord = conf.apps["local"]
PyroUtil.runAppServer(
    server=appRecord.serverName,
    port=appRecord.remotePort,
    nathost=conf.nathost,
    natport=appRecord.natPort,
    nshost=conf.nshost,
    nsport=conf.nsport,
    nsname=PyroUtil.getNSAppName(conf.jobname, appname),
    hkey=conf.hkey,
    app=app,
)
Пример #9
0
        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()

print("=========SUMMARY============")
Пример #10
0
    #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:
Пример #11
0
    #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.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()

print ("=========SUMMARY============")
for r in results: