stricter zone_id checking

This commit is contained in:
Sandy Walsh
2011-07-07 10:20:35 -07:00
2 changed files with 20 additions and 3 deletions

View File

@@ -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)
@@ -101,4 +114,6 @@ if __name__ == "__main__":
host=FLAGS.vncproxy_host,
port=FLAGS.vncproxy_port)
server.start()
server.start_tcp(handle_flash_socket_policy, 843, host=FLAGS.vncproxy_host)
server.wait()

View File

@@ -178,12 +178,14 @@ class ZoneAwareScheduler(driver.Scheduler):
to adjust the weights returned from the child zones. Alters
child_results in place.
"""
for zone, result in child_results:
for zone_id, result in child_results:
if not result:
continue
assert isinstance(zone_id, int)
for zone_rec in zones:
if zone_rec['id'] != zone:
if zone_rec['id'] != zone_id:
continue
for item in result:
@@ -196,7 +198,7 @@ class ZoneAwareScheduler(driver.Scheduler):
item['raw_weight'] = raw_weight
except KeyError:
LOG.exception(_("Bad child zone scaling values "
"for Zone: %(zone)s") % locals())
"for Zone: %(zone_id)s") % locals())
def schedule_run_instance(self, context, instance_id, request_spec,
*args, **kwargs):