From 51c20f6f85d76bc14f394221a8836d2aac9a1aea Mon Sep 17 00:00:00 2001 From: Jimmy Bergman Date: Wed, 22 Jun 2011 12:01:18 +0200 Subject: Add a socket server responding with an allowing flash socket policy for all requests from flash on port 843 to nova-vncproxy --- bin/nova-vncproxy | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-vncproxy b/bin/nova-vncproxy index ccb97e3a3..467d1eba3 100755 --- a/bin/nova-vncproxy +++ b/bin/nova-vncproxy @@ -39,6 +39,8 @@ from nova import wsgi from nova import version from nova.vnc import auth from nova.vnc import proxy +from twisted.internet import protocol, reactor +from twisted.protocols import basic LOG = logging.getLogger('nova.vnc-proxy') @@ -62,6 +64,16 @@ flags.DEFINE_flag(flags.HelpFlag()) flags.DEFINE_flag(flags.HelpshortFlag()) flags.DEFINE_flag(flags.HelpXMLFlag()) +class FlashSocketPolicyProtocol(basic.LineReceiver): + delimiter = "\0" + + def lineReceived(self, request): + if '' in request: + self.transport.write('' % (FLAGS.vncproxy_port)) + self.transport.loseConnection() + +class FlashSocketPolicyFactory(protocol.ServerFactory): + protocol = FlashSocketPolicyProtocol if __name__ == "__main__": utils.default_flagfile() @@ -96,6 +108,11 @@ if __name__ == "__main__": service.serve() - server = wsgi.Server() - server.start(with_auth, FLAGS.vncproxy_port, host=FLAGS.vncproxy_host) - server.wait() + flash_socket_policy_pid = os.fork() + if flash_socket_policy_pid == 0: + reactor.listenTCP(843, FlashSocketPolicyFactory()) + reactor.run() + else: + server = wsgi.Server() + server.start(with_auth, FLAGS.vncproxy_port, host=FLAGS.vncproxy_host) + server.wait() -- cgit From 3d1c8463d80932ddbe677ea1b8aee357642018a8 Mon Sep 17 00:00:00 2001 From: Jimmy Bergman Date: Thu, 23 Jun 2011 13:34:01 +0200 Subject: Change so that the flash socket policy server is using eventlet instead of twisted and is running in the same process as the main vnx proxy --- bin/nova-vncproxy | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'bin') diff --git a/bin/nova-vncproxy b/bin/nova-vncproxy index 467d1eba3..60e01e7f8 100755 --- a/bin/nova-vncproxy +++ b/bin/nova-vncproxy @@ -39,8 +39,6 @@ from nova import wsgi from nova import version from nova.vnc import auth from nova.vnc import proxy -from twisted.internet import protocol, reactor -from twisted.protocols import basic LOG = logging.getLogger('nova.vnc-proxy') @@ -64,16 +62,16 @@ flags.DEFINE_flag(flags.HelpFlag()) flags.DEFINE_flag(flags.HelpshortFlag()) flags.DEFINE_flag(flags.HelpXMLFlag()) -class FlashSocketPolicyProtocol(basic.LineReceiver): - delimiter = "\0" +def handle_flash_socket_policy(socket): + LOG.info(_("Received connection on flash socket policy port")) - def lineReceived(self, request): - if '' in request: - self.transport.write('' % (FLAGS.vncproxy_port)) - self.transport.loseConnection() - -class FlashSocketPolicyFactory(protocol.ServerFactory): - protocol = FlashSocketPolicyProtocol + fd = socket.makefile('rw') + expected_command = "" + if expected_command in fd.read(len(expected_command)+1): + LOG.info(_("Received valid flash socket policy request")) + fd.write('' % (FLAGS.vncproxy_port)) + fd.flush() + socket.close() if __name__ == "__main__": utils.default_flagfile() @@ -108,11 +106,7 @@ if __name__ == "__main__": service.serve() - flash_socket_policy_pid = os.fork() - if flash_socket_policy_pid == 0: - reactor.listenTCP(843, FlashSocketPolicyFactory()) - reactor.run() - else: - server = wsgi.Server() - server.start(with_auth, FLAGS.vncproxy_port, host=FLAGS.vncproxy_host) - server.wait() + server = wsgi.Server() + server.start(with_auth, FLAGS.vncproxy_port, host=FLAGS.vncproxy_host) + server.start_tcp(handle_flash_socket_policy, 843, host=FLAGS.vncproxy_host) + server.wait() -- cgit From 1732c373aa21fb7493b8fb50dd64bdf9425bf70b Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Mon, 4 Jul 2011 23:48:05 +0400 Subject: Gracefull shutdown of nova-api. --- bin/nova-api | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index fff67251f..71c68f24d 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -24,6 +24,7 @@ Starts both the EC2 and OpenStack APIs in separate processes. """ import os +import signal import sys possible_topdir = os.path.normpath(os.path.join(os.path.abspath( @@ -34,11 +35,15 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils +def create_kill_handler(launcher): + def handle(signal, frame): + launcher.stop() + return handle def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) - + ec2 = nova.service.WSGIService("ec2") osapi = nova.service.WSGIService("osapi") @@ -46,10 +51,9 @@ def main(): launcher.launch_service(ec2) launcher.launch_service(osapi) - try: - launcher.wait() - except KeyboardInterrupt: - launcher.stop() + signal.signal(signal.SIGTERM, create_kill_handler(launcher)) + + launcher.wait() if __name__ == '__main__': -- cgit From fde44cdf69ad1884adf7007ae432438de5bcd664 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 00:24:55 +0400 Subject: Signal handler cleanup, proper ^C handling. --- bin/nova-api | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 71c68f24d..a51eb1b6e 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -35,11 +35,6 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils -def create_kill_handler(launcher): - def handle(signal, frame): - launcher.stop() - return handle - def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) @@ -51,9 +46,12 @@ def main(): launcher.launch_service(ec2) launcher.launch_service(osapi) - signal.signal(signal.SIGTERM, create_kill_handler(launcher)) - - launcher.wait() + signal.signal(signal.SIGTERM, lambda *_: launcher.stop()) + + try: + launcher.wait() + except KeyboardInterrupt: + launcher.stop() if __name__ == '__main__': -- cgit From c3229ec37f117d4fe8fc280b726a2e410a4b42a0 Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 01:09:00 +0400 Subject: Formatting fix. --- bin/nova-api | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index a51eb1b6e..ccbb103f4 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -27,6 +27,7 @@ import os import signal import sys + possible_topdir = os.path.normpath(os.path.join(os.path.abspath( sys.argv[0]), os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): -- cgit From 6b6fd2fe87ff23f3c056ba076218917404bd024a Mon Sep 17 00:00:00 2001 From: Nikolay Sokolov Date: Wed, 6 Jul 2011 01:31:04 +0400 Subject: PEP8 passed. --- bin/nova-api | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index ccbb103f4..4c5164ea1 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -36,10 +36,11 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils + def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) - + ec2 = nova.service.WSGIService("ec2") osapi = nova.service.WSGIService("osapi") @@ -48,7 +49,7 @@ def main(): launcher.launch_service(osapi) signal.signal(signal.SIGTERM, lambda *_: launcher.stop()) - + try: launcher.wait() except KeyboardInterrupt: -- cgit From efb5363356b13c3492ae895a1778428d06e6ca9c Mon Sep 17 00:00:00 2001 From: Jimmy Bergman Date: Thu, 7 Jul 2011 08:10:45 +0200 Subject: pep8 compliance --- bin/nova-vncproxy | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-vncproxy b/bin/nova-vncproxy index 5d3dbf610..bdbb30a7f 100755 --- a/bin/nova-vncproxy +++ b/bin/nova-vncproxy @@ -62,14 +62,17 @@ flags.DEFINE_flag(flags.HelpFlag()) flags.DEFINE_flag(flags.HelpshortFlag()) flags.DEFINE_flag(flags.HelpXMLFlag()) + def handle_flash_socket_policy(socket): LOG.info(_("Received connection on flash socket policy port")) fd = socket.makefile('rw') expected_command = "" - if expected_command in fd.read(len(expected_command)+1): - LOG.info(_("Received valid flash socket policy request")) - fd.write('' % (FLAGS.vncproxy_port)) + if expected_command in fd.read(len(expected_command) + 1): + LOG.info(_("Received valid flash socket policy request")) + fd.write('' % (FLAGS.vncproxy_port)) fd.flush() socket.close() -- cgit From 209bf1ef495d2d599ef51e207e8de0694dec9790 Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Fri, 8 Jul 2011 17:12:14 -0500 Subject: Add a flag to disable ec2 or osapi. --- bin/nova-api | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 4c5164ea1..fe8e83366 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -36,17 +36,21 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): import nova.service import nova.utils +from nova import flags + + +FLAGS = flags.FLAGS + def main(): """Launch EC2 and OSAPI services.""" nova.utils.Bootstrapper.bootstrap_binary(sys.argv) - ec2 = nova.service.WSGIService("ec2") - osapi = nova.service.WSGIService("osapi") - launcher = nova.service.Launcher() - launcher.launch_service(ec2) - launcher.launch_service(osapi) + + for api in FLAGS.enabled_apis: + service = nova.service.WSGIService(api) + launcher.launch_service(service) signal.signal(signal.SIGTERM, lambda *_: launcher.stop()) -- cgit