nxos_install_os: Fix nxapi local failures (#55993)
* Fix nxapi failures * Remove logit debug calls * Remove msg_timestamps * Fix code alignment issue
This commit is contained in:
parent
1dc3fe5317
commit
7c73dd3e78
10 changed files with 115 additions and 24 deletions
|
@ -429,6 +429,12 @@ class LocalNxapi:
|
||||||
def load_config(self, commands, return_error=False, opts=None, replace=None):
|
def load_config(self, commands, return_error=False, opts=None, replace=None):
|
||||||
"""Sends the ordered set of commands to the device
|
"""Sends the ordered set of commands to the device
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if opts is None:
|
||||||
|
opts = {}
|
||||||
|
|
||||||
|
responses = []
|
||||||
|
|
||||||
if replace:
|
if replace:
|
||||||
device_info = self.get_device_info()
|
device_info = self.get_device_info()
|
||||||
if '9K' not in device_info.get('network_os_platform', ''):
|
if '9K' not in device_info.get('network_os_platform', ''):
|
||||||
|
@ -436,12 +442,30 @@ class LocalNxapi:
|
||||||
commands = 'config replace {0}'.format(replace)
|
commands = 'config replace {0}'.format(replace)
|
||||||
|
|
||||||
commands = to_list(commands)
|
commands = to_list(commands)
|
||||||
msg = self.send_request(commands, output='config', check_status=True,
|
try:
|
||||||
return_error=return_error, opts=opts)
|
resp = self.send_request(commands, output='config', check_status=True,
|
||||||
|
return_error=return_error, opts=opts)
|
||||||
|
except ValueError as exc:
|
||||||
|
code = getattr(exc, 'code', 1)
|
||||||
|
message = getattr(exc, 'err', exc)
|
||||||
|
err = to_text(message, errors='surrogate_then_replace')
|
||||||
|
if opts.get('ignore_timeout') and code:
|
||||||
|
responses.append(code)
|
||||||
|
return responses
|
||||||
|
elif code and 'no graceful-restart' in err:
|
||||||
|
if 'ISSU/HA will be affected if Graceful Restart is disabled' in err:
|
||||||
|
msg = ['']
|
||||||
|
responses.extend(msg)
|
||||||
|
return responses
|
||||||
|
else:
|
||||||
|
self._module.fail_json(msg=err)
|
||||||
|
elif code:
|
||||||
|
self._module.fail_json(msg=err)
|
||||||
|
|
||||||
if return_error:
|
if return_error:
|
||||||
return msg
|
return resp
|
||||||
else:
|
else:
|
||||||
return []
|
return responses.extend(resp)
|
||||||
|
|
||||||
def get_diff(self, candidate=None, running=None, diff_match='line', diff_ignore_lines=None, path=None, diff_replace='line'):
|
def get_diff(self, candidate=None, running=None, diff_match='line', diff_ignore_lines=None, path=None, diff_replace='line'):
|
||||||
diff = {}
|
diff = {}
|
||||||
|
|
|
@ -222,6 +222,8 @@ def parse_show_install(data):
|
||||||
ud['server_error'] = True
|
ud['server_error'] = True
|
||||||
elif data == -32603:
|
elif data == -32603:
|
||||||
ud['server_error'] = True
|
ud['server_error'] = True
|
||||||
|
elif data == 1:
|
||||||
|
ud['server_error'] = True
|
||||||
return ud
|
return ud
|
||||||
else:
|
else:
|
||||||
ud['list_data'] = data.split('\n')
|
ud['list_data'] = data.split('\n')
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
---
|
---
|
||||||
testcase: "upgrade"
|
testcase: " {{ testcase }}"
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
- prepare_nxos_tests
|
# Prepare nxos tests is not required for this test.
|
||||||
|
#- prepare_nxos_tests
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
---
|
---
|
||||||
- { include: network_cli.yaml, tags: ['cli'] }
|
# Upgrade using SSH
|
||||||
- { include: network_local.yaml, tags: ['local'] }
|
- include: network_cli.yaml
|
||||||
- { include: httpapi.yaml, tags: ['httpapi'] }
|
when: connection_type == 'network_cli'
|
||||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
- include: network_local.yaml
|
||||||
|
when: connection_type == 'cli_local'
|
||||||
|
|
||||||
|
# Upgrade using NX-API
|
||||||
|
- include: httpapi.yaml
|
||||||
|
when: connection_type == 'httpapi'
|
||||||
|
- include: nxapi.yaml
|
||||||
|
when: connection_type == 'nxapi_local'
|
||||||
|
|
|
@ -5,14 +5,20 @@
|
||||||
|
|
||||||
- include: targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml
|
- include: targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml
|
||||||
|
|
||||||
|
- name: 'Remove SSH known_hosts file before scp of image file'
|
||||||
|
nxos_command:
|
||||||
|
commands: 'run bash rm /var/home/admin/.ssh/known_hosts'
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: "Copy {{ si }} to bootflash"
|
- name: "Copy {{ si }} to bootflash"
|
||||||
nxos_file_copy:
|
nxos_file_copy:
|
||||||
file_pull: True
|
file_pull: True
|
||||||
file_pull_timeout: 1200
|
file_pull_timeout: 1200
|
||||||
remote_file: "{{image_dir}}{{ si }}"
|
remote_file: "{{image_dir}}{{ si }}"
|
||||||
remote_scp_server: 192.168.1.1
|
remote_scp_server: "{{ remote_scp_server }}"
|
||||||
remote_scp_server_user: scp_user
|
remote_scp_server_user: "{{ remote_scp_user }}"
|
||||||
remote_scp_server_password: scp_password
|
remote_scp_server_password: "{{ remote_scp_password }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
#- name: "Copy {{ si }} to bootflash"
|
#- name: "Copy {{ si }} to bootflash"
|
||||||
|
@ -33,9 +39,9 @@
|
||||||
file_pull: True
|
file_pull: True
|
||||||
file_pull_timeout: 1200
|
file_pull_timeout: 1200
|
||||||
remote_file: "{{image_dir}}{{ ki }}"
|
remote_file: "{{image_dir}}{{ ki }}"
|
||||||
remote_scp_server: 192.168.1.1
|
remote_scp_server: "{{ remote_scp_server }}"
|
||||||
remote_scp_server_user: scp_user
|
remote_scp_server_user: "{{ remote_scp_user }}"
|
||||||
remote_scp_server_password: scp_password
|
remote_scp_server_password: "{{ remote_scp_password }}"
|
||||||
when: ki is defined
|
when: ki is defined
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,20 @@
|
||||||
register: result
|
register: result
|
||||||
when: not force
|
when: not force
|
||||||
|
|
||||||
- name: "Set OS image {{ si }} boot pointers"
|
- name: "Remove old boot pointers if any"
|
||||||
nxos_config:
|
nxos_config:
|
||||||
lines:
|
lines:
|
||||||
- no boot nxos
|
- no boot nxos
|
||||||
- no boot kickstart
|
- no boot kickstart
|
||||||
- no boot system
|
- no boot system
|
||||||
|
match: line
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
when: force
|
||||||
|
|
||||||
|
- name: "Set OS image {{ si }} boot pointers"
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
- "boot nxos bootflash:{{ si }}"
|
- "boot nxos bootflash:{{ si }}"
|
||||||
- copy run start
|
- copy run start
|
||||||
match: line
|
match: line
|
||||||
|
@ -21,8 +29,10 @@
|
||||||
when: force
|
when: force
|
||||||
|
|
||||||
- name: "Boot image {{ si }} using reload"
|
- name: "Boot image {{ si }} using reload"
|
||||||
nxos_command:
|
nxos_config:
|
||||||
commands: 'terminal dont-ask ; reload'
|
lines:
|
||||||
|
- 'terminal dont-ask'
|
||||||
|
- 'reload'
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
when: force
|
when: force
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/greensboro/REL_7_0_3_I7_4/'
|
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/greensboro/REL_7_0_3_I7_4/'
|
||||||
|
|
||||||
- set_fact: checkmode='no'
|
- set_fact: checkmode='no'
|
||||||
- set_fact: issu='yes'
|
- set_fact: issu='desired'
|
||||||
- set_fact: copy_images=False
|
- set_fact: copy_images=True
|
||||||
|
|
||||||
# Set boot pointers and reload
|
# Set boot pointers and reload
|
||||||
- set_fact: force=False
|
- set_fact: force=False
|
||||||
|
|
||||||
- set_fact: delete_files=False
|
- set_fact: delete_files=True
|
||||||
- set_fact:
|
- set_fact:
|
||||||
delete_image_list:
|
delete_image_list:
|
||||||
- nxos*.bin
|
- nxos*.bin
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
|
||||||
|
- debug: msg="Using provider={{ connection.transport }}"
|
||||||
|
when: connection is defined
|
||||||
|
|
||||||
|
# Set directory pointer to software images
|
||||||
|
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/greensboro/REL_7_0_3_I7_4/'
|
||||||
|
|
||||||
|
- set_fact: checkmode='no'
|
||||||
|
- set_fact: issu='desired'
|
||||||
|
- set_fact: copy_images=True
|
||||||
|
|
||||||
|
# Set boot pointers and reload
|
||||||
|
- set_fact: force=True
|
||||||
|
|
||||||
|
- set_fact: delete_files=True
|
||||||
|
- set_fact:
|
||||||
|
delete_image_list:
|
||||||
|
- nxos*.bin
|
||||||
|
|
||||||
|
#---------------------------------------------------------#
|
||||||
|
# Remove incompatible features #
|
||||||
|
#---------------------------------------------------------#
|
||||||
|
- name: Unconfigure features that will conflict with upgrade
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- terminal dont-ask
|
||||||
|
- no feature nv overlay
|
||||||
|
- no nxapi ssl protocols
|
||||||
|
- no nxapi ssl ciphers weak
|
||||||
|
match: none
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
#---------------------------------------------------------#
|
||||||
|
# Upgrade Device #
|
||||||
|
#---------------------------------------------------------#
|
||||||
|
- set_fact: si='nxos.7.0.3.I7.4.bin'
|
||||||
|
|
||||||
|
- name: Upgrade N9k Device to Greensboro Release Image
|
||||||
|
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml
|
|
@ -8,12 +8,12 @@
|
||||||
|
|
||||||
- set_fact: checkmode='no'
|
- set_fact: checkmode='no'
|
||||||
- set_fact: issu='desired'
|
- set_fact: issu='desired'
|
||||||
- set_fact: copy_images=False
|
- set_fact: copy_images=True
|
||||||
|
|
||||||
# Set boot pointers and reload
|
# Set boot pointers and reload
|
||||||
- set_fact: force=False
|
- set_fact: force=False
|
||||||
|
|
||||||
- set_fact: delete_files=False
|
- set_fact: delete_files=True
|
||||||
- set_fact:
|
- set_fact:
|
||||||
delete_image_list:
|
delete_image_list:
|
||||||
- nxos*.bin
|
- nxos*.bin
|
||||||
|
|
Loading…
Reference in a new issue