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

[show][config] Add new snmp commands #1347

Merged
merged 6 commits into from
May 5, 2021

Conversation

tsvanduyn
Copy link
Contributor

- What I did
I created these new show commands:

show runningconfiguration snmp
show runningconfiguration snmp contact
show runningconfiguration snmp location
show runningconfiguration snmp community
show runningconfiguration snmp user

show runningconfiguration snmp contact --json
show runningconfiguration snmp location --json
show runningconfiguration snmp community --json
show runningconfiguration snmp user --json

These commands will check in the REDIS ConfigDB and get the information.

- How I did it
I created a standard snmp schema that was approved here:
sonic-net/SONiC#731

I also moved from using only the snmp.yml file to using the ConfigDB for the device.
sonic-net/sonic-buildimage#6205

Jinja template update:
sonic-net/sonic-buildimage#6134

This way the REDIS ConfigDB will be the source of truth but we can still use the snmp.yml file.

Since it is setup whenever the snmp docker container is restarted to pull this info into the ConfigDB we are able to use the data in the configdb for the show commands.
- How to verify it
You can run the show commands:

show runningconfiguration snmp
show runningconfiguration snmp contact
show runningconfiguration snmp location
show runningconfiguration snmp community
show runningconfiguration snmp user

show runningconfiguration snmp contact --json
show runningconfiguration snmp location --json
show runningconfiguration snmp community --json
show runningconfiguration snmp user --json

and compare the output to what is in the REDIS ConfigDB.

admin@switch1:~$ redis-cli -n 4 keys "*" | grep -i snmp 
SNMP_USER|travis
SNMP_COMMUNITY|Joe
FEATURE|snmp
SNMP_COMMUNITY|public
SNMP|CONTACT
SNMP|LOCATION
SNMP_COMMUNITY|Travis
admin@switch1:~$ redis-cli -n 4 hgetall "SNMP_USER|travis"
 1) "SNMP_USER_ENCRYPTION_TYPE"
 2) "AES"
 3) "SNMP_USER_AUTH_TYPE"
 4) "SHA"
 5) "SNMP_USER_ENCRYPTION_PASSWORD"
 6) "TravEncryptPass"
 7) "SNMP_USER_AUTH_PASSWORD"
 8) "TravAuthPass"
 9) "SNMP_USER_TYPE"
10) "Priv"
11) "SNMP_USER_PERMISSION"
12) "RO"
admin@switch1:~$ redis-cli -n 4 hgetall "SNMP_COMMUNITY|Joe"
1) "TYPE"
2) "RO"
admin@switch1:~$ redis-cli -n 4 hgetall "SNMP|CONTACT"
1) "travis"
2) "travis@contoso.com"
admin@switch1:~$ redis-cli -n 4 hgetall "SNMP|LOCATION"
1) "Location"
2) "Palm Springs"
admin@switch1:~$

- Previous command output (if the output of a command-line utility has changed)
N/A
- New command output (if the output of a command-line utility has changed)

admin@switch1:~$ show run snmp
Location
------------
Palm Springs


SNMP_CONTACT    SNMP_CONTACT_EMAIL
--------------  --------------------
travis          travis@contoso.com


Community String    Community Type
------------------  ----------------
Joe                 RO
public              RO
Travis              RO


User    Type    Auth Type    Auth Password    Encryption Type    Encryption Password
------  ------  -----------  ---------------  -----------------  ---------------------
travis  Priv    SHA          TravAuthPass     AES                TravEncryptPass
admin@switch1:~$ show run snmp location 
Location
------------
Palm Springs
admin@switch1:~$ show run snmp contact
Contact    Contact Email
---------  ------------------
travis     travis@contoso.com
admin@switch1:~$ show run snmp community
Community String    Community Type
------------------  ----------------
Joe                 RO
public              RO
Travis              RO
admin@switch1:~$ show run snmp server
agentAddress udp:161
agentAddress udp6:161
admin@switch1:~$ show run snmp user
User    Type    Auth Type    Auth Password    Encryption Type    Encryption Password
------  ------  -----------  ---------------  -----------------  ---------------------
travis  Priv    SHA          TravAuthPass     AES                TravEncryptPass
admin@switch1:~$ show run snmp location --json
{'Location': 'Palm Springs'}
admin@switch1:~$ show run snmp contact --json
{'travis': 'travis@contoso.com'}
admin@switch1:~$ show run snmp community --json
{'Joe': {'TYPE': 'RO'}, 'public': {'TYPE': 'RO'}, 'Travis': {'TYPE': 'RO'}}
admin@switch1:~$ show run snmp user --json
{'travis': {'SNMP_USER_ENCRYPTION_TYPE': 'AES', 'SNMP_USER_AUTH_TYPE': 'SHA', 'SNMP_USER_ENCRYPTION_PASSWORD': 'TravEncryptPass', 'SNMP_USER_AUTH_PASSWORD': 'TravAuthPass', 'SNMP_USER_TYPE': 'Priv', 'SNMP_USER_PERMISSION': 'RO'}}
admin@switch1:~$

@tsvanduyn tsvanduyn force-pushed the tsvanduyn/snmp_show_commands branch from 9cc6a85 to acc56ea Compare March 31, 2021 00:09
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments.

config/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
tests/config_snmp_test.py Outdated Show resolved Hide resolved
tests/config_snmp_test.py Show resolved Hide resolved
tests/config_snmp_test.py Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
config/main.py Outdated Show resolved Hide resolved
@tsvanduyn tsvanduyn changed the title Add new snmp show commands [show][config] Add new snmp commands May 5, 2021
@tsvanduyn tsvanduyn merged commit 615e531 into sonic-net:master May 5, 2021
@tsvanduyn tsvanduyn deleted the tsvanduyn/snmp_show_commands branch May 5, 2021 19:22
gitsabari pushed a commit to gitsabari/sonic-utilities that referenced this pull request Jun 15, 2021
Added new SNMP show and config commands using ConfigDB as well as unittests.
show commands: 
show runningconfiguration snmp 
show runningconfiguration snmp contact [--json] 
show runningconfiguration snmp location [--json] 
show runningconfiguration snmp community [--json] 
show runningconfiguration snmp user [--json] 

config commands:
sudo config snmp community add/del/replace
sudo config snmp contact add/del/modify
sudo config snmp location add/del/modify
sudo config snmp user add/del
qiluo-msft pushed a commit that referenced this pull request Nov 15, 2021
Added new SNMP show and config commands using ConfigDB as well as unittests.
show commands: 
show runningconfiguration snmp 
show runningconfiguration snmp contact [--json] 
show runningconfiguration snmp location [--json] 
show runningconfiguration snmp community [--json] 
show runningconfiguration snmp user [--json] 

config commands:
sudo config snmp community add/del/replace
sudo config snmp contact add/del/modify
sudo config snmp location add/del/modify
sudo config snmp user add/del
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 18, 2022
9dd3025 2021-05-11 | [Command-Reference.md] Document new SNMP show and config commands (sonic-net#1600) [Travis Van Duyn]
be40767 2021-05-05 | [show][config] Add new snmp commands (sonic-net#1347) [Travis Van Duyn]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants