Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the vlan_mask fixture #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add the vlan_mask fixture #14

wants to merge 1 commit into from

Conversation

Jane-Fan
Copy link

@Jane-Fan Jane-Fan commented Jun 5, 2018

The vlan mask info is missing before and it is needed in some tests.

@@ -84,9 +84,11 @@ def addresses(self):
if addr.is_link_local:
continue
elif addr.version == 4:
data.setdefault(socket.AF_INET, []).append(addr)
values = data.setdefault(socket.AF_INET, [])
values.append(addr), values.append(prefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't do this. This is a list for a reason - its possible to have multiple addresses per network interface. You can't just shove whatever extra data you want in here just because.

Copy link
Contributor

Choose a reason for hiding this comment

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

addr is already an ipaddress.IPv4Address/ipaddress.IPv6Address - we use ipaddress.ip_address to parse it.

It would make much more sense to just mixin the prefix information and use ipaddress.ip_interface instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, we probably should just mark this method as deprecated and introduce a new method that returns interfaces instead of addresses.

@@ -84,9 +84,11 @@ def addresses(self):
if addr.is_link_local:
continue
elif addr.version == 4:
data.setdefault(socket.AF_INET, []).append(addr)
values = data.setdefault(socket.AF_INET, [])
values.append(addr), values.append(prefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

addr is already an ipaddress.IPv4Address/ipaddress.IPv6Address - we use ipaddress.ip_address to parse it.

It would make much more sense to just mixin the prefix information and use ipaddress.ip_interface instead.

@pytest.fixture(scope='class')
def vlan_mask(vlan, addr_family):
'''Return the correct network mask for the macvlan interface'''
return vlan.get_address(addr_family)[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

First, this isn't the mask - its the prefix.

And I don't think you should add this fixture.

vlan and vlan_set have been the predominant way to get macvlan(s). Your change to get_address breaks all code that uses either of these two fixtures directly. Realise that vlan_addr is just a convenience fixture because of the sheer number of tests that only care about having a second IP address.

But we have a lot of tests that ask for 5 more, for example, and this change will break them.

@@ -84,9 +84,11 @@ def addresses(self):
if addr.is_link_local:
continue
elif addr.version == 4:
data.setdefault(socket.AF_INET, []).append(addr)
values = data.setdefault(socket.AF_INET, [])
values.append(addr), values.append(prefix)
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, we probably should just mark this method as deprecated and introduce a new method that returns interfaces instead of addresses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants