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

disable :T2372: disable sub-interface if parent is #383

Merged
merged 5 commits into from May 2, 2020
Merged

disable :T2372: disable sub-interface if parent is #383

merged 5 commits into from May 2, 2020

Conversation

thomas-mangin
Copy link
Contributor

The patchset rewrites the vlan_to_dict code so that if an interface is disabled, all the VLAN of that interface are also disabled (admin down).

The code creates a new helper function to look for the disable option in parent interfaces.

It also refactor much of the dictionary generation for interfaces and VLANs (as they are indicatical, and create a helper function to parse vif, vif-s, vif-c.

@@ -98,192 +103,339 @@ def get_ethertype(ethertype_val):
raise ConfigError('invalid ethertype "{}"'.format(ethertype_val))


def vlan_to_dict(conf):
vlan_default = {
# get the '100' in 'interfaces bonding bond0 vif-s 100'
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean with this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leftover from line 109 ..

act_eui = conf.return_values('ipv6 address eui64')

# Determine interface addresses (currently effective) - to determine which
# address is no longer valid and needs to be removed from the bond
Copy link
Member

Choose a reason for hiding this comment

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

I guess bond here is just a leftover.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this comment is also a left-over !

@c-po
Copy link
Member

c-po commented Apr 29, 2020

I really like the idea and besides those two small comments all looks good to me. Less duplicated code!

"""
Common used function which will extract VLAN related information from config
and represent the result as Python dictionary.

Function call's itself recursively if a vif-s/vif-c pair is detected.
"""
vlan = {
'id': conf.get_level()[-1], # get the '100' in 'interfaces bonding bond0 vif-s 100'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@c-po this left over.

@jjakob
Copy link
Contributor

jjakob commented May 1, 2020

@thomas-mangin one of us will need to rebase our changes as we were working on the same code. Look at my PR.

Does this work fine regarding the link-local address code?

@c-po
Copy link
Member

c-po commented May 2, 2020

@thomas-mangin can you please fox the leftovers?

implement disable_state which looks if the current node, or some
designated parent node are set are 'disable' and thefore should
be ignored.

break down the function vlan_to_dict in it multiple components

add_to_dict which can parse vif, vif-s, or vif-c and add them
to the configuration dictionary

intf_to_dict which setup a base configuration dictionary from the
interface Config() with addresses, arp, disable, ...
it is used by vlan_to_dict but can and will be used by other interfaces
use intf_to_dict and add_to_dict to correctly implement disable.
use intf_to_dict and add_to_dict to correctly implement disable.
keeping all interface code with VLAN the same.
use intf_to_dict and add_to_dict to correctly implement disable.
keeping all interface code with VLAN the same.
@thomas-mangin
Copy link
Contributor Author

I fixed the two comments

@c-po c-po merged commit 932657a into vyos:current May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants