Make tripleoclient compatible with cliff-3.4.0

cliff with 3.4.0[1] release moved to stevedore for
loading entry points, with this logging get's setup
too early before config options are loaded.

Move Config register and logging setup to app's main
function.

Also after moving logging.setup to app's main function
a time.time call is removed so adjust test for it.

[1] https://github.com/openstack/cliff/commit/6ac510

Suggested-By: Doug Hellmann <doug@doughellmann.com>
Closes-Bug: #1890389
Change-Id: Ia9a2146a0ad3156c80f8cdffe33280380319e3d6
This commit is contained in:
yatinkarel 2020-09-21 18:00:40 +05:30
parent cb2187b433
commit a8831c6000
7 changed files with 19 additions and 13 deletions

View File

@ -1507,7 +1507,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# assuming heat deploy consumed a 3m out of total 451m timeout
with mock.patch('time.time', side_effect=[0, 1585820346, 1585820526]):
with mock.patch('time.time', side_effect=[1585820346, 1585820526]):
self.cmd.take_action(parsed_args)
self.assertIn(
[mock.call(mock.ANY, mock.ANY, 'overcloud', mock.ANY,

View File

@ -25,8 +25,6 @@ from tripleoclient import utils as oooutils
from tripleoclient.workflows import deployment
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class Authorize(command.Command):
@ -75,6 +73,8 @@ class Authorize(command.Command):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action({})".format(parsed_args))
clients = self.app.client_manager

View File

@ -28,8 +28,6 @@ from tripleoclient.workflows import deployment
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class ExternalUpdateRun(command.Command):
@ -112,6 +110,8 @@ class ExternalUpdateRun(command.Command):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()

View File

@ -27,8 +27,6 @@ from tripleoclient.workflows import deployment
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class ExternalUpgradeRun(command.Command):
@ -112,6 +110,8 @@ class ExternalUpgradeRun(command.Command):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()

View File

@ -29,8 +29,6 @@ from tripleoclient.workflows import package_update
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class UpdatePrepare(DeployOvercloud):
@ -54,6 +52,8 @@ class UpdatePrepare(DeployOvercloud):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()
@ -172,6 +172,8 @@ class UpdateRun(command.Command):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()
@ -237,6 +239,8 @@ class UpdateConverge(DeployOvercloud):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()

View File

@ -28,8 +28,6 @@ from tripleoclient.workflows import deployment
from tripleoclient.workflows import parameters
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class UpgradePrepare(DeployOvercloud):
@ -59,6 +57,8 @@ class UpgradePrepare(DeployOvercloud):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()
@ -207,6 +207,8 @@ class UpgradeRun(command.Command):
return parser
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
oooutils.ensure_run_as_normal_user()

View File

@ -21,8 +21,6 @@ from tripleoclient import utils
from tripleoclient.v1.tripleo_deploy import Deploy
CONF = cfg.CONF
logging.register_options(CONF)
logging.setup(CONF, '')
class Upgrade(Deploy):
@ -31,6 +29,8 @@ class Upgrade(Deploy):
log = logging.getLogger(__name__ + ".Upgrade")
def take_action(self, parsed_args):
logging.register_options(CONF)
logging.setup(CONF, '')
self.log.debug("take_action(%s)" % parsed_args)
if (not parsed_args.yes
and not utils.prompt_user_for_confirmation(