You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parse all secondary IP addresses found under interface configs into a list and change IP address notation to cidr instead of ip address mask subnet. This can be implemented by introducing a macro to the interfaces group and using the inbuilt to_cidr method to convert the masks.
Use-case:
Makes it easier to create a IPNetwork object from the netaddr library
Easier to represent when comparing IPs with a SoT (e.g Netbox)
Fully account for IP information in the configs
def parse_ip(data):
if data.get('primary_ip') and data.get('primary_mask'):
data['primary_ip'] = data['primary_ip'] + '/' + str(data['primary_mask'])
data.pop('primary_mask')
if data.get('secondary_ips') and data.get('secondary_masks'):
data['secondary_ips'] = [f"{ip}/{mask}" for ip, mask in zip(data['secondary_ips'], data['secondary_masks'])]
data.pop('secondary_masks')
</macro>
I can submit a PR for this also.
The text was updated successfully, but these errors were encountered:
Parse all secondary IP addresses found under interface configs into a list and change IP address notation to cidr instead of ip address mask subnet. This can be implemented by introducing a macro to the interfaces group and using the inbuilt to_cidr method to convert the masks.
Use-case:
I can submit a PR for this also.
The text was updated successfully, but these errors were encountered: