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.
description:
- 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:
- Gabriele Gerbino (@GGabriele)
notes:

@ -25,6 +25,7 @@ import sys
from ansible import constants as C
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.nxos.nxos import nxos_provider_spec
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)
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':
provider = load_provider(nxos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'

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

Loading…
Cancel
Save