Skip to content

Commit 361d124

Browse files
samiiblhercot
authored andcommitted
[ignore] Reword to snapshot_choice instead of epoch_choice for anomaly reporting.
1 parent fce8101 commit 361d124

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

plugins/modules/nd_pcv_delta_analysis.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@
4040
type: str
4141
required: true
4242
aliases: [ site, site_name, fabric_name ]
43-
epoch_choice:
43+
snapshot_choice:
4444
description:
45-
- Choice of which Epoch to report when querying for anomalies.
46-
- Use epoch2 to choose anomalies present only in epoch2.
47-
- Use epoch1 to choose anomalies present only in epoch1.
48-
- Use both_epoch to choose anomalies common for both epoch1 and epoch2.
45+
- Choice of which Snapshot/Epoch to report when querying for anomalies.
46+
- Use later_snapshot/epoch2 to choose anomalies present only in the later_snapshot or epoch2.
47+
- Use earlier_snapshot/epoch1 to choose anomalies present only in the erlier_snapshot or epoch1.
48+
- Use both_snapshots/both_epoch to choose anomalies common for both epoch1 and epoch2.
4949
type: str
50-
default: epoch2
51-
choices: [ epoch2, epoch1, both_epoch, all ]
50+
default: later_snapshot
51+
aliases: [ epoch_choice ]
52+
choices: [ later_snapshot, earlier_snapshot, both_snapshots, epoch2, epoch1, both_epoch, all ]
5253
exclude_ack_anomalies:
5354
description:
54-
- Option to exclude anomalies which is acknowledged
55+
- Option to exclude acknowledged anomalies.
5556
type: bool
5657
default: false
5758
job_wait_delay:
@@ -100,7 +101,7 @@
100101
name: exampleName
101102
state: validate
102103
exclude_ack_anomalies: true
103-
epoch_choice: epoch2
104+
snapshot_choice: later_snapshot
104105
job_wait_delay: 2
105106
job_wait_timeout: 600
106107
register: pcv_result
@@ -123,7 +124,10 @@
123124
from ansible_collections.cisco.nd.plugins.module_utils.nd import NDModule, nd_argument_spec
124125
from ansible_collections.cisco.nd.plugins.module_utils.ndi import NDI
125126

126-
epoch_map = {
127+
snapshot_choice_map = {
128+
"later_snapshot": "EPOCH2_ONLY",
129+
"earlier_snapshot": "EPOCH1_ONLY",
130+
"both_snapshots": "BOTH_EPOCHS",
127131
"epoch2": "EPOCH2_ONLY",
128132
"epoch1": "EPOCH1_ONLY",
129133
"both_epoch": "BOTH_EPOCHS",
@@ -139,7 +143,7 @@ def main():
139143
fabric=dict(type="str", required=True, aliases=["site", "site_name", "fabric_name"]),
140144
state=dict(type="str", default="query", choices=["query", "validate"]),
141145
exclude_ack_anomalies=dict(type="bool", default=False),
142-
epoch_choice=dict(type="str", default="epoch2", choices=["epoch2", "epoch1", "both_epoch", "all"]),
146+
snapshot_choice=dict(type="str", default="later_snapshot", choices=list(snapshot_choice_map), aliases=["epoch_choice"]),
143147
job_wait_delay=dict(type="int", default=1, aliases=["wait_delay"]),
144148
job_wait_timeout=dict(type="int", aliases=["wait_timeout"]),
145149
)
@@ -155,7 +159,7 @@ def main():
155159
name = nd.params.get("name")
156160
fabric = nd.params.get("fabric")
157161
insights_group = nd.params.get("insights_group")
158-
epoch_choice = nd.params.get("epoch_choice")
162+
snapshot_choice = nd.params.get("snapshot_choice")
159163
state = nd.params.get("state")
160164
exclude_ack_anomalies = nd.params.get("exclude_ack_anomalies")
161165
wait_delay = nd.params.get("job_wait_delay")
@@ -173,7 +177,7 @@ def main():
173177
nd.fail_json(msg="Pre-change Analysis {0} is not completed".format(name))
174178
epoch_delta_job_id = pcv_result.get("epochDeltaJobId")
175179
nd.existing["anomaly_count"] = ndi.query_event_severity(insights_group, fabric, epoch_delta_job_id)
176-
anomalies = ndi.query_anomalies(insights_group, fabric, epoch_delta_job_id, epoch_map[epoch_choice], exclude_ack_anomalies)
180+
anomalies = ndi.query_anomalies(insights_group, fabric, epoch_delta_job_id, snapshot_choice_map[snapshot_choice], exclude_ack_anomalies)
177181
nd.existing["anomalies"] = anomalies
178182
if state == "validate" and anomalies:
179183
anomalies_count = {"minor": 0, "major": 0, "critical": 0, "warning": 0}

tests/integration/targets/nd_pcv_delta_analysis/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<<: *nd_query
5555
name: pcv_by_file
5656
state: validate
57+
snapshot_choice: both_snapshots
5758
ignore_errors: true
5859
register: validate_pcv_by_file_delta_analysis
5960

0 commit comments

Comments
 (0)