nxos_gir timeout fixes (#66043)

* nxos_gir timeout fixes

* additional setup/teardown cleanups for sanity test

* Add timeout extension comment to module header

* lint

* rework logic to use action plugin
pull/66619/head
Chris Van Heuveln 5 years ago committed by Nilashish Chakraborty
parent 986be77337
commit 7fabb28d22

@ -29,6 +29,7 @@ version_added: "2.2"
short_description: Trigger a graceful removal or insertion (GIR) of the switch. short_description: Trigger a graceful removal or insertion (GIR) of the switch.
description: description:
- Trigger a graceful removal or insertion (GIR) of the switch. - Trigger a graceful removal or insertion (GIR) of the switch.
- GIR processing may take more than 2 minutes. Timeout settings are automatically extended to 200s when user timeout settings are insufficient.
author: author:
- Gabriele Gerbino (@GGabriele) - Gabriele Gerbino (@GGabriele)
notes: notes:

@ -25,6 +25,7 @@ import sys
from ansible import constants as C from ansible import constants as C
from ansible.plugins.action.network import ActionModule as ActionNetworkModule from ansible.plugins.action.network import ActionModule as ActionNetworkModule
from ansible.module_utils.connection import Connection
from ansible.module_utils.network.common.utils import load_provider from ansible.module_utils.network.common.utils import load_provider
from ansible.module_utils.network.nxos.nxos import nxos_provider_spec from ansible.module_utils.network.nxos.nxos import nxos_provider_spec
from ansible.utils.display import Display from ansible.utils.display import Display
@ -81,6 +82,15 @@ class ActionModule(ActionNetworkModule):
display.warning('transport is unnecessary when using %s and will be ignored' % self._play_context.connection) display.warning('transport is unnecessary when using %s and will be ignored' % self._play_context.connection)
del self._task.args['transport'] del self._task.args['transport']
if module_name == 'nxos_gir':
conn = Connection(self._connection.socket_path)
persistent_command_timeout = conn.get_option('persistent_command_timeout')
gir_timeout = 200
if persistent_command_timeout < gir_timeout:
conn.set_option('persistent_command_timeout', gir_timeout)
msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
display.warning(msg)
elif self._play_context.connection == 'local': elif self._play_context.connection == 'local':
provider = load_provider(nxos_provider_spec, self._task.args) provider = load_provider(nxos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli' transport = provider['transport'] or 'cli'

@ -1,13 +1,20 @@
--- ---
- debug: msg="START connection={{ ansible_connection }} nxos_gir sanity test" - debug: msg="START connection={{ ansible_connection }} nxos_gir sanity test"
- set_fact: gir_run='{{ true if (platform is not search("N35")) else false }}'
- set_fact: gir_run="true"
- set_fact: gir_run="false" - name: Setup0
when: platform is search("N35") nxos_config: &cleanup0
#- name: "Setup" lines:
# nxos_gir: &setup - no system mode maintenance timeout 30
# system_mode_maintenance: false - no configure maintenance profile normal-mode
# ignore_errors: yes - no configure maintenance profile maintenance-mode
match: none
ignore_errors: yes
- name: Setup1
nxos_gir:
system_mode_maintenance: false
ignore_errors: yes
- block: - block:
- name: "Put system in maintenance mode with reload reset reason" - name: "Put system in maintenance mode with reload reset reason"
@ -68,12 +75,12 @@
- assert: *false - assert: *false
# - name: "Put system in maintenance mode" - name: "Put system in maintenance mode"
# nxos_gir: &configure_system_mode_maintenance nxos_gir: &configure_system_mode_maintenance
# system_mode_maintenance: true system_mode_maintenance: true
# register: result register: result
#
# - assert: *true - assert: *true
when: gir_run when: gir_run
@ -88,21 +95,18 @@
action: delete_all action: delete_all
ignore_errors: yes ignore_errors: yes
- name: "Remove other config1" - name: Teardown0
nxos_config: nxos_config: *cleanup0
lines: no configure maintenance profile normal-mode
match: none
ignore_errors: yes ignore_errors: yes
- name: "Remove other config2" - name: "Put system back in normal mode"
nxos_config: nxos_gir:
lines: no configure maintenance profile maintenance-mode system_mode_maintenance: false
match: none # Try again if cli is blocking while changing modes
retries: 3
delay: 30
register: result
until: result is not failed
ignore_errors: yes ignore_errors: yes
# - name: "Put system back in normal mode"
# nxos_gir: *setup
# register: result
# ignore_errors: yes
- debug: msg="END connection={{ ansible_connection }} nxos_gir sanity test" - debug: msg="END connection={{ ansible_connection }} nxos_gir sanity test"

Loading…
Cancel
Save