]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix hosts extension and enable its tests
authorZhiteng Huang <zhiteng.huang@intel.com>
Thu, 24 Jan 2013 17:21:44 +0000 (01:21 +0800)
committerZhiteng Huang <zhiteng.huang@intel.com>
Thu, 24 Jan 2013 17:39:17 +0000 (01:39 +0800)
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

cinder/api/contrib/hosts.py
cinder/db/sqlalchemy/api.py
cinder/tests/api/contrib/test_hosts.py [moved from cinder/tests/api/openstack/volume/contrib/test_hosts.py with 99% similarity]

index d3c11030fd29db9056001100c5c993d4bcfb6618..40a4e9cc93712d87d35af302b7d5a5705a7d0f2f 100644 (file)
@@ -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"))
 
index 121a233553d0312fc3d0c0cbb44b15e977fa3e9e..ddce45db687f7ee631b5c10af7c483b855daa3eb 100644 (file)
@@ -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
 
 
similarity index 99%
rename from cinder/tests/api/openstack/volume/contrib/test_hosts.py
rename to cinder/tests/api/contrib/test_hosts.py
index a5c5b08dd9674e84cdea92f5bcd7a471954ca6d0..ff8f9bed029bcd0c058a7d9034df962abb3dbea3 100644 (file)
@@ -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