get location parameter form ext hwm

Change-Id: I972dbba8777e966932bc323df6ffdc9535a52499
Signed-off-by: Yao Lu <lu.yao135@zte.com.cn>
This commit is contained in:
Yao Lu 2016-12-26 10:13:52 +08:00
parent 3cf0d7b5be
commit 6829df0d98
3 changed files with 12 additions and 5 deletions

View File

@ -710,6 +710,18 @@ class Controller(controller.BaseController):
"""
self._enforce(req, 'get_host')
host_meta = self.get_host_meta_or_404(req, id)
path = os.path.join(os.path.abspath(os.path.dirname(
os.path.realpath(__file__))), 'ext')
for root, dirs, names in os.walk(path):
filename = 'router.py'
if filename in names:
ext_name = root.split(path)[1].strip('/')
ext_func = "%s.api.hosts" % ext_name
extension = importutils.import_module('daisy.api.v1.ext',
ext_func)
if 'complement_host_extra_info' in dir(extersion):
extension.complement_host_extra_info(host_meta)
os_handle = get_os_handle()
os_handle.check_discover_state(req,
host_meta,

View File

@ -388,7 +388,6 @@ class Controller(object):
raise
# Currently not used
location = ""
host_interface = self.db_api.get_host_interface(req.context, id)
@ -422,9 +421,6 @@ class Controller(object):
host_data['host']['deployment_backends'] = backends
if cluster_name:
host_data['host']['cluster'] = cluster_name
host_data['host']['position'] = location
return host_data
@utils.mutating

View File

@ -29,4 +29,3 @@ class TestHost(test.TestCase):
host_controller = registry_hosts.Controller()
host = host_controller.get_host(self.req, id)
self.assertEqual(daisy.db.sqlalchemy.models.Host, type(host['host']))
self.assertEqual("", host['host'].position)