@@ -4919,6 +4919,11 @@ def bind(ctx, interface_name, vrf_name):
4919
4919
interface_addresses = get_interface_ipaddresses (config_db , interface_name )
4920
4920
for ipaddress in interface_addresses :
4921
4921
remove_router_interface_ip_address (config_db , interface_name , ipaddress )
4922
+ if interface_type == "VLAN_SUB_INTERFACE" :
4923
+ subintf = config_db .get_entry (interface_type , alias )
4924
+ if 'vrf_name' in subintf_entry :
4925
+ subintf_entry .pop ('vrf' )
4926
+
4922
4927
config_db .set_entry (table_name , interface_name , None )
4923
4928
# When config_db del entry and then add entry with same key, the DEL will lost.
4924
4929
if ctx .obj ['namespace' ] is DEFAULT_NAMESPACE :
@@ -4930,6 +4935,10 @@ def bind(ctx, interface_name, vrf_name):
4930
4935
while state_db .exists (state_db .STATE_DB , _hash ):
4931
4936
time .sleep (0.01 )
4932
4937
state_db .close (state_db .STATE_DB )
4938
+ if interface_type == "VLAN_SUB_INTERFACE" :
4939
+ subintf ['vrf_name' ] = vrfname
4940
+ config_db .set_entry (interface_type , alias , subintf )
4941
+ else :
4933
4942
config_db .set_entry (table_name , interface_name , {"vrf_name" : vrf_name })
4934
4943
4935
4944
#
@@ -6682,6 +6691,18 @@ def subintf_vlan_check(config_db, parent_intf, vlan):
6682
6691
return True
6683
6692
return False
6684
6693
6694
+ def is_subintf_shortname (intf ):
6695
+ if VLAN_SUB_INTERFACE_SEPARATOR in intf :
6696
+ if intf .startswith ("Eth" ):
6697
+ if intf .startswith ("Ethernet" ):
6698
+ return False
6699
+ return True
6700
+ elif intf .startswith ("Po" ):
6701
+ if intf .startswith ("PortChannel" ):
6702
+ return False
6703
+ return True
6704
+ return False
6705
+
6685
6706
@subinterface .command ('add' )
6686
6707
@click .argument ('subinterface_name' , metavar = '<subinterface_name>' , required = True )
6687
6708
@click .argument ('vid' , metavar = '<vid>' , required = False , type = click .IntRange (1 ,4094 ))
@@ -6727,6 +6748,8 @@ def add_subinterface(ctx, subinterface_name, vid):
6727
6748
subintf_dict = {}
6728
6749
if vid is not None :
6729
6750
subintf_dict .update ({"vlan" : vid })
6751
+ elif is_subintf_shortname (subinterface_name ):
6752
+ ctx .fail ("{} Encap vlan is mandatory for short name subinterfaces" .format (subinterface_name ))
6730
6753
6731
6754
if subintf_vlan_check (config_db , get_intf_longname (interface_alias ), vid ) is True :
6732
6755
ctx .fail ("Vlan {} encap already configured on other subinterface on {}" .format (vid , interface_alias ))
0 commit comments