Skip to content

Commit

Permalink
Renovate logging
Browse files Browse the repository at this point in the history
Details:

- Changed the logging so that it can now reasonably be used together
  with other projects that use logging. This is done by
  centralizing the log_init() function in the utils module, and
  by changing it such that the log level is alwqys set, but the
  file handler is set only when a log file is specified. As a result,
  the loggers now propagate to the Python root logger when the
  log_file parameter is not set.

  So playbooks using the zhmc modules have two choices:
  - Specify a log file via the log_file parameter
  - Do not specify a log file and configure the Python root
    logger as needed.

- Added log_file support to all modules that did not have it yet.

- Changed the format of log messages from:
    %(asctime)s %(name)s %(message)s
    with the default date format (e.g. 2019-02-20 10:54:26,123)
  To:
    %(asctime)s %(levelname)s %(name)s %(process)d %(message)s
    with the default date format (e.g. 2019-02-20 10:54:26,123)
  to be more in sync with common log formats.

- Removed the unused log() function in the utils module because
  logging is now done directly to Python loggers.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Feb 20, 2019
1 parent 0945b0a commit d80c974
Show file tree
Hide file tree
Showing 26 changed files with 438 additions and 173 deletions.
2 changes: 1 addition & 1 deletion docs/gen/zhmc_adapter_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Options
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged.</div>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

Expand Down
2 changes: 1 addition & 1 deletion docs/gen/zhmc_cpc_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Options
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged.</div>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

Expand Down
13 changes: 7 additions & 6 deletions docs/gen/zhmc_crypto_attachment_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Options
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged.</div>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

Expand Down Expand Up @@ -207,7 +207,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

- name: Gather facts about the crypto configuration of a partition
zhmc_crypto_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -216,7 +216,7 @@ Examples
partition_name: "{{ my_partition_name }}"
state: facts
register: crypto1

- name: Ensure domain 0 on all ep11 adapters is attached in usage mode
zhmc_crypto_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -228,7 +228,7 @@ Examples
adapter_count: -1
domain_range: 0,0
access_mode: usage

- name: Ensure domains 1-max on all ep11 adapters are attached in control mode
zhmc_crypto_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -240,7 +240,7 @@ Examples
adapter_count: -1
domain_range: 1,-1
access_mode: control

- name: Ensure domains 0-max on 1 ep11 adapter are attached to in usage mode
zhmc_crypto_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -252,7 +252,8 @@ Examples
adapter_count: 1
domain_range: 0,-1
access_mode: usage



Return Values
-------------
Expand Down
15 changes: 13 additions & 2 deletions docs/gen/zhmc_hba_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ Options
</td>
</tr>

<tr>
<td>log_file<br/><div style="font-size: small;"></div></td>
<td>no</td>
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

<tr>
<td>name<br/><div style="font-size: small;"></div></td>
<td>yes</td>
Expand Down Expand Up @@ -181,7 +191,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

- name: Ensure HBA exists in the partition
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -196,7 +206,7 @@ Examples
description: "The port to our V7K #1"
device_number: "123F"
register: hba1

- name: Ensure HBA does not exist in the partition
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -206,6 +216,7 @@ Examples
name: "{{ my_hba_name }}"
state: absent


Return Values
-------------

Expand Down
15 changes: 13 additions & 2 deletions docs/gen/zhmc_nic_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ Options
</td>
</tr>

<tr>
<td>log_file<br/><div style="font-size: small;"></div></td>
<td>no</td>
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

<tr>
<td>name<br/><div style="font-size: small;"></div></td>
<td>yes</td>
Expand Down Expand Up @@ -181,7 +191,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

- name: Ensure NIC exists in the partition
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -196,7 +206,7 @@ Examples
description: "The port to our data network"
device_number: "023F"
register: nic1

- name: Ensure NIC does not exist in the partition
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -206,6 +216,7 @@ Examples
name: "{{ my_nic_name }}"
state: absent


Return Values
-------------

Expand Down
23 changes: 17 additions & 6 deletions docs/gen/zhmc_partition_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ Options
</td>
</tr>

<tr>
<td>log_file<br/><div style="font-size: small;"></div></td>
<td>no</td>
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

<tr>
<td>name<br/><div style="font-size: small;"></div></td>
<td>yes</td>
Expand Down Expand Up @@ -177,7 +187,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

# Because configuring LUN masking in the SAN requires the host WWPN, and the
# host WWPN is automatically assigned and will be known only after an HBA has
# been added to the partition, the partition needs to be created in stopped
Expand All @@ -196,7 +206,7 @@ Examples
initial_memory: 1024
maximum_memory: 1024
register: part1

# After an HBA has been added (see Ansible module zhmc_hba), and LUN masking
# has been configured in the SAN, and a bootable image is available at the
# configured LUN and target WWPN, the partition can be configured for boot
Expand All @@ -214,15 +224,15 @@ Examples
boot_logical_unit_number: 00000000001
boot_world_wide_port_name: abcdefabcdef
register: part1

- name: Ensure the partition does not exist
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
hmc_auth: "{{ my_hmc_auth }}"
cpc_name: "{{ my_cpc_name }}"
name: "{{ my_partition_name }}"
state: absent

- name: Define crypto configuration
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -241,7 +251,7 @@ Examples
- domain_index: 1
access_mode: control
register: part1

- name: Gather facts about a partition
zhmc_partition:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -250,7 +260,8 @@ Examples
name: "{{ my_partition_name }}"
state: facts
register: part1



Return Values
-------------
Expand Down
19 changes: 15 additions & 4 deletions docs/gen/zhmc_storage_group_attachment_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ Options
</td>
</tr>

<tr>
<td>log_file<br/><div style="font-size: small;"></div></td>
<td>no</td>
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

<tr>
<td>partition_name<br/><div style="font-size: small;"></div></td>
<td>yes</td>
Expand Down Expand Up @@ -166,7 +176,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

- name: Gather facts about the attachment
zhmc_storage_group_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -176,7 +186,7 @@ Examples
partition_name: "{{ my_partition_name }}"
state: facts
register: sga1

- name: Ensure the storage group is attached to the partition
zhmc_storage_group_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -185,7 +195,7 @@ Examples
storage_group_name: "{{ my_storage_group_name }}"
partition_name: "{{ my_partition_name }}"
state: attached

- name: "Ensure the storage group is not attached to the partition."
zhmc_storage_group_attachment:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -194,7 +204,8 @@ Examples
storage_group_name: "{{ my_storage_group_name }}"
partition_name: "{{ my_partition_name }}"
state: detached



Return Values
-------------
Expand Down
19 changes: 15 additions & 4 deletions docs/gen/zhmc_storage_group_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ Options
</td>
</tr>

<tr>
<td>log_file<br/><div style="font-size: small;"></div></td>
<td>no</td>
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

<tr>
<td>name<br/><div style="font-size: small;"></div></td>
<td>yes</td>
Expand Down Expand Up @@ -180,7 +190,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

- name: Gather facts about a storage group
zhmc_storage_group:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -190,15 +200,15 @@ Examples
state: facts
expand: true
register: sg1

- name: Ensure the storage group does not exist
zhmc_storage_group:
hmc_host: "{{ my_hmc_host }}"
hmc_auth: "{{ my_hmc_auth }}"
cpc_name: "{{ my_cpc_name }}"
name: "{{ my_storage_group_name }}"
state: absent

- name: Ensure the storage group exists
zhmc_storage_group:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -214,7 +224,8 @@ Examples
connectivity: 4
max-partitions: 1
register: sg1



Return Values
-------------
Expand Down
19 changes: 15 additions & 4 deletions docs/gen/zhmc_storage_volume_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ Options
</td>
</tr>

<tr>
<td>log_file<br/><div style="font-size: small;"></div></td>
<td>no</td>
<td></td>
<td></td>
<td>
<div>File path of a log file to which the logic flow of this module as well as interactions with the HMC are logged. If null, logging will be propagated to the Python root logger.</div>
</td>
</tr>

<tr>
<td>name<br/><div style="font-size: small;"></div></td>
<td>yes</td>
Expand Down Expand Up @@ -179,7 +189,7 @@ Examples
---
# Note: The following examples assume that some variables named 'my_*' are set.

- name: Gather facts about a storage volume
zhmc_storage_volume:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -189,7 +199,7 @@ Examples
name: "{{ my_storage_volume_name }}"
state: facts
register: sv1

- name: Ensure the storage volume does not exist
zhmc_storage_volume:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -198,7 +208,7 @@ Examples
storage_group_name: "{{ my_storage_group_name }}"
name: "{{ my_storage_volume_name }}"
state: absent

- name: Ensure the storage volume exists
zhmc_storage_volume:
hmc_host: "{{ my_hmc_host }}"
Expand All @@ -211,7 +221,8 @@ Examples
description: "Example storage volume 1"
size: 1
register: sv1



Return Values
-------------
Expand Down
Loading

0 comments on commit d80c974

Please sign in to comment.