Skip to content

Commit

Permalink
Add get_console_pool_info() to the compute rpcapi.
Browse files Browse the repository at this point in the history
Part of bug 1006467.

This patch adds the get_console_pool_info() method to the compute
rpcapi.  This is used by the console manager.

Change-Id: I429123ed48cb2a5fcfb70248eac743cf4e7a76f2
  • Loading branch information
russellb committed May 31, 2012
1 parent 164d233 commit 0db055b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions nova/compute/rpcapi.py
Expand Up @@ -101,6 +101,11 @@ def get_console_output(self, ctxt, instance, tail_length):
instance_uuid=instance['uuid'], tail_length=tail_length),
topic=self._compute_topic(ctxt, None, instance))

def get_console_pool_info(self, ctxt, console_type, host):
return self.call(ctxt, self.make_msg('get_console_pool_info',
console_type=console_type),
topic=self._compute_topic(ctxt, host, None))

def get_diagnostics(self, ctxt, instance):
return self.call(ctxt, self.make_msg('get_diagnostics',
instance_uuid=instance['uuid']),
Expand Down
11 changes: 4 additions & 7 deletions nova/console/manager.py
Expand Up @@ -19,13 +19,13 @@

import socket

from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova import flags
from nova import log as logging
from nova import manager
from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova import rpc
from nova import utils


Expand Down Expand Up @@ -61,6 +61,7 @@ def __init__(self, console_driver=None, *args, **kwargs):
self.driver = importutils.import_object(console_driver)
super(ConsoleProxyManager, self).__init__(*args, **kwargs)
self.driver.host = self.host
self.compute_rpcapi = compute_rpcapi.ComputeAPI()

def init_host(self):
self.driver.init_host()
Expand Down Expand Up @@ -121,12 +122,8 @@ def get_pool_for_instance_host(self, context, instance_host):
'username': 'test',
'password': '1234pass'}
else:
pool_info = rpc.call(context,
rpc.queue_get_for(context,
FLAGS.compute_topic,
instance_host),
{'method': 'get_console_pool_info',
'args': {'console_type': console_type}})
pool_info = compute_rpcapi.get_console_pool_info(context,
console_type, instance_host)
pool_info['password'] = self.driver.fix_pool_password(
pool_info['password'])
pool_info['host'] = self.host
Expand Down
11 changes: 4 additions & 7 deletions nova/console/vmrc_manager.py
Expand Up @@ -17,13 +17,13 @@

"""VMRC Console Manager."""

from nova.compute import rpcapi as compute_rpcapi
from nova import exception
from nova import flags
from nova import log as logging
from nova import manager
from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova import rpc
from nova.virt import vmwareapi_conn


Expand All @@ -47,6 +47,7 @@ class ConsoleVMRCManager(manager.Manager):

def __init__(self, console_driver=None, *args, **kwargs):
self.driver = importutils.import_object(FLAGS.console_driver)
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
super(ConsoleVMRCManager, self).__init__(*args, **kwargs)

def init_host(self):
Expand Down Expand Up @@ -137,12 +138,8 @@ def get_pool_for_instance_host(self, context, instance_host):
self.host,
console_type)
except exception.NotFound:
pool_info = rpc.call(context,
rpc.queue_get_for(context,
FLAGS.compute_topic,
instance_host),
{'method': 'get_console_pool_info',
'args': {'console_type': console_type}})
pool_info = self.compute_rpcapi.get_console_pool_info(context,
console_type, instance_host)
pool_info['password'] = self.driver.fix_pool_password(
pool_info['password'])
pool_info['host'] = self.host
Expand Down
4 changes: 4 additions & 0 deletions nova/tests/compute/test_rpcapi.py
Expand Up @@ -108,6 +108,10 @@ def test_get_console_output(self):
self._test_compute_api('get_console_output', 'call',
instance=self.fake_instance, tail_length='tl')

def test_get_console_pool_info(self):
self._test_compute_api('get_console_pool_info', 'call',
console_type='type', host='host')

def test_get_diagnostics(self):
self._test_compute_api('get_diagnostics', 'call',
instance=self.fake_instance)
Expand Down

0 comments on commit 0db055b

Please sign in to comment.