From efaea88bf13889519b4e370f2b3082e30ca0e973 Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Mon, 11 Sep 2017 10:00:45 +0000 Subject: [PATCH] Delay rpc initialization until config is available When being run within __init__() the rpc.init() call sees an empty config, leading to errors when doing RPC call later. So we move it to a later stage where we have read the config and can setup RPC properly. Change-Id: I195b57bf9c001883764dc160ced40272c5eb4fd3 Closes-Bug: 1651576 (cherry picked from commit 30e037063d714e2ce9792bb462d01ba8bf2a5c98) --- designate/manage/pool.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/designate/manage/pool.py b/designate/manage/pool.py index 431270295..59026d806 100644 --- a/designate/manage/pool.py +++ b/designate/manage/pool.py @@ -38,6 +38,10 @@ CONF = cfg.CONF class PoolCommands(base.Commands): def __init__(self): super(PoolCommands, self).__init__() + + # NOTE(jh): Cannot do this earlier because we are still missing the config + # at that point, see bug #1651576 + def _startup(self): rpc.init(cfg.CONF) self.central_api = central_rpcapi.CentralAPI() @@ -45,6 +49,7 @@ class PoolCommands(base.Commands): 'written to', default='/etc/designate/pools.yaml') def generate_file(self, file): + self._startup() try: pools = self.central_api.find_pools(self.context) except messaging.exceptions.MessagingTimeout: @@ -62,6 +67,7 @@ class PoolCommands(base.Commands): 'writen to', default='/etc/designate/pools.yaml') def export_from_config(self, file): + self._startup() try: pools = self.central_api.find_pools(self.context) except messaging.exceptions.MessagingTimeout: @@ -85,6 +91,7 @@ class PoolCommands(base.Commands): @base.args('--pool_id', help='ID of the pool to be examined', default=CONF['service:central'].default_pool_id) def show_config(self, pool_id): + self._startup() try: pool = self.central_api.find_pool(self.context, {"id": pool_id}) @@ -111,6 +118,7 @@ class PoolCommands(base.Commands): help='This will simulate what will happen when you run this command', default=False) def update(self, file, delete, dry_run): + self._startup() print('Updating Pools Configuration') print('****************************') output_msg = ['']