From 844fb66087ba7594ebf99149b0e5d9443d8c3b1a Mon Sep 17 00:00:00 2001 From: Ken Celenza Date: Sat, 11 Feb 2017 16:45:44 -0500 Subject: [PATCH 1/3] interfaces_ip primary IP check For IPv4 addresses, look to add check for primary IP. This method should be backwards compatible with current implementation. --- napalm_base/base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/napalm_base/base.py b/napalm_base/base.py index 01e1aa69..7fdcbfa9 100644 --- a/napalm_base/base.py +++ b/napalm_base/base.py @@ -796,6 +796,7 @@ def get_interfaces_ip(self): addresses as keys. Each IP Address dictionary has the following keys: * prefix_length (int) + * primary_ip (boolean) Example:: @@ -803,7 +804,11 @@ def get_interfaces_ip(self): u'FastEthernet8': { u'ipv4': { u'10.66.43.169': { - 'prefix_length': 22 + 'prefix_length': 22, + 'primary_ip': True + }, + u'10.66.50.1': { + 'prefix_length': 24 } } }, @@ -831,7 +836,8 @@ def get_interfaces_ip(self): u'Tunnel0': { u'ipv4': { u'10.63.100.9': { - 'prefix_length': 24 + 'prefix_length': 24, + 'primary_ip': True } } } From 8ab001244256a22b3030c89f85730e4b73145434 Mon Sep 17 00:00:00 2001 From: Narayanan Seshan Date: Tue, 11 Apr 2017 13:41:02 -0700 Subject: [PATCH 2/3] Modified model for interfaces_ip --- napalm_base/test/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/napalm_base/test/models.py b/napalm_base/test/models.py index 37bd84ff..2f783e2b 100644 --- a/napalm_base/test/models.py +++ b/napalm_base/test/models.py @@ -197,7 +197,8 @@ } interfaces_ip = { - 'prefix_length': int + 'prefix_length': int, + 'primary_key': bool } mac_address_table = { From e66801a04e4a8298cabc95f505da4602b448346e Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Sun, 9 Jul 2017 23:41:33 -0400 Subject: [PATCH 3/3] ensure all interfaces have a primary_ip in base example --- napalm_base/base.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/napalm_base/base.py b/napalm_base/base.py index 7fdcbfa9..6e16a442 100644 --- a/napalm_base/base.py +++ b/napalm_base/base.py @@ -808,28 +808,34 @@ def get_interfaces_ip(self): 'primary_ip': True }, u'10.66.50.1': { - 'prefix_length': 24 + 'prefix_length': 24, + 'primary_ip': False } } }, u'Loopback555': { u'ipv4': { u'192.168.1.1': { - 'prefix_length': 24 + 'prefix_length': 24, + 'primary_ip': True } }, u'ipv6': { u'1::1': { - 'prefix_length': 64 + 'prefix_length': 64, + 'primary_ip': False }, u'2001:DB8:1::1': { - 'prefix_length': 64 + 'prefix_length': 64, + 'primary_ip': True }, u'2::': { - 'prefix_length': 64 + 'prefix_length': 64, + 'primary_ip': False }, u'FE80::3': { - 'prefix_length': u'N/A' + 'prefix_length': u'N/A', + 'primary_ip': False } } },