40
40
type: str
41
41
required: true
42
42
aliases: [ site, site_name, fabric_name ]
43
- epoch_choice :
43
+ snapshot_choice :
44
44
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.
49
49
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 ]
52
53
exclude_ack_anomalies:
53
54
description:
54
- - Option to exclude anomalies which is acknowledged
55
+ - Option to exclude acknowledged anomalies.
55
56
type: bool
56
57
default: false
57
58
job_wait_delay:
100
101
name: exampleName
101
102
state: validate
102
103
exclude_ack_anomalies: true
103
- epoch_choice: epoch2
104
+ snapshot_choice: later_snapshot
104
105
job_wait_delay: 2
105
106
job_wait_timeout: 600
106
107
register: pcv_result
123
124
from ansible_collections .cisco .nd .plugins .module_utils .nd import NDModule , nd_argument_spec
124
125
from ansible_collections .cisco .nd .plugins .module_utils .ndi import NDI
125
126
126
- epoch_map = {
127
+ snapshot_choice_map = {
128
+ "later_snapshot" : "EPOCH2_ONLY" ,
129
+ "earlier_snapshot" : "EPOCH1_ONLY" ,
130
+ "both_snapshots" : "BOTH_EPOCHS" ,
127
131
"epoch2" : "EPOCH2_ONLY" ,
128
132
"epoch1" : "EPOCH1_ONLY" ,
129
133
"both_epoch" : "BOTH_EPOCHS" ,
@@ -139,7 +143,7 @@ def main():
139
143
fabric = dict (type = "str" , required = True , aliases = ["site" , "site_name" , "fabric_name" ]),
140
144
state = dict (type = "str" , default = "query" , choices = ["query" , "validate" ]),
141
145
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 " ]),
143
147
job_wait_delay = dict (type = "int" , default = 1 , aliases = ["wait_delay" ]),
144
148
job_wait_timeout = dict (type = "int" , aliases = ["wait_timeout" ]),
145
149
)
@@ -155,7 +159,7 @@ def main():
155
159
name = nd .params .get ("name" )
156
160
fabric = nd .params .get ("fabric" )
157
161
insights_group = nd .params .get ("insights_group" )
158
- epoch_choice = nd .params .get ("epoch_choice " )
162
+ snapshot_choice = nd .params .get ("snapshot_choice " )
159
163
state = nd .params .get ("state" )
160
164
exclude_ack_anomalies = nd .params .get ("exclude_ack_anomalies" )
161
165
wait_delay = nd .params .get ("job_wait_delay" )
@@ -173,7 +177,7 @@ def main():
173
177
nd .fail_json (msg = "Pre-change Analysis {0} is not completed" .format (name ))
174
178
epoch_delta_job_id = pcv_result .get ("epochDeltaJobId" )
175
179
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 )
177
181
nd .existing ["anomalies" ] = anomalies
178
182
if state == "validate" and anomalies :
179
183
anomalies_count = {"minor" : 0 , "major" : 0 , "critical" : 0 , "warning" : 0 }
0 commit comments