Initial commit for Oracle Cloud Infrastructure modules
This commit is contained in:
parent
ec2db1aed7
commit
e98e98757d
9 changed files with 10 additions and 104 deletions
|
@ -1,59 +0,0 @@
|
|||
---
|
||||
# Copyright (c) 2017, 2018 Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
version: 1
|
||||
disable_existing_loggers: False
|
||||
formatters:
|
||||
simple:
|
||||
format: "[%(asctime)s - %(name)s - %(lineno)s - %(funcName)s - %(levelname)s] - %(message)s"
|
||||
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
level: DEBUG
|
||||
formatter: simple
|
||||
stream: ext://sys.stdout
|
||||
|
||||
info_file_handler:
|
||||
class: logging.handlers.RotatingFileHandler
|
||||
level: INFO
|
||||
formatter: simple
|
||||
filename: "{path}/oci_ansible_info_{date}.log"
|
||||
maxBytes: 10485760 # 10MB
|
||||
backupCount: 20
|
||||
encoding: utf8
|
||||
mode: "a"
|
||||
|
||||
error_file_handler:
|
||||
class: logging.handlers.RotatingFileHandler
|
||||
level: ERROR
|
||||
formatter: simple
|
||||
filename: "{path}/oci_ansible_errors_{date}.log"
|
||||
maxBytes: 10485760 # 10MB
|
||||
backupCount: 20
|
||||
encoding: utf8
|
||||
mode: "a"
|
||||
|
||||
debug_file_handler:
|
||||
class: logging.handlers.RotatingFileHandler
|
||||
level: DEBUG
|
||||
formatter: simple
|
||||
filename: "{path}/oci_ansible_debug_{date}.log"
|
||||
maxBytes: 10485760 # 10MB
|
||||
backupCount: 20
|
||||
encoding: utf8
|
||||
mode: "a"
|
||||
|
||||
#loggers:
|
||||
#any_specific_module e.g. oci_bucket:
|
||||
#level: INFO
|
||||
#handlers: [info_file_handler]
|
||||
#propagate: no
|
||||
|
||||
root:
|
||||
level: DEBUG
|
||||
handlers: [info_file_handler, debug_file_handler, error_file_handler]
|
||||
...
|
|
@ -1,8 +1,6 @@
|
|||
# Copyright (c) 2017, 2018, 2019 Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
@ -413,37 +411,18 @@ def get_logger(module_name):
|
|||
|
||||
|
||||
def setup_logging(
|
||||
default_config_file="/etc/ansible/oci_logging.yaml",
|
||||
default_level="INFO",
|
||||
default_log_path=tempfile.gettempdir(),
|
||||
):
|
||||
"""Setup logging configuration"""
|
||||
env_config_file = "LOG_CONFIG"
|
||||
env_log_path = "LOG_PATH"
|
||||
env_log_level = "LOG_LEVEL"
|
||||
|
||||
config_file = os.getenv(env_config_file, default_config_file)
|
||||
default_log_path = tempfile.gettempdir()
|
||||
log_path = os.getenv(env_log_path, default_log_path)
|
||||
|
||||
files_handlers = ["debug_file_handler", "error_file_handler", "info_file_handler"]
|
||||
|
||||
if os.path.exists(config_file):
|
||||
with open(to_bytes(config_file), "rt") as f:
|
||||
config = yaml.safe_load(f.read())
|
||||
for files_handler in files_handlers:
|
||||
config["handlers"][files_handler]["filename"] = config["handlers"][
|
||||
files_handler
|
||||
]["filename"].format(
|
||||
path=log_path, date=datetime.today().strftime("%d-%m-%Y")
|
||||
)
|
||||
logging.config.dictConfig(config)
|
||||
else:
|
||||
log_level_str = os.getenv(env_log_level, default_level)
|
||||
log_level = logging.getLevelName(log_level_str)
|
||||
|
||||
log_file_path = os.path.join(tempfile.gettempdir(), "oci_ansible_module.log")
|
||||
|
||||
logging.basicConfig(filename=log_file_path, filemode="a", level=log_level)
|
||||
log_level_str = os.getenv(env_log_level, default_level)
|
||||
log_level = logging.getLevelName(log_level_str)
|
||||
log_file_path = os.path.join(log_path, "oci_ansible_module.log")
|
||||
logging.basicConfig(filename=log_file_path, filemode="a", level=log_level)
|
||||
return logging
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# Copyright (c) 2017, 2018, Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
||||
class ModuleDocFragment(object):
|
||||
DOCUMENTATION = """
|
||||
requirements:
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
# Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
|
||||
class ModuleDocFragment(object):
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
# Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
|
||||
class ModuleDocFragment(object):
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
# Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
|
||||
class ModuleDocFragment(object):
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
# Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
|
||||
class ModuleDocFragment(object):
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
# Copyright (c) 2018, Oracle and/or its affiliates.
|
||||
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Apache License v2.0
|
||||
# See LICENSE.TXT for details.
|
||||
|
||||
|
||||
class ModuleDocFragment(object):
|
||||
|
|
Loading…
Reference in a new issue