Merge lp:~jimmy-sigint/nova/support_flash_socket_policy_in_vnc_proxy into lp:~hudson-openstack/nova/trunk

Proposed by Jimmy Bergman
Status: Merged
Approved by: Vish Ishaya
Approved revision: 1208
Merged at revision: 1246
Proposed branch: lp:~jimmy-sigint/nova/support_flash_socket_policy_in_vnc_proxy
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 76 lines (+36/-0)
2 files modified
bin/nova-vncproxy (+15/-0)
nova/wsgi.py (+21/-0)
To merge this branch: bzr merge lp:~jimmy-sigint/nova/support_flash_socket_policy_in_vnc_proxy
Reviewer Review Type Date Requested Status
Matt Dietz (community) Approve
Vish Ishaya (community) Approve
Review via email: mp+65464@code.launchpad.net

Description of the change

Add a socket server responding with an allowing flash socket policy for all requests from flash on port 843 to nova-vncproxy

To post a comment you must log in.
Revision history for this message
Vish Ishaya (vishvananda) wrote :

It will be very cool to get this feature in. Unfortunately we've pulled twisted out of the rest of the code base and it seems silly to add the dependency back for this small feature. It seems like this could be done without twisted by making the wsgi app listen on 843 as well and handling the requests on that port by sending the policy data.

review: Needs Fixing
Revision history for this message
Jimmy Bergman (jimmy-sigint) wrote :

Missed that (re twisted), will arrange some other solution. I didn't try to hack it into the wsgi app due to the fact that it doesn't use HTTP, it connects and simply sends <policy-file-request/> followed by a NULL byte, and I guessed that it would be messy to get the wsgi app to handle non-http stuff.

Revision history for this message
Jimmy Bergman (jimmy-sigint) wrote :

> It will be very cool to get this feature in. Unfortunately we've pulled
> twisted out of the rest of the code base and it seems silly to add the
> dependency back for this small feature. It seems like this could be done
> without twisted by making the wsgi app listen on 843 as well and handling the
> requests on that port by sending the policy data.

The branch is now updated to instead let the nova.wsgi.Server have an additional
raw non-HTTP TCP listener listening on 843 (and the code to support that is
added to nova.wsgi.Server).

Revision history for this message
Vish Ishaya (vishvananda) wrote :

awesome! Much better.

review: Approve
Revision history for this message
Matt Dietz (cerberus) wrote :

lgtm.

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Attempt to merge into lp:nova failed due to conflicts:

text conflict in bin/nova-vncproxy

Revision history for this message
Jimmy Bergman (jimmy-sigint) wrote :

Now I've merged with trunk again and adapted the patch to the nova/wsgi.py refactoring that was merged while this branch was pending approval.

Revision history for this message
Jimmy Bergman (jimmy-sigint) wrote :

What is the process for redoing the merge attempt?

Revision history for this message
Vish Ishaya (vishvananda) wrote :

I'll kick it off again.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

In general, if you set the branch back to Needs Review, it will notify nova-core that it has been updated, so we can re-approve.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (179.3 KiB)

The attempt to merge lp:~jimmy-sigint/nova/support_flash_socket_policy_in_vnc_proxy into lp:nova failed. Below is the output from the failed tests.

FloatingIpTest
    test_floating_ip_allocate OK 0.15
    test_floating_ip_associate OK 0.21
    test_floating_ip_disassociate OK 0.09
    test_floating_ip_release OK 0.09
    test_floating_ip_show OK 0.09
    test_floating_ips_list OK 0.09
    test_translate_floating_ip_view OK 0.04
FlavorsExtraSpecsTest
    test_create OK 0.05
    test_create_empty_body OK 0.04
    test_delete OK 0.04
    test_index OK 0.04
    test_index_no_data OK 0.05
    test_show OK 0.05
    test_show_spec_not_found OK 0.25
    test_update_item OK 0.04
    test_update_item_body_uri_mismatch OK 0.04
    test_update_item_empty_body OK 0.04
    test_update_item_too_many_keys OK 0.04
AccountsTest
    test_account_create OK 0.17
    test_account_delete OK 0.17
    test_account_update OK 0.17
    test_get_account OK 0.43
