summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/api/openstack/compute/contrib/certificates.py13
-rw-r--r--nova/cert/manager.py2
-rw-r--r--nova/cert/rpcapi.py71
-rw-r--r--nova/compute/api.py13
-rw-r--r--nova/consoleauth/manager.py2
-rw-r--r--nova/consoleauth/rpcapi.py53
-rw-r--r--nova/image/s3.py19
-rw-r--r--nova/tests/cert/__init__.py19
-rw-r--r--nova/tests/cert/test_rpcapi.py93
-rw-r--r--nova/tests/consoleauth/__init__.py19
-rw-r--r--nova/tests/consoleauth/test_consoleauth.py (renamed from nova/tests/test_consoleauth.py)2
-rw-r--r--nova/tests/consoleauth/test_rpcapi.py74
-rw-r--r--nova/tests/fakelibvirt.py3
-rw-r--r--nova/tests/test_compute.py17
-rw-r--r--nova/tests/test_libvirt.py4
-rw-r--r--nova/tests/test_xenapi.py3
-rw-r--r--nova/tests/xenapi/stubs.py10
-rw-r--r--nova/virt/libvirt/connection.py6
-rw-r--r--nova/virt/xenapi/volume_utils.py27
-rw-r--r--nova/vnc/xvp_proxy.py8
20 files changed, 377 insertions, 81 deletions
diff --git a/nova/api/openstack/compute/contrib/certificates.py b/nova/api/openstack/compute/contrib/certificates.py
index 601825950..7c33c295e 100644
--- a/nova/api/openstack/compute/contrib/certificates.py
+++ b/nova/api/openstack/compute/contrib/certificates.py
@@ -19,6 +19,7 @@ import webob.exc
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
+import nova.cert.rpcapi
from nova import flags
from nova import log as logging
from nova import network
@@ -64,6 +65,7 @@ class CertificatesController(object):
def __init__(self):
self.network_api = network.API()
+ self.cert_rpcapi = nova.cert.rpcapi.CertAPI()
super(CertificatesController, self).__init__()
@wsgi.serializers(xml=CertificateTemplate)
@@ -74,9 +76,8 @@ class CertificatesController(object):
if id != 'root':
msg = _("Only root certificate can be retrieved.")
raise webob.exc.HTTPNotImplemented(explanation=msg)
- cert = rpc.call(context, FLAGS.cert_topic,
- {"method": "fetch_ca",
- "args": {"project_id": context.project_id}})
+ cert = self.cert_rpcapi.fetch_ca(context,
+ project_id=context.project_id)
return {'certificate': _translate_certificate_view(cert)}
@wsgi.serializers(xml=CertificateTemplate)
@@ -84,10 +85,8 @@ class CertificatesController(object):
"""Return a list of certificates."""
context = req.environ['nova.context']
authorize(context)
- pk, cert = rpc.call(context, FLAGS.cert_topic,
- {"method": "generate_x509_cert",
- "args": {"user_id": context.user_id,
- "project_id": context.project_id}})
+ pk, cert = self.cert_rpcapi.generate_x509_cert(context,
+ user_id=context.user_id, project_id=context.project_id)
context = req.environ['nova.context']
return {'certificate': _translate_certificate_view(cert, pk)}
diff --git a/nova/cert/manager.py b/nova/cert/manager.py
index b9f35b72d..840a782c5 100644
--- a/nova/cert/manager.py
+++ b/nova/cert/manager.py
@@ -36,6 +36,8 @@ FLAGS = flags.FLAGS
class CertManager(manager.Manager):
+ RPC_API_VERSION = '1.0'
+
def init_host(self):
crypto.ensure_ca_filesystem()
diff --git a/nova/cert/rpcapi.py b/nova/cert/rpcapi.py
new file mode 100644
index 000000000..d062026da
--- /dev/null
+++ b/nova/cert/rpcapi.py
@@ -0,0 +1,71 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012, Red Hat, Inc.
+#
+# 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.
+
+"""
+Client side of the cert manager RPC API.
+"""
+
+from nova import flags
+import nova.rpc.proxy
+
+
+FLAGS = flags.FLAGS
+
+
+class CertAPI(nova.rpc.proxy.RpcProxy):
+ '''Client side of the cert rpc API.
+
+ API version history:
+
+ 1.0 - Initial version.
+ '''
+
+ RPC_API_VERSION = '1.0'
+
+ def __init__(self):
+ super(CertAPI, self).__init__(topic=FLAGS.cert_topic,
+ default_version=self.RPC_API_VERSION)
+
+ def revoke_certs_by_user(self, ctxt, user_id):
+ return self.call(ctxt, self.make_msg('revoke_certs_by_user',
+ user_id=user_id))
+
+ def revoke_certs_by_project(self, ctxt, project_id):
+ return self.call(ctxt, self.make_msg('revoke_certs_by_project',
+ project_id=project_id))
+
+ def revoke_certs_by_user_and_project(self, ctxt, user_id, project_id):
+ return self.call(ctxt,
+ self.make_msg('revoke_certs_by_user_and_project',
+ user_id=user_id, project_id=project_id))
+
+ def generate_x509_cert(self, ctxt, user_id, project_id):
+ return self.call(ctxt, self.make_msg('generate_x509_cert',
+ user_id=user_id,
+ project_id=project_id))
+
+ def fetch_ca(self, ctxt, project_id):
+ return self.call(ctxt, self.make_msg('fetch_ca',
+ project_id=project_id))
+
+ def fetch_crl(self, ctxt, project_id):
+ return self.call(ctxt, self.make_msg('fetch_crl',
+ project_id=project_id))
+
+ def decrypt_text(self, ctxt, project_id, text):
+ return self.call(ctxt, self.make_msg('decrypt_text',
+ project_id=project_id,
+ text=text))
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 82bcff3f1..02accd5b1 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -33,6 +33,7 @@ from nova.compute import power_state
from nova.compute import task_states
from nova.compute import vm_states
from nova import crypto
+from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova.db import base
from nova import exception
from nova import flags
@@ -162,6 +163,7 @@ class API(BaseAPI):
self.network_api = network_api or network.API()
self.volume_api = volume_api or volume.API()
+ self.consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
super(API, self).__init__(**kwargs)
def _check_injected_file_quota(self, context, injected_files):
@@ -1630,14 +1632,9 @@ class API(BaseAPI):
connect_info = self._call_compute_message('get_vnc_console',
context, instance, params={"console_type": console_type})
- rpc.call(context, '%s' % FLAGS.consoleauth_topic,
- {'method': 'authorize_console',
- 'args': {'token': connect_info['token'],
- 'console_type': console_type,
- 'host': connect_info['host'],
- 'port': connect_info['port'],
- 'internal_access_path':
- connect_info['internal_access_path']}})
+ self.consoleauth_rpcapi.authorize_console(context,
+ connect_info['token'], console_type, connect_info['host'],
+ connect_info['port'], connect_info['internal_access_path'])
return {'url': connect_info['access_url']}
diff --git a/nova/consoleauth/manager.py b/nova/consoleauth/manager.py
index 27e3cb74d..a5c133e7a 100644
--- a/nova/consoleauth/manager.py
+++ b/nova/consoleauth/manager.py
@@ -45,6 +45,8 @@ FLAGS.register_opts(consoleauth_opts)
class ConsoleAuthManager(manager.Manager):
"""Manages token based authentication."""
+ RPC_API_VERSION = '1.0'
+
def __init__(self, scheduler_driver=None, *args, **kwargs):
super(ConsoleAuthManager, self).__init__(*args, **kwargs)
self.tokens = {}
diff --git a/nova/consoleauth/rpcapi.py b/nova/consoleauth/rpcapi.py
new file mode 100644
index 000000000..5cb940a34
--- /dev/null
+++ b/nova/consoleauth/rpcapi.py
@@ -0,0 +1,53 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012, Red Hat, Inc.
+#
+# 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.
+
+"""
+Client side of the consoleauth RPC API.
+"""
+
+from nova import flags
+import nova.rpc.proxy
+
+
+FLAGS = flags.FLAGS
+
+
+class ConsoleAuthAPI(nova.rpc.proxy.RpcProxy):
+ '''Client side of the consoleauth rpc API.
+
+ API version history:
+
+ 1.0 - Initial version.
+ '''
+
+ RPC_API_VERSION = '1.0'
+
+ def __init__(self):
+ super(ConsoleAuthAPI, self).__init__(topic=FLAGS.consoleauth_topic,
+ default_version=self.RPC_API_VERSION)
+
+ def authorize_console(self, ctxt, token, console_type, host, port,
+ internal_access_path):
+ # The remote side doesn't return anything, but we want to block
+ # until it completes.
+ return self.call(ctxt,
+ self.make_msg('authorize_console',
+ token=token, console_type=console_type,
+ host=host, port=port,
+ internal_access_path=internal_access_path))
+
+ def check_token(self, ctxt, token):
+ return self.call(ctxt, self.make_msg('check_token', token=token))
diff --git a/nova/image/s3.py b/nova/image/s3.py
index 31dfa1916..9ed060464 100644
--- a/nova/image/s3.py
+++ b/nova/image/s3.py
@@ -30,6 +30,7 @@ import eventlet
from lxml import etree
from nova.api.ec2 import ec2utils
+import nova.cert.rpcapi
from nova import exception
from nova import flags
from nova import image
@@ -68,6 +69,7 @@ class S3ImageService(object):
"""Wraps an existing image service to support s3 based register."""
def __init__(self, service=None, *args, **kwargs):
+ self.cert_rpcapi = nova.cert.rpcapi.CertAPI()
self.service = service or image.get_default_image_service()
self.service.__init__(*args, **kwargs)
@@ -366,23 +368,20 @@ class S3ImageService(object):
return image
- @staticmethod
- def _decrypt_image(context, encrypted_filename, encrypted_key,
+ def _decrypt_image(self, context, encrypted_filename, encrypted_key,
encrypted_iv, decrypted_filename):
elevated = context.elevated()
try:
- key = rpc.call(elevated, FLAGS.cert_topic,
- {"method": "decrypt_text",
- "args": {"project_id": context.project_id,
- "text": base64.b64encode(encrypted_key)}})
+ key = self.cert_rpcapi.decrypt_text(elevated,
+ project_id=context.project_id,
+ text=base64.b64encode(encrypted_key))
except Exception, exc:
msg = _('Failed to decrypt private key: %s') % exc
raise exception.NovaException(msg)
try:
- iv = rpc.call(elevated, FLAGS.cert_topic,
- {"method": "decrypt_text",
- "args": {"project_id": context.project_id,
- "text": base64.b64encode(encrypted_iv)}})
+ iv = self.cert_rpcapi.decrypt_text(elevated,
+ project_id=context.project_id,
+ text=base64.b64encode(encrypted_iv))
except Exception, exc:
raise exception.NovaException(_('Failed to decrypt initialization '
'vector: %s') % exc)
diff --git a/nova/tests/cert/__init__.py b/nova/tests/cert/__init__.py
new file mode 100644
index 000000000..7e04e7c73
--- /dev/null
+++ b/nova/tests/cert/__init__.py
@@ -0,0 +1,19 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 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.
+
+# NOTE(vish): this forces the fixtures from tests/__init.py:setup() to work
+from nova.tests import *
diff --git a/nova/tests/cert/test_rpcapi.py b/nova/tests/cert/test_rpcapi.py
new file mode 100644
index 000000000..2e3feeaaf
--- /dev/null
+++ b/nova/tests/cert/test_rpcapi.py
@@ -0,0 +1,93 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012, Red Hat, Inc.
+#
+# 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.
+
+"""
+Unit Tests for nova.cert.rpcapi
+"""
+
+from nova.cert import rpcapi as cert_rpcapi
+from nova import context
+from nova import flags
+from nova import rpc
+from nova import test
+
+
+FLAGS = flags.FLAGS
+
+
+class CertRpcAPITestCase(test.TestCase):
+
+ def setUp(self):
+ super(CertRpcAPITestCase, self).setUp()
+
+ def tearDown(self):
+ super(CertRpcAPITestCase, self).tearDown()
+
+ def _test_cert_api(self, method, **kwargs):
+ ctxt = context.RequestContext('fake_user', 'fake_project')
+ rpcapi = cert_rpcapi.CertAPI()
+ expected_retval = 'foo'
+ expected_msg = rpcapi.make_msg(method, **kwargs)
+ expected_msg['version'] = rpcapi.RPC_API_VERSION
+
+ self.call_ctxt = None
+ self.call_topic = None
+ self.call_msg = None
+ self.call_timeout = None
+
+ def _fake_call(_ctxt, _topic, _msg, _timeout):
+ self.call_ctxt = _ctxt
+ self.call_topic = _topic
+ self.call_msg = _msg
+ self.call_timeout = _timeout
+ return expected_retval
+
+ self.stubs.Set(rpc, 'call', _fake_call)
+
+ retval = getattr(rpcapi, method)(ctxt, **kwargs)
+
+ self.assertEqual(retval, expected_retval)
+ self.assertEqual(self.call_ctxt, ctxt)
+ self.assertEqual(self.call_topic, FLAGS.cert_topic)
+ self.assertEqual(self.call_msg, expected_msg)
+ self.assertEqual(self.call_timeout, None)
+
+ def test_revoke_certs_by_user(self):
+ self._test_cert_api('revoke_certs_by_user', user_id='fake_user_id')
+
+ def test_revoke_certs_by_project(self):
+ self._test_cert_api('revoke_certs_by_project',
+ project_id='fake_project_id')
+
+ def test_revoke_certs_by_user_and_project(self):
+ self._test_cert_api('revoke_certs_by_user_and_project',
+ user_id='fake_user_id',
+ project_id='fake_project_id')
+
+ def test_generate_x509_cert(self):
+ self._test_cert_api('generate_x509_cert',
+ user_id='fake_user_id',
+ project_id='fake_project_id')
+
+ def test_fetch_ca(self):
+ self._test_cert_api('fetch_ca', project_id='fake_project_id')
+
+ def test_fetch_crl(self):
+ self._test_cert_api('fetch_crl', project_id='fake_project_id')
+
+ def test_decrypt_text(self):
+ self._test_cert_api('decrypt_text',
+ project_id='fake_project_id', text='blah')
diff --git a/nova/tests/consoleauth/__init__.py b/nova/tests/consoleauth/__init__.py
new file mode 100644
index 000000000..7e04e7c73
--- /dev/null
+++ b/nova/tests/consoleauth/__init__.py
@@ -0,0 +1,19 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 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.
+
+# NOTE(vish): this forces the fixtures from tests/__init.py:setup() to work
+from nova.tests import *
diff --git a/nova/tests/test_consoleauth.py b/nova/tests/consoleauth/test_consoleauth.py
index ba336ccd5..fd30bc2d2 100644
--- a/nova/tests/test_consoleauth.py
+++ b/nova/tests/consoleauth/test_consoleauth.py
@@ -41,7 +41,7 @@ class ConsoleauthTestCase(test.TestCase):
def setUp(self):
super(ConsoleauthTestCase, self).setUp()
- self.manager = importutils.import_object(FLAGS.consoleauth_manager)
+ self.manager = manager.ConsoleAuthManager()
self.context = context.get_admin_context()
def test_tokens_expire(self):
diff --git a/nova/tests/consoleauth/test_rpcapi.py b/nova/tests/consoleauth/test_rpcapi.py
new file mode 100644
index 000000000..546183185
--- /dev/null
+++ b/nova/tests/consoleauth/test_rpcapi.py
@@ -0,0 +1,74 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012, Red Hat, Inc.
+#
+# 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.
+
+"""
+Unit Tests for nova.consoleauth.rpcapi
+"""
+
+from nova.consoleauth import rpcapi as consoleauth_rpcapi
+from nova import context
+from nova import flags
+from nova import rpc
+from nova import test
+
+
+FLAGS = flags.FLAGS
+
+
+class ConsoleAuthRpcAPITestCase(test.TestCase):
+
+ def setUp(self):
+ super(ConsoleAuthRpcAPITestCase, self).setUp()
+
+ def tearDown(self):
+ super(ConsoleAuthRpcAPITestCase, self).tearDown()
+
+ def _test_consoleauth_api(self, method, **kwargs):
+ ctxt = context.RequestContext('fake_user', 'fake_project')
+ rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
+ expected_retval = 'foo'
+ expected_msg = rpcapi.make_msg(method, **kwargs)
+ expected_msg['version'] = rpcapi.RPC_API_VERSION
+
+ self.call_ctxt = None
+ self.call_topic = None
+ self.call_msg = None
+ self.call_timeout = None
+
+ def _fake_call(_ctxt, _topic, _msg, _timeout):
+ self.call_ctxt = _ctxt
+ self.call_topic = _topic
+ self.call_msg = _msg
+ self.call_timeout = _timeout
+ return expected_retval
+
+ self.stubs.Set(rpc, 'call', _fake_call)
+
+ retval = getattr(rpcapi, method)(ctxt, **kwargs)
+
+ self.assertEqual(retval, expected_retval)
+ self.assertEqual(self.call_ctxt, ctxt)
+ self.assertEqual(self.call_topic, FLAGS.consoleauth_topic)
+ self.assertEqual(self.call_msg, expected_msg)
+ self.assertEqual(self.call_timeout, None)
+
+ def test_authorize_console(self):
+ self._test_consoleauth_api('authorize_console', token='token',
+ console_type='ctype', host='h', port='p',
+ internal_access_path='iap')
+
+ def test_check_token(self):
+ self._test_consoleauth_api('check_token', token='t')
diff --git a/nova/tests/fakelibvirt.py b/nova/tests/fakelibvirt.py
index 5a317dca1..693330408 100644
--- a/nova/tests/fakelibvirt.py
+++ b/nova/tests/fakelibvirt.py
@@ -507,6 +507,9 @@ class Connection(object):
def getVersion(self):
return 14000
+ def getHostname(self):
+ return 'compute1'
+
def getCapabilities(self):
return '''<capabilities>
<host>
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index 677e0aa0e..c574b8863 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -3484,26 +3484,23 @@ class ComputeAPITestCase(BaseTestCase):
'console_type': fake_console_type,
'host': 'fake_console_host',
'port': 'fake_console_port',
- 'internal_access_path': 'fake_access_path',
- 'access_url': 'fake_console_url'}
+ 'internal_access_path': 'fake_access_path'}
+ fake_connect_info2 = copy.deepcopy(fake_connect_info)
+ fake_connect_info2['access_url'] = 'fake_console_url'
self.mox.StubOutWithMock(rpc, 'call')
rpc_msg1 = {'method': 'get_vnc_console',
'args': {'instance_uuid': fake_instance['uuid'],
'console_type': fake_console_type}}
- # 2nd rpc.call receives almost everything from fake_connect_info
- # except 'access_url'
- rpc_msg2_args = dict([(k, v)
- for k, v in fake_connect_info.items()
- if k != 'access_url'])
rpc_msg2 = {'method': 'authorize_console',
- 'args': rpc_msg2_args}
+ 'args': fake_connect_info,
+ 'version': '1.0'}
rpc.call(self.context, 'compute.%s' % fake_instance['host'],
- rpc_msg1).AndReturn(fake_connect_info)
+ rpc_msg1).AndReturn(fake_connect_info2)
rpc.call(self.context, FLAGS.consoleauth_topic,
- rpc_msg2).AndReturn(None)
+ rpc_msg2, None).AndReturn(None)
self.mox.ReplayAll()
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 42dfdbfa7..d70618807 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -1696,6 +1696,9 @@ class HostStateTestCase(test.TestCase):
def get_hypervisor_version(self):
return 13091
+ def get_hypervisor_hostname(self):
+ return 'compute1'
+
def get_disk_available_least(self):
return 13091
@@ -1722,6 +1725,7 @@ class HostStateTestCase(test.TestCase):
self.assertEquals(stats["host_memory_free"], 409)
self.assertEquals(stats["hypervisor_type"], 'QEMU')
self.assertEquals(stats["hypervisor_version"], 13091)
+ self.assertEquals(stats["hypervisor_hostname"], 'compute1')
class NWFilterFakes:
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 2e5c65de4..62c2f67ea 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -102,7 +102,6 @@ class XenAPIVolumeTestCase(test.TestCase):
firewall_driver='nova.virt.xenapi.firewall.'
'Dom0IptablesFirewallDriver')
db_fakes.stub_out_db_instance_api(self.stubs)
- stubs.stub_out_get_target(self.stubs)
xenapi_fake.reset()
self.instance_values = {'id': 1,
'project_id': self.user_id,
@@ -844,7 +843,6 @@ class XenAPIMigrateInstance(test.TestCase):
'Dom0IptablesFirewallDriver')
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
db_fakes.stub_out_db_instance_api(self.stubs)
- stubs.stub_out_get_target(self.stubs)
xenapi_fake.reset()
xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
self.user_id = 'fake'
@@ -1700,7 +1698,6 @@ class XenAPISRSelectionTestCase(test.TestCase):
"""Unit tests for testing we find the right SR."""
def setUp(self):
super(XenAPISRSelectionTestCase, self).setUp()
- stubs.stub_out_get_target(self.stubs)
xenapi_fake.reset()
def test_safe_find_sr_raise_exception(self):
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index 5dfb3b281..7486c4d74 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -22,10 +22,8 @@ from eventlet import tpool
from nova.virt.xenapi import connection as xenapi_conn
from nova.virt.xenapi import fake
-from nova.virt.xenapi import volume_utils
from nova.virt.xenapi import vm_utils
from nova.virt.xenapi import vmops
-from nova import utils
def stubout_firewall_driver(stubs, conn):
@@ -73,14 +71,6 @@ def stubout_session(stubs, cls, product_version=(5, 6, 2), **opt_args):
stubs.Set(tpool, 'execute', lambda m, *a, **kw: m(*a, **kw))
-def stub_out_get_target(stubs):
- """Stubs out _get_target in volume_utils"""
- def fake_get_target(volume_id):
- return (None, None)
-
- stubs.Set(volume_utils, '_get_target', fake_get_target)
-
-
def stubout_get_this_vm_uuid(stubs):
def f():
vms = [rec['uuid'] for ref, rec
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index a7c14cd65..23429e84d 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -1944,6 +1944,10 @@ class LibvirtConnection(driver.ComputeDriver):
return method()
+ def get_hypervisor_hostname(self):
+ """Returns the hostname of the hypervisor."""
+ return self._conn.getHostname()
+
def get_cpu_info(self):
"""Get cpuinfo information.
@@ -2055,6 +2059,7 @@ class LibvirtConnection(driver.ComputeDriver):
'local_gb_used': self.get_local_gb_used(),
'hypervisor_type': self.get_hypervisor_type(),
'hypervisor_version': self.get_hypervisor_version(),
+ 'hypervisor_hostname': self.get_hypervisor_hostname(),
'cpu_info': self.get_cpu_info(),
'service_id': service_ref['id'],
'disk_available_least': self.get_disk_available_least()}
@@ -2637,6 +2642,7 @@ class HostState(object):
self.connection.get_memory_mb_used())
data["hypervisor_type"] = self.connection.get_hypervisor_type()
data["hypervisor_version"] = self.connection.get_hypervisor_version()
+ data["hypervisor_hostname"] = self.connection.get_hypervisor_hostname()
self._stats = data
diff --git a/nova/virt/xenapi/volume_utils.py b/nova/virt/xenapi/volume_utils.py
index 7b305d22c..9c207a4cd 100644
--- a/nova/virt/xenapi/volume_utils.py
+++ b/nova/virt/xenapi/volume_utils.py
@@ -384,30 +384,3 @@ def _get_iqn(iscsi_string, id):
elif iscsi_string is None or FLAGS.iqn_prefix:
volume_id = _get_volume_id(id)
return '%s:%s' % (FLAGS.iqn_prefix, volume_id)
-
-
-def _get_target(volume_id):
- """
- Gets iscsi name and portal from volume name and host.
- For this method to work the following are needed:
- 1) volume_ref['host'] must resolve to something rather than loopback
- """
- volume_ref = db.volume_get(context.get_admin_context(),
- volume_id)
- result = (None, None)
- try:
- (r, _e) = utils.execute('iscsiadm',
- '-m', 'discovery',
- '-t', 'sendtargets',
- '-p', volume_ref['host'], run_as_root=True)
- except exception.ProcessExecutionError, exc:
- LOG.exception(exc)
- else:
- volume_name = "volume-%08x" % volume_id
- for target in r.splitlines():
- if FLAGS.iscsi_ip_prefix in target and volume_name in target:
- (location, _sep, iscsi_name) = target.partition(" ")
- break
- iscsi_portal = location.split(",")[0]
- result = (iscsi_name, iscsi_portal)
- return result
diff --git a/nova/vnc/xvp_proxy.py b/nova/vnc/xvp_proxy.py
index 5aedfe0fb..1eca54530 100644
--- a/nova/vnc/xvp_proxy.py
+++ b/nova/vnc/xvp_proxy.py
@@ -26,6 +26,7 @@ import eventlet.green
import eventlet.greenio
import eventlet.wsgi
+from nova.consoleauth import rpcapi as consoleauth_rpcapi
from nova import context
from nova import flags
from nova import log as logging
@@ -49,8 +50,6 @@ xvp_proxy_opts = [
FLAGS = flags.FLAGS
FLAGS.register_opts(xvp_proxy_opts)
-flags.DECLARE('consoleauth_topic', 'nova.consoleauth')
-
class XCPVNCProxy(object):
"""Class to use the xvp auth protocol to proxy instance vnc consoles."""
@@ -145,9 +144,8 @@ class XCPVNCProxy(object):
return "Invalid Request"
ctxt = context.get_admin_context()
- connect_info = rpc.call(ctxt, FLAGS.consoleauth_topic,
- {'method': 'check_token',
- 'args': {'token': token}})
+ api = consoleauth_rpcapi.ConsoleAuthAPI()
+ connect_info = api.check_token(ctxt, token)
if not connect_info:
LOG.audit(_("Request made with invalid token: %s"), req)