def main(): from AccessGrid.Toolkit import Service # Initialize the toolkit so Access Grid certificates will be available. Service.instance().Initialize("SecureEventService") eventService = SecureEventService( name="test", description="atest", id="testId", type="event", location=("localhost", 7002) ) eventService.CreateChannel("Test") eventService.Start() from twisted.internet import reactor reactor.run()
def main(): from AccessGrid.Toolkit import Service # Initialize the toolkit so Access Grid certificates will be available. Service.instance().Initialize("SecureEventService") eventService = SecureEventService(name="test", description="atest", id="testId", type="event", location=('localhost', 7002)) eventService.CreateChannel("Test") eventService.Start() from twisted.internet import reactor reactor.run()
def main(): """ The main routine of this program. """ global venueServer, log import threading M2Crypto_threading.init() # Init toolkit with standard environment. app = Service.instance() # build options for this application portOption = Option("-p", "--port", type="int", dest="port", default=8000, metavar="PORT", help="Set the port the service manager should run on.") app.AddCmdLineOption(portOption) # set default options app.SetCmdLineDefault('secure', 1) # Try to initialize try: args = app.Initialize("VenueServer") except MissingDependencyError, e: print "Toolkit Initialization failed, exiting." print " Initialization Error: Missing Dependency: ", e sys.exit(-1)
def main(): global gServiceManager, gNodeService, log, running # Create the app app = Service.instance() # build options for this application portOption = Option( "-p", "--port", type="int", dest="port", default=11000, metavar="PORT", help="Set the port the service manager should run on.", ) app.AddCmdLineOption(portOption) nsOption = Option( "-n", "--nodeService", action="store_true", dest="nodeService", help="Run a node service interface too." ) app.AddCmdLineOption(nsOption) # Initialize the application try: app.Initialize(Log.ServiceManager) except MissingDependencyError, e: print "Toolkit Initialization failed, exiting." print " Initialization Error: Missing Dependency: ", e sys.exit(-1)
def main(): """ The main routine of this program. """ global venueServer, log import threading M2Crypto_threading.init() # Init toolkit with standard environment. app = Service.instance() # build options for this application portOption = Option("-p", "--port", type="int", dest="port", default=8000, metavar="PORT", help="Set the port the service manager should run on.") app.AddCmdLineOption(portOption) # set default options app.SetCmdLineDefault('secure',1) # Try to initialize try: args = app.Initialize("VenueServer") except MissingDependencyError, e: print "Toolkit Initialization failed, exiting." print " Initialization Error: Missing Dependency: ", e sys.exit(-1)
def __init__( self ): if self.__class__ == AGService: raise Exception("Can't instantiate abstract class AGService") self.name = str(self.__class__).split('.')[-1] self.uri = 0 self.serviceManagerUri = '' self.resource = None self.executable = "" self.streamDescription = None self.startPriority = "5" self.capabilities = [] self.startPriorityOption = OptionSetParameter("Start Priority", self.startPriority, self.START_PRIORITY_OPTIONS) self.configuration = [ self.startPriorityOption ] self.started = 1 self.enabled = 1 self.running = 1 self.packageFile = "" self.id = GUID() # Variable used by new service with AG3.1 interface to indicate when the server has first been configured # Afterwards relies on streamDescription comparision as with older AG3.0.x services. self.isConfigured = False self.processManager = ProcessManager() app = GetDefaultApplication() if not app: app = Service.instance() self.log = app.GetLog()
def __init__(self): """ The constructor creates a new Venue Server object, initializes that object, then registers signal handlers so the venue can cleanly shutdown in the event of catastrophic signals. **Arguments:** """ # Initialize our state self.multicastAddressAllocator = MulticastAddressAllocator() self.hostname = Service.instance().GetHostname() self.properties = dict() self.venues = dict() self.services = list() self.defaultVenue = None self.houseKeeperFrequency = 30 # The houseKeeper is a task that is doing garbage collection and # other general housekeeping tasks for the Venue Server. self.houseKeeper = Scheduler() # self.houseKeeper.AddTask(self.Checkpoint, # int(self.houseKeeperFrequency), 0, 1) # self.houseKeeper.AddTask(self._CleanupClients, 15, 0, 1) # Start all the periodic tasks registered with the housekeeper thread self.houseKeeper.StartAllTasks()
def main(): global gServiceManager, gNodeService, log, running # Create the app app = Service.instance() # build options for this application portOption = Option("-p", "--port", type="int", dest="port", default=11000, metavar="PORT", help="Set the port the service manager should run on.") app.AddCmdLineOption(portOption) nsOption = Option("-n", "--nodeService", action="store_true", dest="nodeService", help="Run a node service interface too.") app.AddCmdLineOption(nsOption) # Initialize the application try: app.Initialize(Log.ServiceManager) except MissingDependencyError, e: print "Toolkit Initialization failed, exiting." print " Initialization Error: Missing Dependency: ", e sys.exit(-1)
def main(): from AccessGrid.Toolkit import Service service = Service.instance() service.Initialize("SecureGroupMsgServiceTest") groupMsgService = SecureGroupMsgService(location=('localhost', 7002)) groupMsgService.CreateGroup("Test") groupMsgService.Start() from twisted.internet import reactor reactor.run()
def testMemoryHandlers(self): num = GetMemoryHandlers() print "Number of memory handlers in logs before initialization: ", num app = Service.instance() app.Initialize("test") num = GetMemoryHandlers() print "Number of memory handlers in logs after initialization: ", num assert num == 0
def main(): from AccessGrid.Toolkit import Service service = Service.instance() service.Initialize("SecureGroupMsgServiceTest") groupMsgService = SecureGroupMsgService(location=('localhost',7002)) groupMsgService.CreateGroup("Test") groupMsgService.Start() from twisted.internet import reactor reactor.run()
def __init__( self, app=None, builtInServiceManager=None ): if app: self.app = app else: self.app = Service.instance() self.serviceManagers = dict() self.sysNodeConfigDir = self.app.GetToolkitConfig().GetNodeConfigDir() self.userNodeConfigDir = self.app.GetUserConfig().GetNodeConfigDir() self.servicesDir = self.app.GetToolkitConfig().GetNodeServicesDir() self.streamDescriptionList = [] self.builtInServiceManager = builtInServiceManager if builtInServiceManager: builtInServiceManagerDesc = builtInServiceManager.GetDescription() self.serviceManagers[builtInServiceManager.uri] = builtInServiceManager self.uri = 0 self.services = {}
def __init__( self, server, app=None ): self.server = server if app is not None: self.app = app else: self.app = Service.instance() self.name = self.app.GetHostname() self.uri = 0 self.services = dict() self.processManager = ProcessManager() self.registeringServices = dict() self.registerFlag = threading.Event() self.allocator = NetworkAddressAllocator() self.nodeServiceUri = 0 userConfig = self.app.GetUserConfig() self.localServicesDir = userConfig.GetLocalServicesDir() toolkitConfig = self.app.GetToolkitConfig() self.servicesDir = toolkitConfig.GetNodeServicesDir()
def __init__(self, server, app=None): self.server = server if app is not None: self.app = app else: self.app = Service.instance() self.name = self.app.GetHostname() self.uri = 0 self.services = dict() self.processManager = ProcessManager() self.registeringServices = dict() self.registerFlag = threading.Event() self.allocator = NetworkAddressAllocator() self.nodeServiceUri = 0 userConfig = self.app.GetUserConfig() self.localServicesDir = userConfig.GetLocalServicesDir() toolkitConfig = self.app.GetToolkitConfig() self.servicesDir = toolkitConfig.GetNodeServicesDir()
def __init__(self, app=None, builtInServiceManager=None): if app: self.app = app else: self.app = Service.instance() self.serviceManagers = dict() self.sysNodeConfigDir = self.app.GetToolkitConfig().GetNodeConfigDir() self.userNodeConfigDir = self.app.GetUserConfig().GetNodeConfigDir() self.servicesDir = self.app.GetToolkitConfig().GetNodeServicesDir() self.streamDescriptionList = [] self.builtInServiceManager = builtInServiceManager if builtInServiceManager: builtInServiceManagerDesc = builtInServiceManager.GetDescription() self.serviceManagers[ builtInServiceManager.uri] = builtInServiceManager self.uri = 0 self.services = {}
testMain(eventService=eventService, privateId=privateId, channel=group, msgLength=testMessageSize, numMsgs=numMsgs, groupMsgClientClassList=groupMsgClientClassList, multipleClients=multipleClients) from twisted.internet import reactor reactor.run() if __name__ == '__main__': # need to parse for wx here to be able to get wx imports # and the threadedselectreactor that wx requires. useUI = True for arg in sys.argv: if arg.startswith("--perf"): useUI = False # -- Starting the service for testing -- from AccessGrid.EventService import EventService from AccessGrid.Toolkit import Service # Initialize the toolkit so Access Grid certificates will be available. Service.instance().Initialize("InProcessEventService", args=["InProcessEventService.py"]) eventService = EventService(name="test", description="atest", id="testId", type="event", location=('localhost',7002)) eventService.CreateChannel("Test") eventService.Start() # -- Starting the client for testing -- from twisted.internet import reactor main(eventService)
def RunService(service,serviceInterface,unusedCompatabilityArg=None,app=None): import signal, time from AccessGrid.hosting import SecureServer, InsecureServer from AccessGrid.interfaces.AGServiceManager_client import AGServiceManagerIW serviceName = service.GetName() # Initialize the service svc = Service.instance() svc.AddCmdLineOption(Option("-p", "--port", type="int", dest="port", default=9999, metavar="PORT", help="Set the port the service should run on.")) svc.AddCmdLineOption(Option("-s", "--serviceManagerUri", type="string", dest="serviceManagerUri", default=None, metavar="SERVICE_MANAGER_URL", help="URL of ServiceManager to register with")) svc.AddCmdLineOption(Option("-t", "--token", type="string", dest="token", default=None, metavar="TOKEN", help="Token to pass to service manager when registering")) svc.AddCmdLineOption(Option("--test", action='store_true', dest="test", default=None, metavar="TEST", help="Test service and then exit")) svc.Initialize(serviceName) log = svc.GetLog() Log.SetDefaultLevel(serviceName, Log.DEBUG) # Get options port = svc.GetOption("port") serviceManagerUri = svc.GetOption('serviceManagerUri') test = svc.GetOption('test') if test: from AccessGrid.NetworkLocation import MulticastNetworkLocation stream = StreamDescription('test stream', MulticastNetworkLocation('224.2.2.2',20000,1)) stream.capability = service.capabilities resources = service.GetResources() if len(resources) > 0: service.SetResource(resources[0]) service.SetStream(stream) return # Create the server if not app: app = GetDefaultApplication() hostname = app.GetHostname() server = None if svc.GetOption("secure"): server = SecureServer( (hostname, port) ) else: server = InsecureServer( (hostname, port) ) serviceInterface.impl = service serviceInterface.auth_method_name = None # Register the service interface with the server servicePath = '/Services/%s.%s' % (serviceName, str(GUID())) server.RegisterObject(serviceInterface, path = servicePath) # Start the server server.RunInThread() url = server.FindURLForObject(service) log.info("Starting Service URI: %s", url) print "Starting Service URI: %s" % url # Set service data service.SetServiceManagerUrl(serviceManagerUri) service.SetUri(url) # Register with the calling service manager if serviceManagerUri: log.debug("Registering with service manager; url=%s", serviceManagerUri) token = svc.GetOption('token') AGServiceManagerIW(serviceManagerUri).RegisterService(token,url) else: log.info("Service Manager does not exist for service %s"%(url)) # Register the signal handler so we can shut down cleanly # lambda is used to pass the service instance to the # signal handler signal.signal(signal.SIGINT, lambda signum,frame,service=service: SignalHandler(signum,frame,service)) # Loop main thread to catch signals while service.IsRunning(): time.sleep(1) # Shutdown the server server.Stop()
reactor.run() if __name__ == '__main__': # need to parse for wx here to be able to get wx imports # and the threadedselectreactor that wx requires. useUI = True for arg in sys.argv: if arg.startswith("--perf"): useUI = False # -- Starting the service for testing -- from AccessGrid.EventService import EventService from AccessGrid.Toolkit import Service # Initialize the toolkit so Access Grid certificates will be available. Service.instance().Initialize("InProcessEventService", args=["InProcessEventService.py"]) eventService = EventService(name="test", description="atest", id="testId", type="event", location=('localhost', 7002)) eventService.CreateChannel("Test") eventService.Start() # -- Starting the client for testing -- from twisted.internet import reactor main(eventService)