[minigraph.py]: Add peer switch hostname to device metadata (#6405)
To make the peer switch hostname easily accessible from config DB. Add peer_switch field to DEVICE_METADATA table Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
This commit is contained in:
parent
9da8b0faf9
commit
264ecb181c
@ -1178,6 +1178,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
||||
|
||||
if bool(results['PEER_SWITCH']):
|
||||
results['DEVICE_METADATA']['localhost']['subtype'] = 'DualToR'
|
||||
if len(results['PEER_SWITCH'].keys()) > 1:
|
||||
print("Warning: more than one peer switch was found. Only the first will be parsed: {}".format(results['PEER_SWITCH'].keys()[0]))
|
||||
|
||||
results['DEVICE_METADATA']['localhost']['peer_switch'] = list(results['PEER_SWITCH'].keys())[0]
|
||||
|
||||
if is_storage_device:
|
||||
results['DEVICE_METADATA']['localhost']['storage_device'] = "true"
|
||||
|
@ -57,6 +57,11 @@ class TestCfgGenCaseInsensitive(TestCase):
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), 'DualToR')
|
||||
|
||||
def test_minigraph_peer_switch_hostname(self):
|
||||
argument = '-m "' + self.sample_graph + '" -v "DEVICE_METADATA[\'localhost\'][\'peer_switch\']"'
|
||||
output = self.run_script(argument)
|
||||
self.assertEqual(output.strip(), 'switch2-t0')
|
||||
|
||||
def test_additional_json_data(self):
|
||||
argument = '-a \'{"key1":"value1"}\' -v key1'
|
||||
output = self.run_script(argument)
|
||||
|
Reference in New Issue
Block a user