def testAAABegin(self):
        global nodeService, server, log

        # initialize toolkit and environment
        app = Toolkit.Service.instance()
        app.Initialize("NodeService_test", sys.argv[:1])
        log = app.GetLog()

        # Create a Node Service
        nodeService = AGNodeService()

        # Create a hosting environment
        server = Server(('localhost', 4000))

        # get url and print it
        url = server.GetURLBase()
        print "Server URL: %s" % url

        # Create the Node Service Service
        nsurl = server.RegisterObject(AGNodeServiceI(nodeService),
                                      path="/NodeService")

        print "NS URL: %s" % nsurl

        # Tell the world where to find the service
        log.info("Starting service; URI: %s", nsurl)

        # Register a signal handler so we can shut down cleanly
        signal.signal(signal.SIGINT, self.SignalHandler)

        # Run the service
        server.RunInThread()
Ejemplo n.º 2
0
    def test_100_Setup(self):
        global nodeService, server, log, smurl, serviceManager

        # initialize toolkit and environment
        app = Toolkit.Service.instance()
        app.Initialize("Node_test", sys.argv[:1])
        log = app.GetLog()

        # Create a hosting environment
        server = Server(('localhost', 4000))

        # Create a Node Service
        nodeService = AGNodeService()

        # Create the Node Service Service
        nsurl = server.RegisterObject(AGNodeServiceI(nodeService),
                                      path="/NodeService")

        print "NS URL: %s" % nsurl

        # Tell the world where to find the service
        log.info("Started node service; URI: %s", nsurl)

        # Create a Service Manager
        serviceManager = AGServiceManager(server)

        # Create the Service Manager Service
        smurl = server.RegisterObject(AGServiceManagerI(serviceManager),
                                      path="/ServiceManager")

        print "SM URL: %s" % smurl

        serviceManager = AGServiceManagerIW(smurl)

        # Tell the world where to find the service
        log.info("Started service manager; URI: %s", smurl)

        # Run the service
        server.RunInThread()

        # Remove some service packages from the local services
        # dir, to force the service manager to retrieve some packages
        # from the node service
        servicesDir = os.path.join(UserConfig.instance().GetConfigDir(),
                                   'local_services')
        serviceFileList = os.listdir(servicesDir)
        halfTheServices = len(serviceFileList) / 2
        for i in range(halfTheServices):
            print "Removing service dir ", serviceFileList[i]

            dir = os.path.join(servicesDir, serviceFileList[i])

            if os.path.isdir(dir):
                dirFiles = os.listdir(dir)
                # remove files in the dir
                map(lambda f: os.remove(os.path.join(dir, f)), dirFiles)

                # remove the dir
                os.rmdir(dir)
    def __init__(self, args):
        # Initilialize Logging
        self.ntl = Log.handlers.NTEventLogHandler("AG Node Service")
        self.ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.NodeService)
        Log.HandleLoggers(self.ntl, Log.GetDefaultLoggers())

        # Initialize Win32 Service stuff
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

        # Make a node service
        self.nodeService = AGNodeService()

        # Make a hosting environment
        self.server = Server(self._defaultPort)

        # Make a node service service
        self.server.RegisterObject(self.nodeService, path='/NodeService')

        # Tell the world we're here
        self.log.info("Created Node Service.")
Ejemplo n.º 4
0
class Win32NodeService(win32serviceutil.ServiceFramework):
    _svc_name_ = "AGNodeService"
    _svc_display_name_ = "Access Grid Node Service"
    _defaultPort = 11000

    def __init__(self,args):
        # Initilialize Logging
        self.ntl = Log.handlers.NTEventLogHandler("AG Node Service")
        self.ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.NodeService)
        Log.HandleLoggers(self.ntl, Log.GetDefaultLoggers())

        # Initialize Win32 Service stuff
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

        # Make a node service
        self.nodeService = AGNodeService()

        # Make a hosting environment
        self.server = Server(self._defaultPort)

        # Make a node service service
        self.server.RegisterObject(self.nodeService, path='/NodeService')

        # Tell the world we're here
        self.log.info("Created Node Service.")

    def SvcStop(self):
        # Service status report
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

        # Wait for a stop event
        win32event.SetEvent(self.hWaitStop)

        # Stop the server
        self.server.stop()

        # Tell the world
        self.log.info("Stopping Node Service.")

    def SvcDoRun(self):
        # Run the service
        self.server.run_in_thread()
        
        # Tell the world
        self.log.info("Starting service; URI: ", self.nodeService.get_handle())

        # Wait for a stop
        win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
class Win32NodeService(win32serviceutil.ServiceFramework):
    _svc_name_ = "AGNodeService"
    _svc_display_name_ = "Access Grid Node Service"
    _defaultPort = 11000

    def __init__(self, args):
        # Initilialize Logging
        self.ntl = Log.handlers.NTEventLogHandler("AG Node Service")
        self.ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.NodeService)
        Log.HandleLoggers(self.ntl, Log.GetDefaultLoggers())

        # Initialize Win32 Service stuff
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

        # Make a node service
        self.nodeService = AGNodeService()

        # Make a hosting environment
        self.server = Server(self._defaultPort)

        # Make a node service service
        self.server.RegisterObject(self.nodeService, path='/NodeService')

        # Tell the world we're here
        self.log.info("Created Node Service.")

    def SvcStop(self):
        # Service status report
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

        # Wait for a stop event
        win32event.SetEvent(self.hWaitStop)

        # Stop the server
        self.server.stop()

        # Tell the world
        self.log.info("Stopping Node Service.")

    def SvcDoRun(self):
        # Run the service
        self.server.run_in_thread()

        # Tell the world
        self.log.info("Starting service; URI: ", self.nodeService.get_handle())

        # Wait for a stop
        win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
    def testAAABegin(self):
        global server, serviceManager, nodeService, log, smURL

        # initialize toolkit and environment
        app = Toolkit.Service.instance()
        app.Initialize("ServiceManager_test", sys.argv[:1])
        log = app.GetLog()

        # Startup serviceManager to test
        server = Server(('localhost', 5000))
        serviceManager = AGServiceManager(server)
        smURL = server.RegisterObject(AGServiceManagerI(serviceManager),
                                      path="/ServiceManager")

        # Start a node service to help test some of ServiceManager's
        #  functions like AddService()
        nodeService = AGNodeService()
        nsurl = server.RegisterObject(AGNodeServiceI(nodeService),
                                      path="/NodeService")
Ejemplo n.º 7
0
    def __init__(self,args):
        # Initilialize Logging
        self.ntl = Log.handlers.NTEventLogHandler("AG Node Service")
        self.ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.NodeService)
        Log.HandleLoggers(self.ntl, Log.GetDefaultLoggers())

        # Initialize Win32 Service stuff
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

        # Make a node service
        self.nodeService = AGNodeService()

        # Make a hosting environment
        self.server = Server(self._defaultPort)

        # Make a node service service
        self.server.RegisterObject(self.nodeService, path='/NodeService')

        # Tell the world we're here
        self.log.info("Created Node Service.")
Ejemplo n.º 8
0
    else:
        server = InsecureServer((hostname, port))

    # Create the Service Manager
    gServiceManager = AGServiceManager(server)

    # Create the Service Manager Service
    smi = AGServiceManagerI(impl=gServiceManager, auth_method_name=None)
    server.RegisterObject(smi, path="/ServiceManager")
    url = server.FindURLForObject(gServiceManager)
    gServiceManager.SetName('%s:%d' % (hostname, port))
    gServiceManager.SetUri(url)

    if app.GetOption("nodeService") is not None:
        # Create a Node Service
        gNodeService = AGNodeService()
        # Create the Node Service Service
        nsi = AGNodeServiceI(impl=gNodeService, auth_method_name=None)
        server.RegisterObject(nsi, path="/NodeService")
        nsurl = server.FindURLForObject(gNodeService)
        log.info("Starting Node Service URL: %s", nsurl)
        print "Starting Node Service URL:", nsurl

        # Add the service manager to the node service
        smdesc = gServiceManager.GetDescription()
        smdesc.builtin = 1
        gNodeService.serviceManagers[url] = smdesc

    # Register the signal handler so we can shut down cleanly
    signal.signal(signal.SIGINT, SignalHandler)
Ejemplo n.º 9
0
    else:
        server = InsecureServer((hostname, port))

    # Create the Service Manager
    gServiceManager = AGServiceManager(server)

    # Create the Service Manager Service
    smi = AGServiceManagerI(impl=gServiceManager, auth_method_name=None)
    server.RegisterObject(smi, path="/ServiceManager")
    url = server.FindURLForObject(gServiceManager)
    gServiceManager.SetName("%s:%d" % (hostname, port))
    gServiceManager.SetUri(url)

    if app.GetOption("nodeService") is not None:
        # Create a Node Service
        gNodeService = AGNodeService()
        # Create the Node Service Service
        nsi = AGNodeServiceI(impl=gNodeService, auth_method_name=None)
        server.RegisterObject(nsi, path="/NodeService")
        nsurl = server.FindURLForObject(gNodeService)
        log.info("Starting Node Service URL: %s", nsurl)
        print "Starting Node Service URL:", nsurl

        # Add the service manager to the node service
        smdesc = gServiceManager.GetDescription()
        smdesc.builtin = 1
        gNodeService.serviceManagers[url] = smdesc

    # Register the signal handler so we can shut down cleanly
    signal.signal(signal.SIGINT, SignalHandler)