AdminAPITest
    test_admin_disabled OK 0.13
    test_admin_enabled OK 0.17
APITest
    test_exceptions_are_converted_to_faults OK 0.01
    test_malformed_json OK 0.06
    test_malformed_xml OK 0.06
Test
    test_authorize_project OK 0.09
    test_authorize_token OK 0.32
    test_authorize_user OK 0.05
    test_bad_project OK 0.09
    test_bad_token OK 0.05
    test_bad_user_bad_key OK 0.06
    test_bad_user_good_key OK 0.05
    test_no_user OK 0.05
    test_not_existing_project OK 0.31
    test_token_expiry OK 0.05
TestFunctional
    test_token_doesnotexist OK 0.06
    test_token_expiry OK 0.08
TestLimiter
    test_authorize_token OK 0.08
LimiterTest
    test_limiter...

Revision history for this message
Vish Ishaya (vishvananda) wrote :

looks like you got caught by the pep8 police!

Revision history for this message
Jimmy Bergman (jimmy-sigint) wrote :

this is now fixed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/nova-vncproxy'
2--- bin/nova-vncproxy 2011-06-21 16:03:27 +0000
3+++ bin/nova-vncproxy 2011-07-07 06:14:57 +0000
4@@ -63,6 +63,19 @@
5 flags.DEFINE_flag(flags.HelpXMLFlag())
6
7
8+def handle_flash_socket_policy(socket):
9+ LOG.info(_("Received connection on flash socket policy port"))
10+
11+ fd = socket.makefile('rw')
12+ expected_command = "<policy-file-request/>"
13+ if expected_command in fd.read(len(expected_command) + 1):
14+ LOG.info(_("Received valid flash socket policy request"))
15+ fd.write('<?xml version="1.0"?><cross-domain-policy><allow-'
16+ 'access-from domain="*" to-ports="%d" /></cross-'
17+ 'domain-policy>' % (FLAGS.vncproxy_port))
18+ fd.flush()
19+ socket.close()
20+
21 if __name__ == "__main__":
22 utils.default_flagfile()
23 FLAGS(sys.argv)
24@@ -101,4 +114,6 @@
25 host=FLAGS.vncproxy_host,
26 port=FLAGS.vncproxy_port)
27 server.start()
28+ server.start_tcp(handle_flash_socket_policy, 843, host=FLAGS.vncproxy_host)
29+
30 server.wait()
31
32=== modified file 'nova/wsgi.py'
33--- nova/wsgi.py 2011-06-21 15:25:44 +0000
34+++ nova/wsgi.py 2011-07-07 06:14:57 +0000
35@@ -67,6 +67,7 @@
36 self.host = host or "0.0.0.0"
37 self.port = port or 0
38 self._server = None
39+ self._tcp_server = None
40 self._socket = None
41 self._pool = eventlet.GreenPool(pool_size or self.default_pool_size)
42 self._logger = logging.getLogger("eventlet.wsgi.server")
43@@ -106,6 +107,17 @@
44 """
45 LOG.info(_("Stopping WSGI server."))
46 self._server.kill()
47+ if self._tcp_server is not None:
48+ LOG.info(_("Stopping raw TCP server."))
49+ self._tcp_server.kill()
50+
51+ def start_tcp(self, listener, port, host='0.0.0.0', key=None, backlog=128):
52+ """Run a raw TCP server with the given application."""
53+ arg0 = sys.argv[0]
54+ LOG.info(_('Starting TCP server %(arg0)s on %(host)s:%(port)s')
55+ % locals())
56+ socket = eventlet.listen((host, port), backlog=backlog)
57+ self._tcp_server = self._pool.spawn_n(self._run_tcp, listener, socket)
58
59 def wait(self):
60 """Block, until the server has stopped.
61@@ -120,6 +132,15 @@
62 except greenlet.GreenletExit:
63 LOG.info(_("WSGI server has stopped."))
64
65+ def _run_tcp(self, listener, socket):
66+ """Start a raw TCP server in a new green thread."""
67+ while True:
68+ try:
69+ new_sock, address = socket.accept()
70+ self._pool.spawn_n(listener, new_sock)
71+ except (SystemExit, KeyboardInterrupt):
72+ pass
73+
74
75 class Request(webob.Request):
76 pass