Skip to content

Commit

Permalink
Update SNMP AGENT ADDRESS config table with default
Browse files Browse the repository at this point in the history
values in minigraph parser

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
  • Loading branch information
SuvarnaMeenakshi committed Oct 10, 2023
1 parent 7059f42 commit d1a9fa3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from portconfig import get_port_config, get_fabric_port_config, get_fabric_monitor_config
from sonic_py_common.interface import backplane_prefix
from sonic_py_common.multi_asic import is_multi_asic

# TODO: Remove this once we no longer support Python 2
if sys.version_info.major == 3:
Expand Down Expand Up @@ -1713,6 +1714,22 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw

results['MGMT_VRF_CONFIG'] = mvrf

# Update SNMP_AGENT_ADDRESS_CONFIG with Management IP and Loopback0 IP
# for single-asic platform.
# Update SNMP_AGENT_ADDRESS_CONFIG with Management IP and docker0 IP
# for multi-asic platform.
results['SNMP_AGENT_ADDRESS_CONFIG'] = {}
if asic_name is None and not is_multi_asic():
results['SNMP_AGENT_ADDRESS_CONFIG'] = {}
for mgmt_if in results['MGMT_INTERFACE'].keys():
snmp_key = mgmt_if[1].split('/')[0] + '|161|'
results['SNMP_AGENT_ADDRESS_CONFIG'][snmp_key] = {}
# Add Loopback0 IP as agent address for single asic
for loip in results['LOOPBACK_INTERFACE']:
if len(loip) == 2 and loip[0] == 'Loopback0':
snmp_key = loip[1].split('/')[0] + '|161|'
results['SNMP_AGENT_ADDRESS_CONFIG'][snmp_key] = {}

phyport_intfs = {}
vlan_intfs = {}
pc_intfs = {}
Expand Down
7 changes: 6 additions & 1 deletion src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,4 +1145,9 @@ def test_minigraph_cisco_400g_to_100G_speed_no_lane_change(self):
)
)


def testsnmp_agent_address_config(self):
argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', 'SNMP_AGENT_ADDRESS_CONFIG.keys()|list']
output = self.run_script(argument)
self.assertEqual(
utils.liststr_to_dict(output.strip()),
utils.liststr_to_dict("['192.168.200.15|161|', '100.0.0.6|161|']")

0 comments on commit d1a9fa3

Please sign in to comment.