コード例 #1
0
 def testInit(self):
     """Test initialization"""
     app = Toolkit.Service.instance()
     app.Initialize("unittest_AGServiceManager", sys.argv[:1])
     self.serviceManager = AGServiceManager(Server(('localhost', 5000)))
     self.serviceManager.Shutdown()
     time.sleep(1)
コード例 #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)
コード例 #3
0
    def testAddRemoveServiceManager(self):
        global nodeService, server
        # Create the Service Manager
        serviceManager = AGServiceManager(server)
        smurl = server.RegisterObject(AGServiceManagerI(serviceManager),
                                      path="/ServiceManager")
        serviceManagerDesc = AGServiceManagerDescription(
            "testServiceManager", smurl)
        nodeService.AddServiceManager(serviceManagerDesc)

        assert serviceManagerDesc in nodeService.GetServiceManagers()
        nodeService.RemoveServiceManager(serviceManagerDesc)
        assert serviceManagerDesc not in nodeService.GetServiceManagers()
コード例 #4
0
    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")
コード例 #5
0
    def __init__(self, args):
        # Initialize Logging
        ntl = Log.handlers.NTEventLogHandler("AG Node Service Manager")
        ntl.setLevel(Log.DEBUG)
        self.log = Log.GetLogger(Log.ServiceManager)
        Log.HandleLoggers(ntl, Log.GetDefaultLoggers())

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

        # Make a Service Manager
        self.serviceManager = AGServiceManager()

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

        # Make a Service Manager Service
        self.server.RegisterObject(self.serviceManager, path='/ServiceManager')

        # tell the world we are here
        self.log.info("Created Service Manager.")
コード例 #6
0
    log = app.GetLog()
    Log.SetDefaultLevel(Log.ServiceManager, Log.DEBUG)

    port = app.GetOption("port")

    # Create the hosting environment
    hostname = app.GetHostname()
    if app.GetOption("secure"):
        context = Toolkit.GetDefaultApplication().GetContext()
        server = SecureServer((hostname, port), context)
    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)