From e98e98757dacf320698be966dd8e793db21f0d9c Mon Sep 17 00:00:00 2001 From: Nabeel AlSaber <21160931+nalsaber@users.noreply.github.com> Date: Tue, 14 May 2019 10:12:23 -0700 Subject: [PATCH] Initial commit for Oracle Cloud Infrastructure modules --- .../module_utils/oracle/oci_logging.yaml | 59 ------------------- lib/ansible/module_utils/oracle/oci_utils.py | 33 ++--------- lib/ansible/modules/cloud/oracle/oci_vcn.py | 3 - lib/ansible/plugins/doc_fragments/oracle.py | 4 ++ .../oracle_creatable_resource.py | 3 - .../oracle_display_name_option.py | 3 - .../doc_fragments/oracle_name_option.py | 3 - .../plugins/doc_fragments/oracle_tags.py | 3 - .../doc_fragments/oracle_wait_options.py | 3 - 9 files changed, 10 insertions(+), 104 deletions(-) delete mode 100644 lib/ansible/module_utils/oracle/oci_logging.yaml diff --git a/lib/ansible/module_utils/oracle/oci_logging.yaml b/lib/ansible/module_utils/oracle/oci_logging.yaml deleted file mode 100644 index 587cec0e15c..00000000000 --- a/lib/ansible/module_utils/oracle/oci_logging.yaml +++ /dev/null @@ -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] -... diff --git a/lib/ansible/module_utils/oracle/oci_utils.py b/lib/ansible/module_utils/oracle/oci_utils.py index 9a8e070cb36..368337a4968 100644 --- a/lib/ansible/module_utils/oracle/oci_utils.py +++ b/lib/ansible/module_utils/oracle/oci_utils.py @@ -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 diff --git a/lib/ansible/modules/cloud/oracle/oci_vcn.py b/lib/ansible/modules/cloud/oracle/oci_vcn.py index 07a62f47377..d9545ba9a16 100644 --- a/lib/ansible/modules/cloud/oracle/oci_vcn.py +++ b/lib/ansible/modules/cloud/oracle/oci_vcn.py @@ -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 diff --git a/lib/ansible/plugins/doc_fragments/oracle.py b/lib/ansible/plugins/doc_fragments/oracle.py index 0c1075e55f2..f894cae3ed8 100644 --- a/lib/ansible/plugins/doc_fragments/oracle.py +++ b/lib/ansible/plugins/doc_fragments/oracle.py @@ -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: diff --git a/lib/ansible/plugins/doc_fragments/oracle_creatable_resource.py b/lib/ansible/plugins/doc_fragments/oracle_creatable_resource.py index 7f61ca4f432..db7fe378ed9 100644 --- a/lib/ansible/plugins/doc_fragments/oracle_creatable_resource.py +++ b/lib/ansible/plugins/doc_fragments/oracle_creatable_resource.py @@ -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): diff --git a/lib/ansible/plugins/doc_fragments/oracle_display_name_option.py b/lib/ansible/plugins/doc_fragments/oracle_display_name_option.py index fd1eb7f2508..029221c566d 100644 --- a/lib/ansible/plugins/doc_fragments/oracle_display_name_option.py +++ b/lib/ansible/plugins/doc_fragments/oracle_display_name_option.py @@ -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): diff --git a/lib/ansible/plugins/doc_fragments/oracle_name_option.py b/lib/ansible/plugins/doc_fragments/oracle_name_option.py index 26d5f4f1605..302ba12ce16 100644 --- a/lib/ansible/plugins/doc_fragments/oracle_name_option.py +++ b/lib/ansible/plugins/doc_fragments/oracle_name_option.py @@ -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): diff --git a/lib/ansible/plugins/doc_fragments/oracle_tags.py b/lib/ansible/plugins/doc_fragments/oracle_tags.py index 0d7b016e760..d85ed60b280 100644 --- a/lib/ansible/plugins/doc_fragments/oracle_tags.py +++ b/lib/ansible/plugins/doc_fragments/oracle_tags.py @@ -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): diff --git a/lib/ansible/plugins/doc_fragments/oracle_wait_options.py b/lib/ansible/plugins/doc_fragments/oracle_wait_options.py index 98693d9779f..394a7cd5309 100644 --- a/lib/ansible/plugins/doc_fragments/oracle_wait_options.py +++ b/lib/ansible/plugins/doc_fragments/oracle_wait_options.py @@ -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):