From 6829df0d987fbca2b68e8f1d8b0e6ffecf24baae Mon Sep 17 00:00:00 2001 From: Yao Lu Date: Mon, 26 Dec 2016 10:13:52 +0800 Subject: [PATCH] get location parameter form ext hwm Change-Id: I972dbba8777e966932bc323df6ffdc9535a52499 Signed-off-by: Yao Lu --- code/daisy/daisy/api/v1/hosts.py | 12 ++++++++++++ code/daisy/daisy/registry/api/v1/hosts.py | 4 ---- code/daisy/daisy/tests/registry/api/test_hosts.py | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/code/daisy/daisy/api/v1/hosts.py b/code/daisy/daisy/api/v1/hosts.py index 1bf2cdd0..058ca691 100755 --- a/code/daisy/daisy/api/v1/hosts.py +++ b/code/daisy/daisy/api/v1/hosts.py @@ -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, diff --git a/code/daisy/daisy/registry/api/v1/hosts.py b/code/daisy/daisy/registry/api/v1/hosts.py index 7cdaa067..5462ee32 100755 --- a/code/daisy/daisy/registry/api/v1/hosts.py +++ b/code/daisy/daisy/registry/api/v1/hosts.py @@ -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 diff --git a/code/daisy/daisy/tests/registry/api/test_hosts.py b/code/daisy/daisy/tests/registry/api/test_hosts.py index 1b9fef7f..b4d71d51 100644 --- a/code/daisy/daisy/tests/registry/api/test_hosts.py +++ b/code/daisy/daisy/tests/registry/api/test_hosts.py @@ -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)