summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorLvov Maxim <usrleon@gmail.com>2011-07-13 11:18:16 +0400
committerLvov Maxim <usrleon@gmail.com>2011-07-13 11:18:16 +0400
commit0beb900ec6a24f072b8cedcf45fc72e5a16a4787 (patch)
tree871bd6ace24262900bafc07b6aad9a8cb3935237 /bin
parentff195162d97f4a1ffaa6127f92cca102705b023b (diff)
parent29ef49c205bf5d042e52a44dda8f16aca043b31c (diff)
downloadnova-0beb900ec6a24f072b8cedcf45fc72e5a16a4787.tar.gz
nova-0beb900ec6a24f072b8cedcf45fc72e5a16a4787.tar.xz
nova-0beb900ec6a24f072b8cedcf45fc72e5a16a4787.zip
merge with trunk
Diffstat (limited to 'bin')
-rwxr-xr-xbin/instance-usage-audit116
-rwxr-xr-xbin/nova-ajax-console-proxy5
-rwxr-xr-xbin/nova-api61
-rwxr-xr-xbin/nova-dhcpbridge8
-rwxr-xr-xbin/nova-direct-api7
-rwxr-xr-xbin/nova-manage175
-rwxr-xr-xbin/nova-objectstore7
-rwxr-xr-xbin/nova-vncproxy22
8 files changed, 314 insertions, 87 deletions
diff --git a/bin/instance-usage-audit b/bin/instance-usage-audit
new file mode 100755
index 000000000..a06c6b1b3
--- /dev/null
+++ b/bin/instance-usage-audit
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2011 Openstack, LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""Cron script to generate usage notifications for instances neither created
+ nor destroyed in a given time period.
+
+ Together with the notifications generated by compute on instance
+ create/delete/resize, over that ime period, this allows an external
+ system consuming usage notification feeds to calculate instance usage
+ for each tenant.
+
+ Time periods are specified like so:
+ <number>[mdy]
+
+ 1m = previous month. If the script is run April 1, it will generate usages
+ for March 1 thry March 31.
+ 3m = 3 previous months.
+ 90d = previous 90 days.
+ 1y = previous year. If run on Jan 1, it generates usages for
+ Jan 1 thru Dec 31 of the previous year.
+"""
+
+import datetime
+import gettext
+import os
+import sys
+import time
+
+# If ../nova/__init__.py exists, add ../ to Python search path, so that
+# it will override what happens to be installed in /usr/(local/)lib/python...
+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')):
+ sys.path.insert(0, POSSIBLE_TOPDIR)
+
+gettext.install('nova', unicode=1)
+
+
+from nova import context
+from nova import db
+from nova import exception
+from nova import flags
+from nova import log as logging
+from nova import utils
+
+from nova.notifier import api as notifier_api
+
+FLAGS = flags.FLAGS
+flags.DEFINE_string('instance_usage_audit_period', '1m',
+ 'time period to generate instance usages for.')
+
+
+def time_period(period):
+ today = datetime.date.today()
+ unit = period[-1]
+ if unit not in 'mdy':
+ raise ValueError('Time period must be m, d, or y')
+ n = int(period[:-1])
+ if unit == 'm':
+ year = today.year - (n // 12)
+ n = n % 12
+ if n >= today.month:
+ year -= 1
+ month = 12 + (today.month - n)
+ else:
+ month = today.month - n
+ begin = datetime.datetime(day=1, month=month, year=year)
+ end = datetime.datetime(day=1, month=today.month, year=today.year)
+
+ elif unit == 'y':
+ begin = datetime.datetime(day=1, month=1, year=today.year - n)
+ end = datetime.datetime(day=1, month=1, year=today.year)
+
+ elif unit == 'd':
+ b = today - datetime.timedelta(days=n)
+ begin = datetime.datetime(day=b.day, month=b.month, year=b.year)
+ end = datetime.datetime(day=today.day,
+ month=today.month,
+ year=today.year)
+
+ return (begin, end)
+
+if __name__ == '__main__':
+ utils.default_flagfile()
+ flags.FLAGS(sys.argv)
+ logging.setup()
+ begin, end = time_period(FLAGS.instance_usage_audit_period)
+ print "Creating usages for %s until %s" % (str(begin), str(end))
+ instances = db.instance_get_active_by_window(context.get_admin_context(),
+ begin,
+ end)
+ print "%s instances" % len(instances)
+ for instance_ref in instances:
+ usage_info = utils.usage_from_instance(instance_ref,
+ audit_period_begining=str(begin),
+ audit_period_ending=str(end))
+ notifier_api.notify('compute.%s' % FLAGS.host,
+ 'compute.instance.exists',
+ notifier_api.INFO,
+ usage_info)
diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy
index d88f59e40..21cf68007 100755
--- a/bin/nova-ajax-console-proxy
+++ b/bin/nova-ajax-console-proxy
@@ -137,8 +137,9 @@ if __name__ == '__main__':
utils.default_flagfile()
FLAGS(sys.argv)
logging.setup()
- server = wsgi.Server()
+ acp_port = FLAGS.ajax_console_proxy_port
acp = AjaxConsoleProxy()
acp.register_listeners()
- server.start(acp, FLAGS.ajax_console_proxy_port, host='0.0.0.0')
+ server = wsgi.Server("AJAX Console Proxy", acp, port=acp_port)
+ server.start()
server.wait()
diff --git a/bin/nova-api b/bin/nova-api
index a1088c23d..fe8e83366 100755
--- a/bin/nova-api
+++ b/bin/nova-api
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# pylint: disable=C0103
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
@@ -18,44 +17,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Starter script for Nova API."""
+"""Starter script for Nova API.
+
+Starts both the EC2 and OpenStack APIs in separate processes.
+
+"""
-import gettext
import os
+import signal
import sys
-# If ../nova/__init__.py exists, add ../ to Python search path, so that
-# it will override what happens to be installed in /usr/(local/)lib/python...
-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')):
+
+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")):
sys.path.insert(0, possible_topdir)
-gettext.install('nova', unicode=1)
+import nova.service
+import nova.utils
from nova import flags
-from nova import log as logging
-from nova import service
-from nova import utils
-from nova import version
-from nova import wsgi
-LOG = logging.getLogger('nova.api')
-
FLAGS = flags.FLAGS
+
+def main():
+ """Launch EC2 and OSAPI services."""
+ nova.utils.Bootstrapper.bootstrap_binary(sys.argv)
+
+ launcher = nova.service.Launcher()
+
+ for api in FLAGS.enabled_apis:
+ service = nova.service.WSGIService(api)
+ launcher.launch_service(service)
+
+ signal.signal(signal.SIGTERM, lambda *_: launcher.stop())
+
+ try:
+ launcher.wait()
+ except KeyboardInterrupt:
+ launcher.stop()
+
+
if __name__ == '__main__':
- utils.default_flagfile()
- FLAGS(sys.argv)
- logging.setup()
- LOG.audit(_("Starting nova-api node (version %s)"),
- version.version_string_with_vcs())
- LOG.debug(_("Full set of FLAGS:"))
- for flag in FLAGS:
- flag_get = FLAGS.get(flag, None)
- LOG.debug("%(flag)s : %(flag_get)s" % locals())
-
- service = service.serve_wsgi(service.ApiService)
- service.wait()
+ sys.exit(main())
diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge
index 5926b97de..6d9d85896 100755
--- a/bin/nova-dhcpbridge
+++ b/bin/nova-dhcpbridge
@@ -59,14 +59,12 @@ def add_lease(mac, ip_address, _hostname, _interface):
LOG.debug(_("leasing ip"))
network_manager = utils.import_object(FLAGS.network_manager)
network_manager.lease_fixed_ip(context.get_admin_context(),
- mac,
ip_address)
else:
rpc.cast(context.get_admin_context(),
"%s.%s" % (FLAGS.network_topic, FLAGS.host),
{"method": "lease_fixed_ip",
- "args": {"mac": mac,
- "address": ip_address}})
+ "args": {"address": ip_address}})
def old_lease(mac, ip_address, hostname, interface):
@@ -81,14 +79,12 @@ def del_lease(mac, ip_address, _hostname, _interface):
LOG.debug(_("releasing ip"))
network_manager = utils.import_object(FLAGS.network_manager)
network_manager.release_fixed_ip(context.get_admin_context(),
- mac,
ip_address)
else:
rpc.cast(context.get_admin_context(),
"%s.%s" % (FLAGS.network_topic, FLAGS.host),
{"method": "release_fixed_ip",
- "args": {"mac": mac,
- "address": ip_address}})
+ "args": {"address": ip_address}})
def init_leases(interface):
diff --git a/bin/nova-direct-api b/bin/nova-direct-api
index 83ec72722..c6cf9b2ff 100755
--- a/bin/nova-direct-api
+++ b/bin/nova-direct-api
@@ -93,6 +93,9 @@ if __name__ == '__main__':
with_req = direct.PostParamsMiddleware(with_json)
with_auth = direct.DelegatedAuthMiddleware(with_req)
- server = wsgi.Server()
- server.start(with_auth, FLAGS.direct_port, host=FLAGS.direct_host)
+ server = wsgi.Server("Direct API",
+ with_auth,
+ host=FLAGS.direct_host,
+ port=FLAGS.direct_port)
+ server.start()
server.wait()
diff --git a/bin/nova-manage b/bin/nova-manage
index a4b221b8c..7b78a0b5c 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -56,6 +56,7 @@
import gettext
import glob
import json
+import netaddr
import os
import sys
import time
@@ -98,7 +99,6 @@ flags.DECLARE('vlan_start', 'nova.network.manager')
flags.DECLARE('vpn_start', 'nova.network.manager')
flags.DECLARE('fixed_range_v6', 'nova.network.manager')
flags.DECLARE('gateway_v6', 'nova.network.manager')
-flags.DECLARE('images_path', 'nova.image.local')
flags.DECLARE('libvirt_type', 'nova.virt.libvirt.connection')
flags.DEFINE_flag(flags.HelpFlag())
flags.DEFINE_flag(flags.HelpshortFlag())
@@ -184,17 +184,23 @@ class VpnCommands(object):
def change(self, project_id, ip, port):
"""Change the ip and port for a vpn.
+ this will update all networks associated with a project
+ not sure if that's the desired behavior or not, patches accepted
+
args: project, ip, port"""
+ # TODO(tr3buchet): perhaps this shouldn't update all networks
+ # associated with a project in the future
project = self.manager.get_project(project_id)
if not project:
print 'No project %s' % (project_id)
return
- admin = context.get_admin_context()
- network_ref = db.project_get_network(admin, project_id)
- db.network_update(admin,
- network_ref['id'],
- {'vpn_public_address': ip,
- 'vpn_public_port': int(port)})
+ admin_context = context.get_admin_context()
+ networks = db.project_get_networks(admin_context, project_id)
+ for network in networks:
+ db.network_update(admin_context,
+ network['id'],
+ {'vpn_public_address': ip,
+ 'vpn_public_port': int(port)})
class ShellCommands(object):
@@ -274,6 +280,11 @@ class RoleCommands(object):
"""adds role to user
if project is specified, adds project specific role
arguments: user, role [project]"""
+ if project:
+ projobj = self.manager.get_project(project)
+ if not projobj.has_member(user):
+ print "%s not a member of %s" % (user, project)
+ return
self.manager.add_role(user, role, project)
@args('--user', dest="user", metavar='<user name>', help='User name')
@@ -497,12 +508,13 @@ class ProjectCommands(object):
def scrub(self, project_id):
"""Deletes data associated with project
arguments: project_id"""
- ctxt = context.get_admin_context()
- network_ref = db.project_get_network(ctxt, project_id)
- db.network_disassociate(ctxt, network_ref['id'])
- groups = db.security_group_get_by_project(ctxt, project_id)
+ admin_context = context.get_admin_context()
+ networks = db.project_get_networks(admin_context, project_id)
+ for network in networks:
+ db.network_disassociate(admin_context, network['id'])
+ groups = db.security_group_get_by_project(admin_context, project_id)
for group in groups:
- db.security_group_destroy(ctxt, group['id'])
+ db.security_group_destroy(admin_context, group['id'])
@args('--project', dest="project_id", metavar='<Project name>', help='Project name')
@args('--user', dest="user_id", metavar='<name>', help='User name')
@@ -560,7 +572,7 @@ class FixedIpCommands(object):
instance = fixed_ip['instance']
hostname = instance['hostname']
host = instance['host']
- mac_address = instance['mac_address']
+ mac_address = fixed_ip['mac_address']['address']
print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (
fixed_ip['network']['cidr'],
fixed_ip['address'],
@@ -570,28 +582,27 @@ class FixedIpCommands(object):
class FloatingIpCommands(object):
"""Class for managing floating ip."""
- @args('--host', dest="host", metavar='<host>', help='Host')
@args('--ip_range', dest="range", metavar='<range>', help='IP range')
- def create(self, host, range):
- """Creates floating ips for host by range
- arguments: host ip_range"""
- for address in IPy.IP(range):
+ def create(self, range):
+ """Creates floating ips for zone by range
+ arguments: ip_range"""
+ for address in netaddr.IPNetwork(range):
db.floating_ip_create(context.get_admin_context(),
- {'address': str(address),
- 'host': host})
+ {'address': str(address)})
@args('--ip_range', dest="ip_range", metavar='<range>', help='IP range')
def delete(self, ip_range):
"""Deletes floating ips by range
arguments: range"""
- for address in IPy.IP(ip_range):
+ for address in netaddr.IPNetwork(ip_range):
db.floating_ip_destroy(context.get_admin_context(),
str(address))
@args('--host', dest="host", metavar='<host>', help='Host')
def list(self, host=None):
"""Lists all floating ips (optionally by host)
- arguments: [host]"""
+ arguments: [host]
+ Note: if host is given, only active floating IPs are returned"""
ctxt = context.get_admin_context()
if host is None:
floating_ips = db.floating_ip_get_all(ctxt)
@@ -609,6 +620,7 @@ class FloatingIpCommands(object):
class NetworkCommands(object):
"""Class for managing networks."""
+ @args('--label', dest="label", metavar='<label>', help='Label (ex: public)')
@args('--network', dest="fixed_range", metavar='<x.x.x.x/yy>', help='Network')
@args('--num_networks', dest="num_networks", metavar='<number>', help='How many networks create')
@args('--network_size', dest="network_size", metavar='<number>', help='How many hosts in network')
@@ -616,12 +628,25 @@ class NetworkCommands(object):
@args('--vpn', dest="vpn_start", help='vpn start')
@args('--fixed_range_v6', dest="fixed_range_v6", help='fixed ipv6 range')
@args('--gateway_v6', dest="gateway_v6", help='ipv6 gateway')
- @args('--project', dest="project_id", metavar='<Project name>', help='Project for network')
- def create(self, fixed_range=None, num_networks=None, network_size=None,
- vlan_start=None, vpn_start=None, fixed_range_v6=None,
- gateway_v6=None, label='public'):
- """Creates fixed ips for host by range"""
-
+ @args('--flat_network_bridge', dest="flat_network_bridge", metavar='<flat network bridge>', help='Flat_network_bridge')
+ @args('--bridge', dest="bridge_interface", metavar='<bridge interface>', help='Bridge_interface')
+ def create(self, label=None, fixed_range=None, num_networks=None,
+ network_size=None, vlan_start=None,
+ vpn_start=None, fixed_range_v6=None, gateway_v6=None,
+ flat_network_bridge=None, bridge_interface=None):
+ """Creates fixed ips for host by range
+ arguments: label, fixed_range, [num_networks=FLAG],
+ [network_size=FLAG], [vlan_start=FLAG],
+ [vpn_start=FLAG], [fixed_range_v6=FLAG], [gateway_v6=FLAG],
+ [flat_network_bridge=FLAG], [bridge_interface=FLAG]
+ If you wish to use a later argument fill in the gaps with 0s
+ Ex: network create private 10.0.0.0/8 1 15 0 0 0 0 xenbr1 eth1
+ network create private 10.0.0.0/8 1 15
+ """
+ if not label:
+ msg = _('a label (ex: public) is required to create networks.')
+ print msg
+ raise TypeError(msg)
if not fixed_range:
msg = _('Fixed range in the form of 10.0.0.0/8 is '
'required to create networks.')
@@ -637,11 +662,17 @@ class NetworkCommands(object):
vpn_start = FLAGS.vpn_start
if not fixed_range_v6:
fixed_range_v6 = FLAGS.fixed_range_v6
+ if not flat_network_bridge:
+ flat_network_bridge = FLAGS.flat_network_bridge
+ if not bridge_interface:
+ bridge_interface = FLAGS.flat_interface or FLAGS.vlan_interface
if not gateway_v6:
gateway_v6 = FLAGS.gateway_v6
net_manager = utils.import_object(FLAGS.network_manager)
+
try:
net_manager.create_networks(context.get_admin_context(),
+ label=label,
cidr=fixed_range,
num_networks=int(num_networks),
network_size=int(network_size),
@@ -649,7 +680,8 @@ class NetworkCommands(object):
vpn_start=int(vpn_start),
cidr_v6=fixed_range_v6,
gateway_v6=gateway_v6,
- label=label)
+ bridge=flat_network_bridge,
+ bridge_interface=bridge_interface)
except ValueError, e:
print e
raise e
@@ -689,7 +721,7 @@ class VmCommands(object):
:param host: show all instance on specified host.
:param instance: show specificed instance.
"""
- print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \
+ print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \
" %-10s %-10s %-10s %-5s" % (
_('instance'),
_('node'),
@@ -711,14 +743,14 @@ class VmCommands(object):
context.get_admin_context(), host)
for instance in instances:
- print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \
+ print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \
" %-10s %-10s %-10s %-5d" % (
instance['hostname'],
instance['host'],
- instance['instance_type'],
+ instance['instance_type'].name,
instance['state_description'],
instance['launched_at'],
- instance['image_id'],
+ instance['image_ref'],
instance['kernel_id'],
instance['ramdisk_id'],
instance['project_id'],
@@ -971,7 +1003,7 @@ class InstanceTypeCommands(object):
try:
instance_types.create(name, memory, vcpus, local_gb,
flavorid, swap, rxtx_quota, rxtx_cap)
- except exception.InvalidInputException:
+ except exception.InvalidInput, e:
print "Must supply valid parameters to create instance_type"
print e
sys.exit(1)
@@ -1182,16 +1214,6 @@ class ImageCommands(object):
machine_images = {}
other_images = {}
directory = os.path.abspath(directory)
- # NOTE(vish): If we're importing from the images path dir, attempt
- # to move the files out of the way before importing
- # so we aren't writing to the same directory. This
- # may fail if the dir was a mointpoint.
- if (FLAGS.image_service == 'nova.image.local.LocalImageService'
- and directory == os.path.abspath(FLAGS.images_path)):
- new_dir = "%s_bak" % directory
- os.rename(directory, new_dir)
- os.mkdir(directory)
- directory = new_dir
for fn in glob.glob("%s/*/info.json" % directory):
try:
image_path = os.path.join(fn.rpartition('/')[0], 'image')
@@ -1208,6 +1230,70 @@ class ImageCommands(object):
self._convert_images(machine_images)
+class AgentBuildCommands(object):
+ """Class for managing agent builds."""
+
+ def create(self, os, architecture, version, url, md5hash,
+ hypervisor='xen'):
+ """Creates a new agent build.
+ arguments: os architecture version url md5hash [hypervisor='xen']"""
+ ctxt = context.get_admin_context()
+ agent_build = db.agent_build_create(ctxt,
+ {'hypervisor': hypervisor,
+ 'os': os,
+ 'architecture': architecture,
+ 'version': version,
+ 'url': url,
+ 'md5hash': md5hash})
+
+ def delete(self, os, architecture, hypervisor='xen'):
+ """Deletes an existing agent build.
+ arguments: os architecture [hypervisor='xen']"""
+ ctxt = context.get_admin_context()
+ agent_build_ref = db.agent_build_get_by_triple(ctxt,
+ hypervisor, os, architecture)
+ db.agent_build_destroy(ctxt, agent_build_ref['id'])
+
+ def list(self, hypervisor=None):
+ """Lists all agent builds.
+ arguments: <none>"""
+ fmt = "%-10s %-8s %12s %s"
+ ctxt = context.get_admin_context()
+ by_hypervisor = {}
+ for agent_build in db.agent_build_get_all(ctxt):
+ buildlist = by_hypervisor.get(agent_build.hypervisor)
+ if not buildlist:
+ buildlist = by_hypervisor[agent_build.hypervisor] = []
+
+ buildlist.append(agent_build)
+
+ for key, buildlist in by_hypervisor.iteritems():
+ if hypervisor and key != hypervisor:
+ continue
+
+ print "Hypervisor: %s" % key
+ print fmt % ('-' * 10, '-' * 8, '-' * 12, '-' * 32)
+ for agent_build in buildlist:
+ print fmt % (agent_build.os, agent_build.architecture,
+ agent_build.version, agent_build.md5hash)
+ print ' %s' % agent_build.url
+
+ print
+
+ def modify(self, os, architecture, version, url, md5hash,
+ hypervisor='xen'):
+ """Update an existing agent build.
+ arguments: os architecture version url md5hash [hypervisor='xen']
+ """
+ ctxt = context.get_admin_context()
+ agent_build_ref = db.agent_build_get_by_triple(ctxt,
+ hypervisor, os, architecture)
+ db.agent_build_update(ctxt, agent_build_ref['id'],
+ {'version': version,
+ 'url': url,
+ 'md5hash': md5hash})
+
+
class ConfigCommands(object):
"""Class for exposing the flags defined by flag_file(s)."""
@@ -1220,6 +1306,7 @@ class ConfigCommands(object):
CATEGORIES = [
('account', AccountCommands),
+ ('agent', AgentBuildCommands),
('config', ConfigCommands),
('db', DbCommands),
('fixed', FixedIpCommands),
diff --git a/bin/nova-objectstore b/bin/nova-objectstore
index 6ef841b85..1aef3a255 100755
--- a/bin/nova-objectstore
+++ b/bin/nova-objectstore
@@ -50,6 +50,9 @@ if __name__ == '__main__':
FLAGS(sys.argv)
logging.setup()
router = s3server.S3Application(FLAGS.buckets_path)
- server = wsgi.Server()
- server.start(router, FLAGS.s3_port, host=FLAGS.s3_host)
+ server = wsgi.Server("S3 Objectstore",
+ router,
+ port=FLAGS.s3_port,
+ host=FLAGS.s3_host)
+ server.start()
server.wait()
diff --git a/bin/nova-vncproxy b/bin/nova-vncproxy
index ccb97e3a3..bdbb30a7f 100755
--- a/bin/nova-vncproxy
+++ b/bin/nova-vncproxy
@@ -63,6 +63,19 @@ 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 = "<policy-file-request/>"
+ if expected_command in fd.read(len(expected_command) + 1):
+ LOG.info(_("Received valid flash socket policy request"))
+ fd.write('<?xml version="1.0"?><cross-domain-policy><allow-'
+ 'access-from domain="*" to-ports="%d" /></cross-'
+ 'domain-policy>' % (FLAGS.vncproxy_port))
+ fd.flush()
+ socket.close()
+
if __name__ == "__main__":
utils.default_flagfile()
FLAGS(sys.argv)
@@ -96,6 +109,11 @@ if __name__ == "__main__":
service.serve()
- server = wsgi.Server()
- server.start(with_auth, FLAGS.vncproxy_port, host=FLAGS.vncproxy_host)
+ server = wsgi.Server("VNC Proxy",
+ with_auth,
+ host=FLAGS.vncproxy_host,
+ port=FLAGS.vncproxy_port)
+ server.start()
+ server.start_tcp(handle_flash_socket_policy, 843, host=FLAGS.vncproxy_host)
+
server.wait()