From: Zhiteng Huang Date: Thu, 24 Jan 2013 17:21:44 +0000 (+0800) Subject: Fix hosts extension and enable its tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ac7031b1b61496086394340f6bf15677f24bd39b;p=openstack-build%2Fcinder-build.git Fix hosts extension and enable its tests This patch corrects the import in hosts.py, fix the DB API service_get_by_host_and_topic raises ServiceNotFound exception with right parameter and move tests to the right place so that they are enabled. Fix LP bug: #1104231 Change-Id: I07c486f456196a3812eb5274b950ab9560a51cf3 --- diff --git a/cinder/api/contrib/hosts.py b/cinder/api/contrib/hosts.py index d3c11030f..40a4e9cc9 100644 --- a/cinder/api/contrib/hosts.py +++ b/cinder/api/contrib/hosts.py @@ -19,9 +19,9 @@ import webob.exc from xml.dom import minidom from xml.parsers import expat -from cinder.api.openstack import extensions +from cinder.api import extensions from cinder.api.openstack import wsgi -from cinder.api.openstack import xmlutil +from cinder.api import xmlutil from cinder import db from cinder import exception from cinder import flags @@ -206,7 +206,7 @@ class HostController(object): try: host_ref = db.service_get_by_host_and_topic(context, host, - 'cinder-volume') + FLAGS.volume_topic) except exception.ServiceNotFound: raise webob.exc.HTTPNotFound(explanation=_("Host not found")) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 121a23355..ddce45db6 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -278,7 +278,7 @@ def service_get_by_host_and_topic(context, host, topic): filter_by(topic=topic).\ first() if not result: - raise exception.ServiceNotFound(host=host, topic=topic) + raise exception.ServiceNotFound(service_id=None) return result diff --git a/cinder/tests/api/openstack/volume/contrib/test_hosts.py b/cinder/tests/api/contrib/test_hosts.py similarity index 99% rename from cinder/tests/api/openstack/volume/contrib/test_hosts.py rename to cinder/tests/api/contrib/test_hosts.py index a5c5b08dd..ff8f9bed0 100644 --- a/cinder/tests/api/openstack/volume/contrib/test_hosts.py +++ b/cinder/tests/api/contrib/test_hosts.py @@ -20,7 +20,7 @@ import datetime from lxml import etree import webob.exc -from cinder.api.openstack.volume.contrib import hosts as os_hosts +from cinder.api.contrib import hosts as os_hosts from cinder import context from cinder import db from cinder import flags