Skip to content

Commit 709cd2f

Browse files
authored
New templates and python validation scripts
New templates and python validation scripts
1 parent 489c147 commit 709cd2f

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

show_interfaces_summary.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import devpackage.DataProvider as DeviceDataProvider
2+
import simplejson
3+
4+
dp = DeviceDataProvider.DeviceDataProvider(context)
5+
ctype = DeviceDataProvider.CollectionType
6+
7+
def main():
8+
dp.job_execution_log("Executing the show interfaces summary script")
9+
10+
# Capture script inputs
11+
#inputs = context.get("INPUTS")
12+
#parsed_json = simplejson.loads(inputs)
13+
14+
pre_result = dp.get_fields_as_dict_list("show interfaces summary", ctype.PRE, "UP")
15+
post_result = dp.get_fields_as_dict_list("show interfaces summary", ctype.POST, "UP")
16+
print(pre_result)
17+
print(post_result)
18+
19+
dp.job_execution_log("Analyzing show interfaces summary")
20+
21+
# Get pre from command results
22+
preUP = ""
23+
for x in pre_result:
24+
preUP = x.get("UP")
25+
break
26+
27+
# Get post from command results
28+
postUP = ""
29+
for x in post_result:
30+
postUP = x.get("UP")
31+
break
32+
33+
dp.job_execution_log("UP Number in command " + preUP)
34+
dp.job_execution_log("UP Number in command " + postUP)
35+
36+
# Determine post results
37+
passmsg = preUP + " less than or equal " + postUP
38+
errmsg = preUP + " grather than " + postUP
39+
if preUP <= postUP:
40+
dp.add_post_status_field("All Types", preUP, passmsg, "Passed")
41+
dp.publish_post_status(True, "Analysis Check passed")
42+
elif preUP > postUP:
43+
dp.add_post_status_field("All Types", preUP, errmsg, "Failed")
44+
dp.publish_post_status(False, "Analysis Check failed")
45+
46+
json = dp.publish_status()
47+
return json

show_interfaces_summary.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Value ALL_TYPES (ALL TYPES)
21
Value TOTAL (\S+)
32
Value UP (\S+)
43
Value DOWN (\S+)

show_redundancy.template

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Value PRIMARY (\S+)
2+
Value NODE_NAME (Partner node|Standby node)
3+
Value ROLE (STANDBY|ready|NSR-ready)
4+
5+
6+
Start
7+
^.*\=+ -> Parse
8+
9+
Parse
10+
#^${NODE_NAME}\*.is\s+${ROLE}\) -> Record
11+
#^${NODE_NAME}\s*.is\s+in\s+${ROLE} -> Record
12+
^${NODE_NAME}.*\bi[ns]\b\s+${ROLE} -> Record

0 commit comments

Comments
 (0)