Skip to content

Commit

Permalink
Merge "Fixed broken vncproxy flush tokens patch" into stable/essex
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Mar 25, 2013
2 parents 1ee892b + 48e81f1 commit e52e691
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,12 +1561,14 @@ def get_vnc_console(self, context, instance, console_type):
return {'url': connect_info['access_url']}

@wrap_check_policy
def validate_vnc_console(self, context, instance_id, host, port):
def validate_vnc_console(self, context, instance_id, host, port,
console_type):
"""Validate VNC Console for an instance."""
instance = self.get(context, instance_id)
output = self._call_compute_message('get_vnc_console',
context,
instance)
context,
instance,
params={"console_type": console_type})
return (port == output['port'] and host == output['host'])

@wrap_check_policy
Expand Down
9 changes: 5 additions & 4 deletions nova/consoleauth/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,23 @@ def authorize_console(self, context, token, console_type, host, port,

LOG.audit(_("Received Token: %(token)s, %(token_dict)s)"), locals())

def _validate_console(self, token):
def _validate_console(self, context, token):
console_valid = False
token_dict = self.tokens[token]
try:
console_valid = self.compute_api.validate_vnc_console(context,
token_dict['instance_uuid'],
token_dict['instance_id'],
token_dict['host'],
token_dict['port'])
token_dict['port'],
token_dict['console_type'])
except exception.InstanceNotFound:
pass
return console_valid

def check_token(self, context, token):
token_valid = token in self.tokens
LOG.audit(_("Checking Token: %(token)s, %(token_valid)s)"), locals())
if token_valid and self._validate_console(token):
if token_valid and self._validate_console(context, token):
return self.tokens[token]

def delete_tokens_for_instance(self, context, instance_id):
Expand Down
8 changes: 5 additions & 3 deletions nova/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,8 @@ def fake(*args, **kwargs):
console_valid = self.compute_api.validate_vnc_console(self.context,
instance['uuid'],
'myhost',
'5900')
'5900',
'novnc')
self.assertTrue(console_valid)
self.compute.terminate_instance(self.context, instance['uuid'])

Expand All @@ -783,7 +784,8 @@ def fake(*args, **kwargs):
console_valid = self.compute_api.validate_vnc_console(self.context,
instance['uuid'],
'myhost',
'5900')
'5900',
'novnc')
self.assertFalse(console_valid)
self.compute.terminate_instance(self.context, instance['uuid'])

Expand All @@ -793,7 +795,7 @@ def test_validate_vnc_console_deleted_instance(self):
self.compute.run_instance(self.context, instance['uuid'])
self.assertRaises(exception.InstanceNotFound,
self.compute_api.validate_vnc_console,
self.context, 5555, 'myhost', '5900')
self.context, 5555, 'myhost', '5900', 'novnc')
self.compute.terminate_instance(self.context, instance['uuid'])

def test_xvpvnc_vnc_console(self):
Expand Down

0 comments on commit e52e691

Please sign in to comment.