From d5e6a6aea5876af368eb93ef47887613c16bd583 Mon Sep 17 00:00:00 2001 From: Yao Lu Date: Mon, 26 Dec 2016 11:27:20 +0800 Subject: [PATCH] add host_template ext Change-Id: I342d5734a58782cbfc8d210a5956aae783f24b00 Signed-off-by: Yao Lu --- code/daisy/daisy/api/v1/host_template.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/daisy/daisy/api/v1/host_template.py b/code/daisy/daisy/api/v1/host_template.py index 3236bf70..75a67f62 100755 --- a/code/daisy/daisy/api/v1/host_template.py +++ b/code/daisy/daisy/api/v1/host_template.py @@ -432,6 +432,17 @@ class Controller(controller.BaseController): raise HTTPForbidden(explanation=msg, request=req, content_type="text/plain") + 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 'template_to_host' in dir(extersion): + extension.template_to_host(orig_host_meta) params = {'filters': {'cluster_name': host_template['cluster_name']}} templates = registry.host_template_lists_metadata( req.context, **params)