Repository: ansible/ansible

Issue:
nxos_facts issue
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and devel branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug Report

##### COMPONENT NAME
<!---
Name of the module, plugin, task or feature
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path
-->
nxos_facts
##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.5.0 (devel 788010d0f0) last updated 2018/01/08 11:49:21 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /root/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
```

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
Ansible Server : Ubuntu 14.04
Device: N9K running 7.0(3)I7(2)

##### SUMMARY
<!--- Explain the problem briefly -->

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->
The output of "show ipv6 interface | json" has changed in the latest version n9k software and this is causing parse_ipv6_interfaces method to fail.
<!--- Paste example playbooks or commands between quotes below -->
```yaml

```
old output:
```
{                                                                      
    "TABLE_vrf": {                                                     
        "ROW_vrf": {                                                   
            "vrf-name-out": "default"                                  
        }                                                              
    },                                                                 
    "TABLE_intf": {                                                    
        "ROW_intf": {                                                  
            "intf-name": "Ethernet1/2",                                
            "proto-state": "down",                                     
            "link-state": "down",                                      
            "admin-state": "up",                                       
            "addr": "fd56:31f7:e4ad:5585::1/64",                       
            "prefix": "fd56:31f7:e4ad:5585::/64",                      
            "linklocal-addr": "fe80::250:56ff:fe9f:6321",              
            "linklocal-configured": "FALSE",                           
            "mrouting-enabled": "disabled",                            
            "mgroup-locally-joined": "TRUE",
```
new output:
```
"TABLE_intf": {                                         
        "ROW_intf": {                                       
            "vrf-name-out": "default",
            "intf-name": "Ethernet1/2",
            "proto-state": "down",
            "link-state": "down",
            "admin-state": "down",
            "TABLE_addr": {
                "ROW_addr": {
                    "addr": "fd56:31f7:e4ad:5585::1/64"
                }
            },
```

nxos_facts issue
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and devel branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug Report

##### COMPONENT NAME
<!---
Name of the module, plugin, task or feature
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path
-->
nxos_facts
##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.5.0 (devel 788010d0f0) last updated 2018/01/08 11:49:21 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /root/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
```

##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
Ansible Server : Ubuntu 14.04
Device: N9K running 7.0(3)I7(2)

##### SUMMARY
<!--- Explain the problem briefly -->

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->
The output of "show ipv6 interface | json" has changed in the latest version n9k software and this is causing parse_ipv6_interfaces method to fail.
<!--- Paste example playbooks or commands between quotes below -->
```yaml

```
old output:
```
{                                                                      
    "TABLE_vrf": {                                                     
        "ROW_vrf": {                                                   
            "vrf-name-out": "default"                                  
        }                                                              
    },                                                                 
    "TABLE_intf": {                                                    
        "ROW_intf": {                                                  
            "intf-name": "Ethernet1/2",                                
            "proto-state": "down",                                     
            "link-state": "down",                                      
            "admin-state": "up",                                       
            "addr": "fd56:31f7:e4ad:5585::1/64",                       
            "prefix": "fd56:31f7:e4ad:5585::/64",                      
            "linklocal-addr": "fe80::250:56ff:fe9f:6321",              
            "linklocal-configured": "FALSE",                           
            "mrouting-enabled": "disabled",                            
            "mgroup-locally-joined": "TRUE",
```
new output:
```
"TABLE_intf": {                                         
        "ROW_intf": {                                       
            "vrf-name-out": "default",
            "intf-name": "Ethernet1/2",
            "proto-state": "down",
            "link-state": "down",
            "admin-state": "down",
            "TABLE_addr": {
                "ROW_addr": {
                    "addr": "fd56:31f7:e4ad:5585::1/64"
                }
            },
```



Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py
--- a/lib/ansible/modules/network/nxos/nxos_facts.py
+++ b/lib/ansible/modules/network/nxos/nxos_facts.py
@@ -409,7 +409,11 @@ def parse_ipv6_interfaces(self, data):
                     name = item['ROW_intf']['intf-name']
                     intf = self.facts['interfaces'][name]
                     intf['ipv6'] = self.transform_dict(item, self.INTERFACE_IPV6_MAP)
-                    self.facts['all_ipv6_addresses'].append(item['ROW_intf']['addr'])
+                    try:
+                        addr = item['ROW_intf']['addr']
+                    except KeyError:
+                        addr = item['ROW_intf']['TABLE_addr']['ROW_addr']['addr']
+                    self.facts['all_ipv6_addresses'].append(addr)
             else:
                 return ""
         except TypeError:


Test patch:
diff --git a/test/integration/targets/nxos_acl/tests/common/sanity.yaml b/test/integration/targets/nxos_acl/tests/common/sanity.yaml
--- a/test/integration/targets/nxos_acl/tests/common/sanity.yaml
+++ b/test/integration/targets/nxos_acl/tests/common/sanity.yaml
@@ -4,7 +4,7 @@
   when: ansible_connection == "local"
 
 - set_fact: time_range="ans-range"
-  when: not ( platform is match("N5K"))
+  when: not (platform is match("N5K")) and not (platform is match("N35"))
 
 - name: "Setup: Cleanup possibly existing acl."
   nxos_acl: &remove
diff --git a/test/integration/targets/nxos_command/tests/cli/sanity.yaml b/test/integration/targets/nxos_command/tests/cli/sanity.yaml
--- a/test/integration/targets/nxos_command/tests/cli/sanity.yaml
+++ b/test/integration/targets/nxos_command/tests/cli/sanity.yaml
@@ -21,7 +21,6 @@
   - assert: &fail
       that:
         - "result.failed == true"
-        - "'Invalid command' in result.msg"
 
   - name: "Enable feature BGP"
     nxos_feature:
diff --git a/test/integration/targets/nxos_command/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_command/tests/nxapi/sanity.yaml
--- a/test/integration/targets/nxos_command/tests/nxapi/sanity.yaml
+++ b/test/integration/targets/nxos_command/tests/nxapi/sanity.yaml
@@ -21,7 +21,6 @@
   - assert: &fail
       that:
         - "result.failed == true"
-        - "'Input CLI command error' in result.msg"
 
   - name: "Enable feature BGP"
     nxos_feature: