From f7c3ed7aead4a6bf28d2cbffc812d11768511d46 Mon Sep 17 00:00:00 2001 From: Kiall Mac Innes Date: Tue, 24 Nov 2015 13:21:53 +0000 Subject: [PATCH] Ensure designate-manage reads config before policy With the designate-manage command, the policy file is read before the configuration is parsed. If the policy file is in a non-default location, all designate-manage commands would fail. Change-Id: Ic1e37c18cc61732db8df0d59cdb687b0167d63c0 Closes-Bug: 1519356 --- designate/manage/akamai.py | 11 +++++++++-- designate/manage/base.py | 2 -- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/designate/manage/akamai.py b/designate/manage/akamai.py index 0e30fbc13..b7479f8e5 100644 --- a/designate/manage/akamai.py +++ b/designate/manage/akamai.py @@ -19,6 +19,7 @@ from oslo_config import cfg from oslo_log import log as logging from designate import exceptions +from designate import policy from designate import rpc from designate.i18n import _ # noqa from designate.i18n import _LI @@ -36,8 +37,6 @@ class AkamaiCommands(base.Commands): rpc.init(cfg.CONF) self.central_api = central_rpcapi.CentralAPI() - self.context.all_tenants = True - def _get_config(self, pool_id, target_id): pool = pool_object.Pool.from_config(cfg.CONF, pool_id) target = None @@ -61,6 +60,10 @@ class AkamaiCommands(base.Commands): client = impl_akamai.EnhancedDNSClient( target.options.get("username"), target.options.get("password")) + # Bug 1519356 - Init policy after configuration has been read + policy.init() + self.context.all_tenants = True + zone = self.central_api.find_domain(self.context, {"name": zone_name}) akamai_zone = client.getZone(zone_name) @@ -81,6 +84,10 @@ class AkamaiCommands(base.Commands): criterion = {"pool_id": pool_id} marker = None + # Bug 1519356 - Init policy after configuration has been read + policy.init() + self.context.all_tenants = True + while (marker is not False): zones = self.central_api.find_domains( self.context, criterion, limit=batch_size, marker=marker) diff --git a/designate/manage/base.py b/designate/manage/base.py index 97ae0dcca..0de7b8e95 100644 --- a/designate/manage/base.py +++ b/designate/manage/base.py @@ -13,7 +13,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from designate import policy from designate.context import DesignateContext @@ -39,4 +38,3 @@ class Commands(object): def __init__(self): self.context = DesignateContext.get_admin_context( request_id='designate-manage') - policy.init()