summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Wiebe <mwiebe@cisco.com>2020-01-22 06:19:12 +0100
committerNilashish Chakraborty <nilashishchakraborty8@gmail.com>2020-01-22 06:19:12 +0100
commit5c158755fc4f5946e79ed82e1057580c85a41f0b (patch)
treeddbbaca80d4ecc82e38cd03885cbfeef171fd764
parentAdd `--venv-system-site-packages` to ansible-test. (diff)
downloadansible-5c158755fc4f5946e79ed82e1057580c85a41f0b.tar.xz
ansible-5c158755fc4f5946e79ed82e1057580c85a41f0b.zip
Fix fact gathering for sensor-groups (#66439)
-rw-r--r--lib/ansible/module_utils/network/nxos/cmdref/telemetry/telemetry.py2
-rw-r--r--test/integration/targets/nxos_telemetry/tests/common/deleted.yaml4
-rw-r--r--test/integration/targets/nxos_telemetry/tests/common/merged.yaml12
-rw-r--r--test/integration/targets/nxos_telemetry/tests/common/replaced.yaml8
-rw-r--r--test/units/modules/network/nxos/fixtures/nxos_telemetry/N9K_SGs.cfg19
-rw-r--r--test/units/modules/network/nxos/test_nxos_telemetry.py21
6 files changed, 53 insertions, 13 deletions
diff --git a/lib/ansible/module_utils/network/nxos/cmdref/telemetry/telemetry.py b/lib/ansible/module_utils/network/nxos/cmdref/telemetry/telemetry.py
index 10e44f4e4c..39f3604518 100644
--- a/lib/ansible/module_utils/network/nxos/cmdref/telemetry/telemetry.py
+++ b/lib/ansible/module_utils/network/nxos/cmdref/telemetry/telemetry.py
@@ -104,7 +104,7 @@ path:
_exclude: ['N3K', 'N5K', 'N6k', 'N7k']
multiple: true
kind: dict
- getval: path (?P<name>\\S+)( depth (?P<depth>\\S+))?( query-condition (?P<query_condition>\\S+))?( filter-condition (?P<filter_condition>\\S+))?$
+ getval: path (?P<name>(\\S+|".*"))( depth (?P<depth>\\S+))?( query-condition (?P<query_condition>\\S+))?( filter-condition (?P<filter_condition>\\S+))?$
setval: path {name} depth {depth} query-condition {query_condition} filter-condition {filter_condition}
default:
name: ~
diff --git a/test/integration/targets/nxos_telemetry/tests/common/deleted.yaml b/test/integration/targets/nxos_telemetry/tests/common/deleted.yaml
index b8a70d547c..6e6875f644 100644
--- a/test/integration/targets/nxos_telemetry/tests/common/deleted.yaml
+++ b/test/integration/targets/nxos_telemetry/tests/common/deleted.yaml
@@ -35,8 +35,8 @@
- { id: 10, destination: {ip: 192.168.0.1, port: 50001, protocol: Grpc, encoding: gPB}}
- { id: 10, destination: {ip: 192.168.0.2, port: 60001, protocol: gRPC, encoding: gpb}}
sensor_groups:
- - { id: 8, data_source: NX-API, path: {name: sys/bgp, depth: 0, query_condition: foo, filter_condition: foo}}
- - { id: 2, data_source: NX-API, path: {name: sys/bgp/inst, depth: unbounded, query_condition: foo, filter_condition: foo}}
+ - { id: 8, data_source: NX-API, path: {name: '"show bgp l2vpn evpn summary"', depth: 0, query_condition: foo, filter_condition: foo}}
+ - { id: 2, data_source: NX-API, path: {name: '"show ip bgp neighbors"', depth: unbounded, query_condition: foo, filter_condition: foo}}
- { id: 55, data_source: DME, path: {name: 'sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]', depth: 0, query_condition: foo, filter_condition: foo}}
- { id: 55, data_source: DME, path: {name: sys/ospf, depth: 0, query_condition: foo, filter_condition: 'or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up"))'}}
subscriptions:
diff --git a/test/integration/targets/nxos_telemetry/tests/common/merged.yaml b/test/integration/targets/nxos_telemetry/tests/common/merged.yaml
index 39ed3a8ca2..6b280e3fa3 100644
--- a/test/integration/targets/nxos_telemetry/tests/common/merged.yaml
+++ b/test/integration/targets/nxos_telemetry/tests/common/merged.yaml
@@ -44,8 +44,8 @@
- { id: 10, destination: {ip: 192.168.0.1, port: 50001, protocol: Grpc, encoding: gPB}}
- { id: 10, destination: {ip: 192.168.0.2, port: 60001, protocol: gRPC, encoding: gpb}}
sensor_groups:
- - { id: 8, data_source: NX-API, path: {name: sys/bgp, depth: 0, query_condition: foo, filter_condition: foo}}
- - { id: 2, data_source: NX-API, path: {name: sys/bgp/inst, depth: unbounded, query_condition: foo, filter_condition: foo}}
+ - { id: 8, data_source: NX-API, path: {name: '"show bgp l2vpn evpn summary"', depth: 0, query_condition: foo, filter_condition: foo}}
+ - { id: 2, data_source: NX-API, path: {name: '"show ip bgp neighbors"', depth: unbounded, query_condition: foo, filter_condition: foo}}
- { id: 55, data_source: DME, path: {name: 'sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]', depth: 0, query_condition: foo, filter_condition: foo}}
- { id: 55, data_source: DME, path: {name: sys/ospf, depth: 0, query_condition: foo, filter_condition: 'or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up"))'}}
subscriptions:
@@ -72,10 +72,10 @@
- "'ip address 192.168.0.2 port 60001 protocol grpc encoding gpb' in result.commands"
- "'sensor-group 8' in result.commands"
- "'data-source NX-API' in result.commands"
- - "'path sys/bgp depth 0 query-condition foo filter-condition foo' in result.commands"
+ - result.commands is search("path .*show bgp l2vpn evpn summary.* depth 0 query-condition foo filter-condition foo")
- "'sensor-group 2' in result.commands"
- "'data-source NX-API' in result.commands"
- - "'path sys/bgp/inst depth unbounded query-condition foo filter-condition foo' in result.commands"
+ - result.commands is search("path .*show ip bgp neighbors.* depth unbounded query-condition foo filter-condition foo")
- "'sensor-group 55' in result.commands"
- "'data-source DME' in result.commands"
- "'path sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11] depth 0 query-condition foo filter-condition foo' in result.commands"
@@ -137,8 +137,8 @@
- { id: 10, destination: {ip: 192.168.0.1, port: 50001, protocol: Grpc, encoding: gPB}}
- { id: 10, destination: {ip: 192.168.0.2, port: 60001, protocol: gRPC, encoding: gpb}}
sensor_groups:
- - { id: 8, data_source: NX-API, path: {name: sys/bgp, depth: 0, query_condition: foo, filter_condition: foo}}
- - { id: 2, data_source: NX-API, path: {name: sys/bgp/inst, depth: unbounded, query_condition: foo, filter_condition: foo}}
+ - { id: 8, data_source: NX-API, path: {name: '"show bgp l2vpn evpn summary"', depth: 0, query_condition: foo, filter_condition: foo}}
+ - { id: 2, data_source: NX-API, path: {name: '"show ip bgp neighbors"', depth: unbounded, query_condition: foo, filter_condition: foo}}
- { id: 55, data_source: DME, path: {name: 'sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11]', depth: 0, query_condition: foo, filter_condition: foo}}
- { id: 55, data_source: DME, path: {name: sys/ospf, depth: 0, query_condition: foo, filter_condition: 'or(eq(ethpmPhysIf.operSt,"down"),eq(ethpmPhysIf.operSt,"up"))'}}
subscriptions:
diff --git a/test/integration/targets/nxos_telemetry/tests/common/replaced.yaml b/test/integration/targets/nxos_telemetry/tests/common/replaced.yaml
index 9305e2ecb9..6ddcaaad8d 100644
--- a/test/integration/targets/nxos_telemetry/tests/common/replaced.yaml
+++ b/test/integration/targets/nxos_telemetry/tests/common/replaced.yaml
@@ -42,10 +42,10 @@
destination-group 99
sensor-group 2
data-source NX-API
- path sys/bgp/inst depth unbounded query-condition foo filter-condition foo
+ path "show bgp l2vpn evpn summary" depth unbounded query-condition foo filter-condition foo
sensor-group 8
data-source NX-API
- path sys/bgp depth 0 query-condition foo filter-condition foo
+ path "show ip bgp neighbors" depth 0 query-condition foo filter-condition foo
sensor-group 55
data-source DME
path sys/bgp/inst/dom-default/peer-[10.10.10.11]/ent-[10.10.10.11] depth 0 query-condition foo filter-condition foo
@@ -107,7 +107,7 @@
- id: 100
data_source: NX-API
path:
- name: sys/bgp/inst
+ name: '"show bgp l2vpn evpn summary"'
depth: unbounded
query_condition: foo
filter_condition: foo
@@ -147,7 +147,7 @@
- "'ip address 192.168.0.1 port 65001 protocol grpc encoding gpb' in result.commands"
- "'ip address 192.168.0.3 port 55001 protocol grpc encoding gpb' in result.commands"
- "'sensor-group 100' in result.commands"
- - "'path sys/bgp/inst depth unbounded query-condition foo filter-condition foo' in result.commands"
+ - result.commands is search("path .*show bgp l2vpn evpn summary.* depth unbounded query-condition foo filter-condition foo")
- "'data-source NX-API' in result.commands"
- "'subscription 99' in result.commands"
- "'snsr-grp 100 sample-interval 2000' in result.commands"
diff --git a/test/units/modules/network/nxos/fixtures/nxos_telemetry/N9K_SGs.cfg b/test/units/modules/network/nxos/fixtures/nxos_telemetry/N9K_SGs.cfg
new file mode 100644
index 0000000000..1729ad813a
--- /dev/null
+++ b/test/units/modules/network/nxos/fixtures/nxos_telemetry/N9K_SGs.cfg
@@ -0,0 +1,19 @@
+feature telemetry
+
+telemetry
+ sensor-group 1
+ path sys/ch depth 4
+ path sys/procsys depth 1
+ sensor-group 2
+ data-source NX-API
+ path "show bgp l2vpn evpn summary"
+ path "show isis adjacency"
+ path "show mac address-table count" depth 2
+ path "show bgp sessions"
+ sensor-group 3
+ data-source NX-API
+ path "show interface ethernet1/1-52"
+ sensor-group 4
+ path sys/bd depth 2
+ path sys/eps/epId-1/nws depth 2
+ path sys/eps/epId-1/peers depth 2
diff --git a/test/units/modules/network/nxos/test_nxos_telemetry.py b/test/units/modules/network/nxos/test_nxos_telemetry.py
index bd630ba5aa..a752ab8615 100644
--- a/test/units/modules/network/nxos/test_nxos_telemetry.py
+++ b/test/units/modules/network/nxos/test_nxos_telemetry.py
@@ -609,6 +609,27 @@ class TestNxosTelemetryModule(TestNxosModule):
set_module_args(args, ignore_provider_arg)
self.execute_module(changed=False)
+ def test_tms_sensorgroup_quotes_merged_idempotent_n9k(self):
+ # Assumes feature telemetry is enabled
+ # TMS sensorgroup config is present with quotes in NX-API path.
+ self.execute_show_command.return_value = load_fixture('nxos_telemetry', 'N9K_SGs.cfg')
+ self.get_platform_shortname.return_value = 'N9K'
+ args = build_args([
+ {'id': '2',
+ 'data_source': 'NX-API',
+ 'path': {'name': '"show mac address-table count"', 'depth': 2},
+ },
+ {'id': '3',
+ 'data_source': 'NX-API',
+ 'path': {'name': '"show interface ethernet1/1-52"'},
+ },
+ {'id': '1',
+ 'path': {'name': 'sys/procsys', 'depth': 1},
+ },
+ ], 'sensor_groups')
+ set_module_args(args, ignore_provider_arg)
+ self.execute_module(changed=False)
+
def test_tms_sensorgroup_vxlan_idempotent_n9k(self):
# TMS sensorgroup config present.
self.execute_show_command.return_value = load_fixture('nxos_telemetry', 'N9K.cfg')