Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/show logging level #729

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--------------------------------------------------------------------------------
New
--------------------------------------------------------------------------------
* NXOS
* Added ShowLoggingLevel:
* show logging level
* show logging level {facility}
59 changes: 59 additions & 0 deletions src/genie/libs/parser/nxos/show_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,62 @@ def cli(self, include='', output=None):
continue

return parsed_dict

class ShowLoggingLevelSchema(MetaParser):
'''Schema for:
* 'show logging level'
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved
* 'show logging level {name}'
'''

schema = { 'facility':
{ Any():
{ 'default_severity': int,
'current_session_severity': int }
}
}
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved

class ShowLoggingLevel(ShowLoggingLevelSchema):
'''Schema for:
* 'show logging level'
* 'show logging level {facility}'
'''

cli_command = [ 'show logging level', 'show logging level {facility}' ]

def cli(self, facility='', output=None):

if (output is None):
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved
# Build the command
if facility:
cmd = self.cli_command[0].format(facility=facility)
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved
else:
cmd = self.cli_command[1]
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved

# Execute the command
out = self.device.execute(cmd)
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved

else:
out = output

rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved
p = re.compile(r'(?P<facility>\S+)\s+'
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved
'(?P<default_severity>\d)\s+'
'(?P<current_session_severity>\d)')
ret_dict = {}

for line in out.splitlines():
line = line.strip()

m = p.match(line)
if m:
if 'facility' not in ret_dict:
ret_dict['facility'] = {}
rohit04saluja marked this conversation as resolved.
Show resolved Hide resolved

facility = m.groupdict()['facility']
if facility not in ret_dict['facility']:
ret_dict['facility'][facility] = {}

for x in ['default_severity', 'current_session_severity']:
x_val = int(m.groupdict()[x])
ret_dict['facility'][facility][x] = x_val

return ret_dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


expected_output = {
'facility': {
"aaa": {
'default_severity': 3,
'current_session_severity': 3
},
"acllog": {
'default_severity': 2,
'current_session_severity': 1
},
"aclmgr": {
'default_severity': 3,
'current_session_severity': 3
},
"aclqos": {
'default_severity': 5,
'current_session_severity': 4
},
"vlan_mgr": {
'default_severity': 2,
'current_session_severity': 5
},
"vshd": {
'default_severity': 5,
'current_session_severity': 5
},
"xbar": {
'default_severity': 5,
'current_session_severity': 0
},
"xmlma": {
'default_severity': 3,
'current_session_severity': 7
}
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

Facility Default Severity Current Session Severity
-------- ---------------- ------------------------
aaa 3 3
acllog 2 1
aclmgr 3 3
aclqos 5 4
vlan_mgr 2 5
vshd 5 5
xbar 5 0
xmlma 3 7

0(emergencies) 1(alerts) 2(critical)
3(errors) 4(warnings) 5(notifications)
6(information) 7(debugging
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"facility": "aaa"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


expected_output = {
'facility': {
"aaa": {
'default_severity': 3,
'current_session_severity': 5
}
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Facility Default Severity Current Session Severity
-------- ---------------- ------------------------
aaa 3 5

0(emergencies) 1(alerts) 2(critical)
3(errors) 4(warnings) 5(notifications)
6(information) 7(debugging)