Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

interfaces_ip primary IP check #206

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@dbarrosop dbarrosop Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no concept of primary or secondary ip on IPv6 so I'd hardcode this to True for simplicity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so even when a router needs to source an IP, how does it choose which one?

Does it make sense not to include on IPv6 at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a whole RFC for that (surprise!): https://tools.ietf.org/html/rfc6724
Actually, IPv4 doesn't have the concept at all either. AFAICT only Cisco has the "secondary" keyword. Juniper certainly doesn't.

Does it make sense not to include on IPv6 at all?

You are probably right. You will have to slightly adapt the test so it uses two different models; one for IPv4 and one for IPv6.

},
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
}
}
},
Expand Down