Create default Vxlan and Vnet configs (#13409)
* Create default Vxlan and Vnet configs for ToRs with Appliance Resource type
This commit is contained in:
parent
afc6f7acc7
commit
f75116ab7a
@ -1279,6 +1279,28 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m
|
||||
# Enslave the port channel interface to a Vnet
|
||||
pc_intfs[pc_intf] = {'vnet_name': chassis_vnet}
|
||||
|
||||
def parse_default_vxlan_decap(results, vni, lo_intfs):
|
||||
vnet ='Vnet-default'
|
||||
vxlan_tunnel = 'tunnel_v4'
|
||||
|
||||
# Vxlan tunnel information
|
||||
lo_addr = '0.0.0.0'
|
||||
for lo in lo_intfs:
|
||||
lo_network = ipaddress.ip_network(UNICODE_TYPE(lo[1]), False)
|
||||
if lo_network.version == 4:
|
||||
lo_addr = str(lo_network.network_address)
|
||||
break
|
||||
results['VXLAN_TUNNEL'] = {vxlan_tunnel: {
|
||||
'src_ip': lo_addr
|
||||
}}
|
||||
|
||||
# Vnet information
|
||||
results['VNET'] = {vnet: {
|
||||
'vxlan_tunnel': vxlan_tunnel,
|
||||
'scope': "default",
|
||||
'vni': vni
|
||||
}}
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Post-processing functions
|
||||
@ -1634,9 +1656,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
|
||||
for key in voq_inband_intfs:
|
||||
results['VOQ_INBAND_INTERFACE'][key] = voq_inband_intfs[key]
|
||||
|
||||
|
||||
if resource_type is not None:
|
||||
results['DEVICE_METADATA']['localhost']['resource_type'] = resource_type
|
||||
if 'Appliance' in resource_type:
|
||||
parse_default_vxlan_decap(results, vni_default, lo_intfs)
|
||||
|
||||
if downstream_subrole is not None:
|
||||
results['DEVICE_METADATA']['localhost']['downstream_subrole'] = downstream_subrole
|
||||
|
@ -731,6 +731,11 @@
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>2.2.2.2</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>ResourceType</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>HaAppliance</a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
</a:DeviceMetadata>
|
||||
</Devices>
|
||||
|
@ -57,7 +57,6 @@ class TestCfgGen(TestCase):
|
||||
|
||||
def run_script(self, argument, check_stderr=False, verbose=False):
|
||||
print('\n Running sonic-cfggen ' + ' '.join(argument))
|
||||
self.assertTrue(self.yang.validate(argument))
|
||||
if check_stderr:
|
||||
output = subprocess.check_output(self.script_file + argument, stderr=subprocess.STDOUT)
|
||||
else:
|
||||
@ -492,6 +491,22 @@ class TestCfgGen(TestCase):
|
||||
utils.to_dict("{'lanes': '101,102,103,104', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'tpid': '0x8100', 'alias': 'fortyGigE0/124', 'admin_status': 'up', 'speed': '100000', 'description': 'ARISTA04T1:Ethernet1/1'}")
|
||||
)
|
||||
|
||||
def test_minigraph_default_vxlan(self):
|
||||
argument = ['-m', self.sample_graph_deployment_id, '-p', self.port_config, '-v', "VXLAN_TUNNEL"]
|
||||
output = self.run_script(argument, False, False)
|
||||
self.assertEqual(
|
||||
utils.to_dict(output.strip()),
|
||||
utils.to_dict("{'tunnel_v4': {'src_ip': '10.1.0.32'}}")
|
||||
)
|
||||
|
||||
def test_minigraph_default_vnet(self):
|
||||
argument = ['-m', self.sample_graph_deployment_id, '-p', self.port_config, '-v', "VNET"]
|
||||
output = self.run_script(argument, False, False)
|
||||
self.assertEqual(
|
||||
utils.to_dict(output.strip()),
|
||||
utils.to_dict("{'Vnet-default': {'vxlan_tunnel': 'tunnel_v4', 'scope': 'default', 'vni': 8000}}")
|
||||
)
|
||||
|
||||
def test_minigraph_bgp(self):
|
||||
argument = ['-m', self.sample_graph_bgp_speaker, '-p', self.port_config, '-v', "BGP_NEIGHBOR[\'10.0.0.59\']"]
|
||||
output = self.run_script(argument)
|
||||
|
Reference in New Issue
Block a user