1313
1414# Python
1515import re
16+ import logging
1617
1718# Metaparser
1819from genie .metaparser import MetaParser
2223# import parser utils
2324from genie .libs .parser .utils .common import Common
2425
26+ log = logging .getLogger (__name__ )
27+
2528# =================================================
2629# Schema for:
2730# * 'show run policy-map {name}'
@@ -2964,18 +2967,24 @@ def cli(self, output=None):
29642967 # GOAL: parse through the line an argument at a time,
29652968 # shortening the line as we go.
29662969
2970+ # GOAL: match the 'common-criteria-policy' option and return its parameter
2971+ # Sample: "common-criteria-policy MyPolicy"
29672972 if m := common_criteria_policy .match (line ):
29682973 group = m .groupdict ()
29692974 users_dict ['common_criteria_policy' ] = group ['common_criteria_policy' ]
29702975 line = line [m .end ():]
29712976 continue
29722977
2978+ # GOAL: match the 'privilege' option and return its parameter
2979+ # Sample: "privilege 15"
29732980 if m := privilege .match (line ):
29742981 group = m .groupdict ()
29752982 users_dict ['privilege' ] = int (group ['privilege' ])
29762983 line = line [m .end ():]
29772984 continue
29782985
2986+ # GOAL: match the 'secret' option and return its parameters ('type' and 'secret')
2987+ # Sample: "secret 9 $9$oNguEA9um9vRx.$MsDk0DOy1rzBjKAcySWdNjoKcA7GetG9YNnKOs8S67A"
29792988 if m := secret .match (line ):
29802989 group = m .groupdict ()
29812990 pass_dict = users_dict .setdefault ('secret' , {})
@@ -2984,24 +2993,32 @@ def cli(self, output=None):
29842993 line = line [m .end ():]
29852994 continue
29862995
2996+ # GOAL: match the 'onetime' flag
2997+ # Sample: "onetime"
29872998 if m := onetime .match (line ):
29882999 group = m .groupdict ()
29893000 users_dict ['onetime' ] = True
29903001 line = line [m .end ():]
29913002 continue
29923003
3004+ # GOAL: match the 'nopassword' flag
3005+ # Sample: "nopassword"
29933006 if m := nopassword .match (line ):
29943007 group = m .groupdict ()
29953008 users_dict ['nopassword' ] = True
29963009 line = line [m .end ():]
29973010 continue
29983011
3012+ # GOAL: match the 'autocommand' option and return all subsequent text
3013+ # Sample: "autocommand show ip bgp summary"
29993014 if m := autocommand .match (line ):
30003015 group = m .groupdict ()
30013016 users_dict ['autocommand' ] = group ['autocommand' ]
30023017 line = line [m .end ():]
30033018 continue
30043019
3020+ # GOAL: match the 'password' option and return its parameters ('type' and 'password')
3021+ # Sample: "password 0 lab"
30053022 if m := password .match (line ):
30063023 group = m .groupdict ()
30073024 pass_dict = users_dict .setdefault ('password' , {})
@@ -3011,7 +3028,7 @@ def cli(self, output=None):
30113028 continue
30123029
30133030 # CLAIM: There is an unhandled argument.
3014- Common . log .warning (f"Unhandled argument in parser 'show running-config aaa username': { line } " )
3031+ log .warning (f"Unhandled argument in parser 'show running-config aaa username': { line } " )
30153032 break
30163033
30173034 return ret_dict
@@ -4993,4 +5010,4 @@ def cli(self, output=None):
49935010 radius_server_dict .update ({'dtls_trustpoint_server' : m .groupdict ()['dtls_trustpoint_server' ]})
49945011 continue
49955012
4996- return ret_dict
5013+ return ret_dict
0 commit comments