def RunController(self): """Main entry point for the controller.""" print ' '.join(sys.argv) common_lib.InitLogging() self._registration_server.Start() error = None tb = None try: self.SetUp() self.RunTest() except Exception as e: # Defer raising exceptions until after TearDown is called. error = e tb = sys.exc_info()[-1] try: self.TearDown() except Exception as e: if not tb: error = e tb = sys.exc_info()[-1] self._registration_server.Shutdown() task_controller.TaskController.ReleaseAllTasks() if error: raise error, None, tb #pylint: disable=raising-bad-type
def main(): print ' '.join(sys.argv) common_lib.InitLogging() logging.info('Task starting') parser = argparse.ArgumentParser() parser.add_argument( '--otp', help='One time token used to authenticate with the host') parser.add_argument('--controller', help='The ip address of the controller machine') parser.add_argument( '--controller-port', type=int, help='The port the controllers registration server is on') parser.add_argument('--idle-timeout', type=int, default=common_lib.DEFAULT_TIMEOUT_SECS, help='The idle timeout for the rpc server in seconds') args, _ = parser.parse_known_args() my_port = common_lib.GetUnusedPort() logging.info( 'Registering with registration server at %s:%d using OTP "%s"', args.controller, args.controller_port, args.otp) rpc_server.RpcServer.Connect(args.controller, args.controller_port).RegisterTask( args.otp, common_lib.MY_IP, my_port) server = rpc_server.RpcServer(args.controller, my_port, args.idle_timeout) server.serve_forever() logging.info('Server shutdown complete') return 0
def RunController(self): """Main entry point for the controller.""" print ' '.join(sys.argv) common_lib.InitLogging() self._discovery_server.Start() error = None tb = None try: self.SetUp() self.Task() except Exception as e: # Defer raising exceptions until after TearDown and _TearDown are called. error = e tb = sys.exc_info()[-1] try: self.TearDown() except Exception as e: # Defer raising exceptions until after _TearDown is called. # Note that an error raised here will obscure any errors raised # previously. error = e tb = sys.exc_info()[-1] self._discovery_server.Shutdown() client_lib.ClientController.ReleaseAllControllers() if error: raise error, None, tb #pylint: disable=raising-bad-type
def _HandleSetUpClass(cls): """Performs common class-level setup operations. This method performs test-wide setup such as starting the registration server and then calls the original setUpClass method.""" try: common_lib.InitLogging() cls._LogInfoBanner('setUpClass', 'Performs class level setup.') cls._SetUpFramework() cls._OriginalSetUpClassMethod() except: # Make sure we tear down in case of any exceptions cls._HandleTearDownClass(setup_failed=True) exc_info = sys.exc_info() logging.error('', exc_info=exc_info) raise exc_info[0], exc_info[1], exc_info[2]
def main(): print ' '.join(sys.argv) common_lib.InitLogging() logging.info('Client controller starting') parser = argparse.ArgumentParser() parser.add_argument( '--otp', help='One time token used to authenticate with the host') parser.add_argument('--host', help='The ip address of the host') parser.add_argument('--idle-timeout', type=int, default=common_lib.DEFAULT_TIMEOUT_SECS, help='The idle timeout for the rpc server in seconds') args, _ = parser.parse_known_args() logging.info('Registering with discovery server at %s using OTP %s', args.host, args.otp) server = common_lib.ConnectToServer(args.host).RegisterClient( args.otp, common_lib.MY_IP) server = client_rpc_server.RPCServer(args.host, args.idle_timeout) server.serve_forever() return 0