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:
Mike Wiebe 2019-06-06 00:05:08 -04:00 committed by Trishna Guha
parent 1dc3fe5317
commit 7c73dd3e78
10 changed files with 115 additions and 24 deletions

View file

@ -429,6 +429,12 @@ class LocalNxapi:
def load_config(self, commands, return_error=False, opts=None, replace=None):
"""Sends the ordered set of commands to the device
"""
if opts is None:
opts = {}
responses = []
if replace:
device_info = self.get_device_info()
if '9K' not in device_info.get('network_os_platform', ''):
@ -436,12 +442,30 @@ class LocalNxapi:
commands = 'config replace {0}'.format(replace)
commands = to_list(commands)
msg = self.send_request(commands, output='config', check_status=True,
return_error=return_error, opts=opts)
try:
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:
return msg
return resp
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'):
diff = {}

View file

@ -222,6 +222,8 @@ def parse_show_install(data):
ud['server_error'] = True
elif data == -32603:
ud['server_error'] = True
elif data == 1:
ud['server_error'] = True
return ud
else:
ud['list_data'] = data.split('\n')

View file

@ -1,2 +1,2 @@
---
testcase: "upgrade"
testcase: " {{ testcase }}"

View file

@ -1,2 +1,3 @@
dependencies:
- prepare_nxos_tests
# Prepare nxos tests is not required for this test.
#- prepare_nxos_tests

View file

@ -1,5 +1,12 @@
---
- { include: network_cli.yaml, tags: ['cli'] }
- { include: network_local.yaml, tags: ['local'] }
- { include: httpapi.yaml, tags: ['httpapi'] }
- { include: nxapi.yaml, tags: ['nxapi'] }
# Upgrade using SSH
- include: network_cli.yaml
when: connection_type == 'network_cli'
- 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'

View file

@ -5,14 +5,20 @@
- 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"
nxos_file_copy:
file_pull: True
file_pull_timeout: 1200
remote_file: "{{image_dir}}{{ si }}"
remote_scp_server: 192.168.1.1
remote_scp_server_user: scp_user
remote_scp_server_password: scp_password
remote_scp_server: "{{ remote_scp_server }}"
remote_scp_server_user: "{{ remote_scp_user }}"
remote_scp_server_password: "{{ remote_scp_password }}"
register: result
#- name: "Copy {{ si }} to bootflash"
@ -33,9 +39,9 @@
file_pull: True
file_pull_timeout: 1200
remote_file: "{{image_dir}}{{ ki }}"
remote_scp_server: 192.168.1.1
remote_scp_server_user: scp_user
remote_scp_server_password: scp_password
remote_scp_server: "{{ remote_scp_server }}"
remote_scp_server_user: "{{ remote_scp_user }}"
remote_scp_server_password: "{{ remote_scp_password }}"
when: ki is defined
register: result

View file

@ -8,12 +8,20 @@
register: result
when: not force
- name: "Set OS image {{ si }} boot pointers"
- name: "Remove old boot pointers if any"
nxos_config:
lines:
- no boot nxos
- no boot kickstart
- 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 }}"
- copy run start
match: line
@ -21,8 +29,10 @@
when: force
- name: "Boot image {{ si }} using reload"
nxos_command:
commands: 'terminal dont-ask ; reload'
nxos_config:
lines:
- 'terminal dont-ask'
- 'reload'
provider: "{{ connection }}"
ignore_errors: yes
when: force

View file

@ -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: checkmode='no'
- set_fact: issu='yes'
- set_fact: copy_images=False
- set_fact: issu='desired'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- nxos*.bin

View file

@ -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

View file

@ -8,12 +8,12 @@
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=False
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- nxos*.bin