From 05712358dab8d987b238e8588a96224b852090d4 Mon Sep 17 00:00:00 2001 From: Thomas Morin Date: Wed, 30 May 2018 17:46:07 +0200 Subject: [PATCH] avoid parsing heat.conf for each Heat resource This moves heat configuration parsing to module loading time. Parsing the config for each resource does not seem to be useful, and profiling with pyflame shows that it is a significant hit, measurable in tens of seconds on heat stack with a large number of Contrail heat resources. Change-Id: Iad81d60e63fdfb554e6c42dbcdf58848586984f1 Closes-Bug: 1779078 (cherry picked from commit df5389e5bda19a0ff5cbebc82c0b892394331ef8) --- contrail_heat/resources/contrail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrail_heat/resources/contrail.py b/contrail_heat/resources/contrail.py index 821dd5c..c34bd04 100644 --- a/contrail_heat/resources/contrail.py +++ b/contrail_heat/resources/contrail.py @@ -13,6 +13,8 @@ LOG = logging.getLogger(__name__) +cfg_parser = ConfigParser.ConfigParser() +cfg_parser.read("/etc/heat/heat.conf") def set_auth_token(func): def wrapper(self, *args, **kwargs): @@ -34,8 +36,6 @@ class ContrailResource(resource.Resource): def __init__(self, name, json_snippet, stack): super(ContrailResource, self).__init__(name, json_snippet, stack) - cfg_parser = ConfigParser.ConfigParser() - cfg_parser.read("/etc/heat/heat.conf") self._user = self._read_cfg(cfg_parser, 'clients_contrail', 'user',