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
This commit is contained in:
Kiall Mac Innes 2015-11-24 13:21:53 +00:00
parent d7756d66e8
commit f7c3ed7aea
2 changed files with 9 additions and 4 deletions

View File

@ -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)

View File

@ -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()