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)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
# assuming heat deploy consumed a 3m out of total 451m timeout
|
# 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.cmd.take_action(parsed_args)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
[mock.call(mock.ANY, mock.ANY, 'overcloud', mock.ANY,
|
[mock.call(mock.ANY, mock.ANY, 'overcloud', mock.ANY,
|
||||||
|
@ -75,7 +75,6 @@ class Authorize(command.Command):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
logging.register_options(CONF)
|
logging.register_options(CONF)
|
||||||
logging.setup(CONF, '')
|
logging.setup(CONF, '')
|
||||||
|
|
||||||
self.log.debug("take_action({})".format(parsed_args))
|
self.log.debug("take_action({})".format(parsed_args))
|
||||||
clients = self.app.client_manager
|
clients = self.app.client_manager
|
||||||
stack = oooutils.get_stack(clients.orchestration, parsed_args.stack)
|
stack = oooutils.get_stack(clients.orchestration, parsed_args.stack)
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
from pwd import getpwuid
|
from pwd import getpwuid
|
||||||
import re
|
import re
|
||||||
@ -44,6 +45,8 @@ from tripleoclient.workflows import deployment
|
|||||||
from tripleoclient.workflows import parameters as workflow_params
|
from tripleoclient.workflows import parameters as workflow_params
|
||||||
from tripleoclient.workflows import plan_management
|
from tripleoclient.workflows import plan_management
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class DeployOvercloud(command.Command):
|
class DeployOvercloud(command.Command):
|
||||||
"""Deploy Overcloud"""
|
"""Deploy Overcloud"""
|
||||||
@ -282,7 +285,7 @@ class DeployOvercloud(command.Command):
|
|||||||
workflow_params.check_deprecated_parameters(self.clients, stack_name)
|
workflow_params.check_deprecated_parameters(self.clients, stack_name)
|
||||||
|
|
||||||
if not update_plan_only:
|
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)))
|
os.path.abspath(tht_root)))
|
||||||
deployment.deploy_and_wait(
|
deployment.deploy_and_wait(
|
||||||
log=self.log,
|
log=self.log,
|
||||||
@ -472,7 +475,7 @@ class DeployOvercloud(command.Command):
|
|||||||
self._download_missing_files_from_plan(
|
self._download_missing_files_from_plan(
|
||||||
tht_root, parsed_args.stack)
|
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)))
|
os.path.abspath(tht_root)))
|
||||||
|
|
||||||
self.log.debug("Creating Environment files")
|
self.log.debug("Creating Environment files")
|
||||||
@ -1057,6 +1060,8 @@ class DeployOvercloud(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
logging.register_options(CONF)
|
||||||
|
logging.setup(CONF, '')
|
||||||
self.log.debug("take_action(%s)" % parsed_args)
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
deploy_status = 'DEPLOY_SUCCESS'
|
deploy_status = 'DEPLOY_SUCCESS'
|
||||||
deploy_message = 'without error'
|
deploy_message = 'without error'
|
||||||
@ -1089,7 +1094,7 @@ class DeployOvercloud(command.Command):
|
|||||||
self.log.info("Stack found, will be doing a stack update")
|
self.log.info("Stack found, will be doing a stack update")
|
||||||
|
|
||||||
if parsed_args.dry_run:
|
if parsed_args.dry_run:
|
||||||
print("Validation Finished")
|
self.log.info("Validation Finished")
|
||||||
return
|
return
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
@ -1121,7 +1126,7 @@ class DeployOvercloud(command.Command):
|
|||||||
stack=stack.stack_name)
|
stack=stack.stack_name)
|
||||||
|
|
||||||
if parsed_args.config_download:
|
if parsed_args.config_download:
|
||||||
print("Deploying overcloud configuration")
|
self.log.info("Deploying overcloud configuration")
|
||||||
deployment.set_deployment_status(
|
deployment.set_deployment_status(
|
||||||
clients=self.clients,
|
clients=self.clients,
|
||||||
plan=stack.stack_name,
|
plan=stack.stack_name,
|
||||||
@ -1198,8 +1203,7 @@ class DeployOvercloud(command.Command):
|
|||||||
utils.create_tempest_deployer_input()
|
utils.create_tempest_deployer_input()
|
||||||
|
|
||||||
print("Overcloud Endpoint: {0}".format(overcloud_endpoint))
|
print("Overcloud Endpoint: {0}".format(overcloud_endpoint))
|
||||||
print("Overcloud Horizon Dashboard URL: {0}".format(
|
print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url))
|
||||||
horizon_url))
|
|
||||||
print("Overcloud rc file: {0}".format(rcpath))
|
print("Overcloud rc file: {0}".format(rcpath))
|
||||||
print("Overcloud Deployed {0}".format(deploy_message))
|
print("Overcloud Deployed {0}".format(deploy_message))
|
||||||
|
|
||||||
@ -1230,7 +1234,7 @@ class GetDeploymentStatus(command.Command):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not status:
|
if not status:
|
||||||
print('No deployment was found for %s' % plan)
|
self.log.info('No deployment was found for %s' % plan)
|
||||||
return
|
return
|
||||||
|
|
||||||
table = PrettyTable(
|
table = PrettyTable(
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
@ -24,6 +23,9 @@ import six
|
|||||||
|
|
||||||
from osc_lib.i18n import _
|
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.exception import NotFound
|
||||||
from tripleo_common.image.builder import buildah
|
from tripleo_common.image.builder import buildah
|
||||||
|
|
||||||
@ -32,6 +34,8 @@ from tripleoclient import constants
|
|||||||
from tripleoclient import utils
|
from tripleoclient import utils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
DEFAULT_AUTHFILE = "{}/containers/auth.json".format(
|
DEFAULT_AUTHFILE = "{}/containers/auth.json".format(
|
||||||
os.environ.get("XDG_RUNTIME_DIR", os.path.expanduser("~"))
|
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):
|
class Build(command.Command):
|
||||||
"""Build tripleo container images with tripleo-ansible."""
|
"""Build tripleo container images with tripleo-ansible."""
|
||||||
|
|
||||||
auth_required = False
|
|
||||||
log = logging.getLogger(__name__ + ".Build")
|
log = logging.getLogger(__name__ + ".Build")
|
||||||
|
|
||||||
|
auth_required = False
|
||||||
identified_images = list()
|
identified_images = list()
|
||||||
image_parents = collections.OrderedDict()
|
image_parents = collections.OrderedDict()
|
||||||
image_paths = dict()
|
image_paths = dict()
|
||||||
@ -389,6 +394,8 @@ class Build(command.Command):
|
|||||||
return image_configs
|
return image_configs
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
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_file = os.path.expanduser(parsed_args.config_file)
|
||||||
self.config_path = os.path.expanduser(parsed_args.config_path)
|
self.config_path = os.path.expanduser(parsed_args.config_path)
|
||||||
authfile = os.path.expanduser(parsed_args.authfile)
|
authfile = os.path.expanduser(parsed_args.authfile)
|
||||||
@ -656,6 +663,8 @@ class Build(command.Command):
|
|||||||
class HotFix(command.Command):
|
class HotFix(command.Command):
|
||||||
"""Hotfix tripleo container images with tripleo-ansible."""
|
"""Hotfix tripleo container images with tripleo-ansible."""
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__ + ".HotFix")
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(HotFix, self).get_parser(prog_name)
|
parser = super(HotFix, self).get_parser(prog_name)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -688,6 +697,8 @@ class HotFix(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
|
logging.register_options(CONF)
|
||||||
|
logging.setup(CONF, '')
|
||||||
with utils.TempDirs() as tmp:
|
with utils.TempDirs() as tmp:
|
||||||
tasks = list()
|
tasks = list()
|
||||||
for image in parsed_args.images:
|
for image in parsed_args.images:
|
||||||
@ -722,6 +733,7 @@ class HotFix(command.Command):
|
|||||||
[playdata], f, default_flow_style=False, width=4096
|
[playdata], f, default_flow_style=False, width=4096
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.log.debug("Running ansible playbook {}".format(playbook))
|
||||||
utils.run_ansible_playbook(
|
utils.run_ansible_playbook(
|
||||||
playbook=playbook,
|
playbook=playbook,
|
||||||
inventory="localhost",
|
inventory="localhost",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user