@@ -182,24 +182,35 @@ for ccp_obj in parse.find_objects('^interface'):
182
182
intf_class = ccp_obj.interface_object.interface_class or " "
183
183
184
184
# #########################################################################
185
- # Extract an IPv4Obj() with re_match_iter_typed()
185
+ # Extract all IPv4Obj() with re_match_iter_typed()
186
186
# #########################################################################
187
- intf_dict = ccp_obj.re_match_iter_typed(
188
- r " ip\s + address\s + ( ?P<v4addr> \S . + ) $ " ,
189
- groupdict = {" v4addr" : IPv4Obj},
190
- default = None
191
- )
192
- intf_ipv4obj = intf_dict[" v4addr" ]
187
+ for _obj in ccp_obj.children:
188
+ # Get a dict() from re_match_iter_typed() by caling it with 'groupdict'
189
+ intf_dict = _obj.re_match_iter_typed(
190
+ # Add a regex match-group called 'v4addr'
191
+ r " ip\s + address\s + ( ?P<v4addr> \S . + ) $ " ,
192
+ # Cast the v4addr regex match group as an IPv4Obj() type
193
+ groupdict = {" v4addr" : IPv4Obj},
194
+ # Default to None if there is no regex match
195
+ default = None
196
+ )
197
+ intf_ipv4obj = intf_dict[" v4addr" ]
193
198
194
199
# #########################################################################
195
- # Extract an IPv6Obj() (only EUI-64 portion ) with re_match_iter_typed()
200
+ # Extract all IPv6Obj() with re_match_iter_typed()
196
201
# #########################################################################
197
- intf_dict = ccp_obj.re_match_iter_typed(
198
- r " ipv6\s + address\s + ( ?P<v6addr> \S . + ) \s + ( eui. 64) $ " ,
199
- groupdict = {" v6addr" : IPv6Obj},
200
- default = None
201
- )
202
- intf_ipv6obj = intf_dict[" v6addr" ]
202
+ for _obj in ccp_obj.children:
203
+ # Get a dict() from re_match_iter_typed() by caling it with 'groupdict'
204
+ intf_dict = _obj.re_match_iter_typed(
205
+ # Add regex match-groups called 'v6addr' and an optional 'ipv6type'
206
+ r " ipv6\s + address\s + ( ?P<v6addr> \S . + ) \s * ( ?P<v6type> eui. 64| link. local) * $ " ,
207
+ # Cast the v6addr regex match group as an IPv6Obj() type
208
+ groupdict = {" v6addr" : IPv6Obj, " v6type" : str },
209
+ # Default to None if there is no regex match
210
+ default = None
211
+ )
212
+ intf_ipv6obj = intf_dict[" v6addr" ]
213
+ intf_ipv6type = intf_dict[" v6type" ]
203
214
```
204
215
205
216
When that is run, you will see information similar to this...
0 commit comments