Logging refactor
- Replace logging with logging from oslo_log In order to have timestamps as well as other features this patch replaces python logging to extended logging from oslo_log. This allows to produce timestamps in output messages - Replace some prints with log.info to have timing information in logs Change-Id: I3569272795a52bb25f3de502fdfd5006ff6b8be1 Related-Bug: #1890389
This commit is contained in:
parent
bec4e6fcb1
commit
b139da3995
@ -1551,7 +1551,8 @@ 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=[1585820346, 1585820526]):
|
||||
with mock.patch('time.time', side_effect=[0, 1585820346,
|
||||
0, 0, 1585820526]):
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.assertIn(
|
||||
[mock.call(mock.ANY, mock.ANY, 'overcloud', mock.ANY,
|
||||
|
@ -75,7 +75,6 @@ class Authorize(command.Command):
|
||||
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
|
||||
stack = oooutils.get_stack(clients.orchestration, parsed_args.stack)
|
||||
|
@ -15,9 +15,10 @@
|
||||
|
||||
import argparse
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from prettytable import PrettyTable
|
||||
from pwd import getpwuid
|
||||
import re
|
||||
@ -44,6 +45,8 @@ from tripleoclient.workflows import deployment
|
||||
from tripleoclient.workflows import parameters as workflow_params
|
||||
from tripleoclient.workflows import plan_management
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class DeployOvercloud(command.Command):
|
||||
"""Deploy Overcloud"""
|
||||
@ -282,7 +285,7 @@ class DeployOvercloud(command.Command):
|
||||
workflow_params.check_deprecated_parameters(self.clients, stack_name)
|
||||
|
||||
if not update_plan_only:
|
||||
print("Deploying templates in the directory {0}".format(
|
||||
self.log.info("Deploying templates in the directory {0}".format(
|
||||
os.path.abspath(tht_root)))
|
||||
deployment.deploy_and_wait(
|
||||
log=self.log,
|
||||
@ -472,7 +475,7 @@ class DeployOvercloud(command.Command):
|
||||
self._download_missing_files_from_plan(
|
||||
tht_root, parsed_args.stack)
|
||||
|
||||
print("Processing templates in the directory {0}".format(
|
||||
self.log.info("Processing templates in the directory {0}".format(
|
||||
os.path.abspath(tht_root)))
|
||||
|
||||
self.log.debug("Creating Environment files")
|
||||
@ -1057,6 +1060,8 @@ class DeployOvercloud(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)
|
||||
deploy_status = 'DEPLOY_SUCCESS'
|
||||
deploy_message = 'without error'
|
||||
@ -1089,7 +1094,7 @@ class DeployOvercloud(command.Command):
|
||||
self.log.info("Stack found, will be doing a stack update")
|
||||
|
||||
if parsed_args.dry_run:
|
||||
print("Validation Finished")
|
||||
self.log.info("Validation Finished")
|
||||
return
|
||||
|
||||
start = time.time()
|
||||
@ -1121,7 +1126,7 @@ class DeployOvercloud(command.Command):
|
||||
stack=stack.stack_name)
|
||||
|
||||
if parsed_args.config_download:
|
||||
print("Deploying overcloud configuration")
|
||||
self.log.info("Deploying overcloud configuration")
|
||||
deployment.set_deployment_status(
|
||||
clients=self.clients,
|
||||
plan=stack.stack_name,
|
||||
@ -1198,8 +1203,7 @@ class DeployOvercloud(command.Command):
|
||||
utils.create_tempest_deployer_input()
|
||||
|
||||
print("Overcloud Endpoint: {0}".format(overcloud_endpoint))
|
||||
print("Overcloud Horizon Dashboard URL: {0}".format(
|
||||
horizon_url))
|
||||
print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url))
|
||||
print("Overcloud rc file: {0}".format(rcpath))
|
||||
print("Overcloud Deployed {0}".format(deploy_message))
|
||||
|
||||
@ -1230,7 +1234,7 @@ class GetDeploymentStatus(command.Command):
|
||||
)
|
||||
|
||||
if not status:
|
||||
print('No deployment was found for %s' % plan)
|
||||
self.log.info('No deployment was found for %s' % plan)
|
||||
return
|
||||
|
||||
table = PrettyTable(
|
||||
|
@ -14,7 +14,6 @@
|
||||
#
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
@ -24,6 +23,9 @@ import six
|
||||
|
||||
from osc_lib.i18n import _
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from tripleo_common.exception import NotFound
|
||||
from tripleo_common.image.builder import buildah
|
||||
|
||||
@ -32,6 +34,8 @@ from tripleoclient import constants
|
||||
from tripleoclient import utils
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
DEFAULT_AUTHFILE = "{}/containers/auth.json".format(
|
||||
os.environ.get("XDG_RUNTIME_DIR", os.path.expanduser("~"))
|
||||
)
|
||||
@ -44,8 +48,9 @@ SUPPORTED_RHEL_MODULES = ['container-tools', 'mariadb', 'redis', 'virt']
|
||||
class Build(command.Command):
|
||||
"""Build tripleo container images with tripleo-ansible."""
|
||||
|
||||
auth_required = False
|
||||
log = logging.getLogger(__name__ + ".Build")
|
||||
|
||||
auth_required = False
|
||||
identified_images = list()
|
||||
image_parents = collections.OrderedDict()
|
||||
image_paths = dict()
|
||||
@ -389,6 +394,8 @@ class Build(command.Command):
|
||||
return image_configs
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
logging.register_options(CONF)
|
||||
logging.setup(CONF, '')
|
||||
self.config_file = os.path.expanduser(parsed_args.config_file)
|
||||
self.config_path = os.path.expanduser(parsed_args.config_path)
|
||||
authfile = os.path.expanduser(parsed_args.authfile)
|
||||
@ -656,6 +663,8 @@ class Build(command.Command):
|
||||
class HotFix(command.Command):
|
||||
"""Hotfix tripleo container images with tripleo-ansible."""
|
||||
|
||||
log = logging.getLogger(__name__ + ".HotFix")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(HotFix, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
@ -688,6 +697,8 @@ class HotFix(command.Command):
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
logging.register_options(CONF)
|
||||
logging.setup(CONF, '')
|
||||
with utils.TempDirs() as tmp:
|
||||
tasks = list()
|
||||
for image in parsed_args.images:
|
||||
@ -722,6 +733,7 @@ class HotFix(command.Command):
|
||||
[playdata], f, default_flow_style=False, width=4096
|
||||
)
|
||||
|
||||
self.log.debug("Running ansible playbook {}".format(playbook))
|
||||
utils.run_ansible_playbook(
|
||||
playbook=playbook,
|
||||
inventory="localhost",
|
||||
|
Loading…
Reference in New Issue
Block a user