@@ -1030,46 +1030,53 @@ def check_link_type(data: Box) -> bool:
10301030 return True
10311031
10321032#
1033- # Interface Feature Check -- validate that the selected addressing works on target lab devices
1033+ # Interface Feature Check -- validate that the selected interface features work on target lab devices
10341034#
10351035
1036+ def interface_fc_ipv4 (ifdata : Box , ndata : Box , features : Box , more_data : str ) -> None :
1037+ if 'ipv4' not in ifdata :
1038+ return
1039+ if ifdata .ipv4 is True :
1040+ f_v4_unnum = features .initial .ipv4 .unnumbered
1041+ if not f_v4_unnum :
1042+ log .error (
1043+ text = f'Invalid unnumbered IPv4 interface { ifdata .ifname } ({ ifdata .name } ) on node { ndata .name } ' ,
1044+ more_hints = f'Device { ndata .device } (node { ndata .name } ) does not support unnumbered IPv4 interfaces' ,
1045+ category = log .IncorrectValue ,
1046+ module = 'interfaces' )
1047+ elif isinstance (f_v4_unnum ,list ):
1048+ if ifdata .type not in features .initial .ipv4 .unnumbered :
1049+ log .error (
1050+ text = f'Node { ndata .name } uses unsupported unnumbered IPv4 interface type { ifdata .type } ' ,
1051+ more_data = more_data ,
1052+ more_hints = f'Device { ndata .device } supports only { "," .join (f_v4_unnum )} unnumbered IPv4 interfaces' ,
1053+ category = log .IncorrectValue ,
1054+ module = 'interfaces' )
1055+ elif f_v4_unnum == 'peer' :
1056+ if len (ifdata .neighbors )!= 1 or ifdata .neighbors [0 ].get ('ipv4' ,False ) is not True :
1057+ log .error (
1058+ text = f'The unnumbered IPv4 interface { ifdata .ifname } ({ ifdata .name } ) on node { ndata .name } is not supported' ,
1059+ more_hints = f'Device { ndata .device } can have unnumbered IPv4 interfaces with a single unnumbered peer' ,
1060+ category = log .IncorrectType ,
1061+ module = 'interfaces' )
1062+
1063+ def interface_fc_ipv6 (ifdata : Box , ndata : Box , features : Box , more_data : str ) -> None :
1064+ if 'ipv6' not in ifdata :
1065+ return
1066+ if ifdata .ipv6 is True and not features .initial .ipv6 .lla :
1067+ log .error (
1068+ f'Device { ndata .device } (node { ndata .name } ) does not support LLA-only IPv6 interfaces' ,
1069+ category = log .IncorrectValue ,
1070+ more_data = more_data ,
1071+ module = 'interfaces' )
1072+
10361073def interface_feature_check (nodes : Box , defaults : Box ) -> None :
10371074 for node ,ndata in nodes .items ():
10381075 features = devices .get_device_features (ndata ,defaults )
10391076 for ifdata in ndata .get ('interfaces' ,[]):
10401077 more_data = f'Interface { ifdata .ifname } (link { ifdata .name } )'
1041- if 'ipv4' in ifdata :
1042- if ifdata .ipv4 is True :
1043- f_v4_unnum = features .initial .ipv4 .unnumbered
1044- if not f_v4_unnum :
1045- log .error (
1046- text = f'Invalid unnumbered IPv4 interface { ifdata .ifname } ({ ifdata .name } ) on node { node } ' ,
1047- more_hints = f'Device { ndata .device } (node { node } ) does not support unnumbered IPv4 interfaces' ,
1048- category = log .IncorrectValue ,
1049- module = 'interfaces' )
1050- elif isinstance (f_v4_unnum ,list ):
1051- if ifdata .type not in features .initial .ipv4 .unnumbered :
1052- log .error (
1053- text = f'Node { node } uses unsupported unnumbered IPv4 interface type { ifdata .type } ' ,
1054- more_data = more_data ,
1055- more_hints = f'Device { ndata .device } supports only { "," .join (f_v4_unnum )} unnumbered IPv4 interfaces' ,
1056- category = log .IncorrectValue ,
1057- module = 'interfaces' )
1058- elif f_v4_unnum == 'peer' :
1059- if len (ifdata .neighbors )!= 1 or ifdata .neighbors [0 ].get ('ipv4' ,False ) is not True :
1060- log .error (
1061- text = f'The unnumbered IPv4 interface { ifdata .ifname } ({ ifdata .name } ) on node { node } is not supported' ,
1062- more_hints = f'Device { ndata .device } can have unnumbered IPv4 interfaces with a single unnumbered peer' ,
1063- category = log .IncorrectType ,
1064- module = 'interfaces' )
1065-
1066- if 'ipv6' in ifdata :
1067- if ifdata .ipv6 is True and not features .initial .ipv6 .lla :
1068- log .error (
1069- f'Device { ndata .device } (node { node } ) does not support LLA-only IPv6 interfaces' ,
1070- category = log .IncorrectValue ,
1071- more_data = more_data ,
1072- module = 'interfaces' )
1078+ interface_fc_ipv4 (ifdata ,ndata ,features ,more_data )
1079+ interface_fc_ipv6 (ifdata ,ndata ,features ,more_data )
10731080
10741081'''
10751082copy_link_gateway -- copy link gateway addresses to node-on-link (future interface) data
0 commit comments