summaryrefslogtreecommitdiff
path: root/python/vyos/configdict.py
AgeCommit message (Collapse)Author
2022-07-18vyos.configdict(): T4228: is_member() must use the "real" hardware interfaceChristian Poessinger
When is_member() is inspecting the bridge/Bond member interfaces it must work with the real interface (e.g. eth1) under the "ethernet" node and not work on the "member interface eth1" CLI tree, that makes no sense at all. (cherry picked from commit 3915791216998a18bf6831450df68ee199e2e4f8)
2022-04-29vyos.configdict: T4369: add is_node_changed() helperChristian Poessinger
(cherry picked from commit 714346e2ee0c61a08a9d17fdb962f2fbea9f73c9)
2022-02-22vyos.configdict: T4263: leaf_node_changed() must also honor valueLess CLI nodesChristian Poessinger
If a valueLess node is added or removed from the CLI, a call to leaf_node_changed() will not detect it. If node is valueLess, on change old or new (depending on addition or deletion) will be {} and is treated as None. Add handler for this special case where old or new is an instance of a dictionary but empty. (cherry picked from commit 149f704a172fb14f16d0ba00ef237b972539492f)
2022-02-20interface: T4203: prevent DHCP client restart if not necessaryChristian Poessinger
In the past whenever a change happened to any interface and it was configured as a DHCP client, VyOS always had a breif outage as DHCP released the old lease and re-aquired a new one - bad! This commit changes the behavior that DHCP client is only restarted if any one of the possible options one can set for DHCP client under the "dhcp-options" node is altered. (cherry picked from commit 3a1a7c40a13ee9f5561823a79876d88d3f5bf053)
2022-02-06config: T4228: is_member() must return all instances not only the last oneChristian Poessinger
(cherry picked from commit 5e7e96380b314587bbd8bd584848d39caef86f3f)
2021-12-09vyos.configdict: T4064: bugfix for IP addresses not removed from KernelChristian Poessinger
Commit e8c6595fc47 ("vyos.ifconfig: T2738: do not remove OS assigned IP addresses from interface") addressed an issue with IP addresses added to interfaces by daemons and not by the CLI. The solution in this commit for IP address removal unfortunately did not cover VLAN (802.1q and 802.1ad) IP address removal in the same way as it is done for non VLAN interfaces. The code was missing.
2021-11-05vyos.configdict: T3972: bugfix QinQ vif-c removal triggered KeyErrorChristian Poessinger
Generic get_removed_vlans() function replaced the entire config dict when any QinQ vif-c subinterface was deleted. (cherry picked from commit b3be36586c85005538d5cc994c7c9694b9907d81)
2021-11-03sstp: T2566: use XML defaultValue over Jinja2 hardcoded valueChristian Poessinger
2021-09-19vyos.ifconfig: T2738: do not remove OS assigned IP addresses from interfaceChristian Poessinger
When using VRRP on any given interface and performing an action against that interface - be it even only changing the alias - will trigger a removal of the VRRP IP address. The issue is caused by: # determine IP addresses which are assigned to the interface and build a # list of addresses which are no longer in the dict so they can be removed cur_addr = self.get_addr() for addr in list_diff(cur_addr, new_addr): When the script calls into the library - we will drop all IP addresses set on the adapter but not available in the config dict. We should only remove the IP addresses marked by the CLI to be deleted! (cherry picked from commit e80d0aebd691f1a707ab534b4d1340fa0b793e01)
2021-09-19vyos.configdict: bugfix: leaf_node_changed() must return empty dict when ↵Christian Poessinger
node is added Commit f476e456 ("vyos.configdict: leaf_node_changed() must return empty dict when node is added") returned [''] as "empty" dict - but this is not empty. >>> if ['']: ... print('foo') ... foo It should rather be: [] (cherry picked from commit e28a80a2b742ea3d9d4bcb8ae66c7a0d51aaaff6)
2021-09-09vyos.configdict: T3814: use no_tag_node_value_mangle in get_interface_dict()Christian Poessinger
This change is required and currently only impacts WireGuards peer configuration, so that the peers name is not mangled. (cherry picked from commit 4d2201eed00ac4780d0196abf53dd9b7cb943a09)
2021-08-22vyos.configdict: leaf_node_changed() must return empty dict when node is addedChristian Poessinger
vyos@vyos# show interfaces pppoe pppoe pppoe10 { + access-concentrator asdfg authentication { password bar user foo } default-route force no-peer-dns source-interface eth0.202 } vyos@vyos# python3 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from vyos.config import Config >>> from vyos.configdict import get_interface_dict >>> from vyos.configdict import leaf_node_changed >>> conf = Config() >>> base = ['interfaces', 'pppoe'] >>> tmp = get_interface_dict(conf, base, 'pppoe10') >>> leaf_node_changed(conf, ['access-concentrator']) >>> [''] (cherry picked from commit f476e456e20393e7e7e91b73e369c9b033fbf048)
2021-08-22vyos.configdict: add note when using leaf_node_changed()Christian Poessinger
(cherry picked from commit 9c97bd1b0214e102ac36eae8b2c3c9ff672a0bf3)
2021-06-10pppoe: T3250: Not mangle values for tag nodessever-sever
(cherry picked from commit 80fe3ef4d49f6ee277d52ef5847f011e5775e7fb)
2021-01-16vyos.configdict: node_changed() now accepts key mangling parameterChristian Poessinger
(cherry picked from commit 452a9c504f472dcaee8c93947a889dab4f8259ce)
2021-01-03mirror: T3089: remove redundant code pathsChristian Poessinger
- remove redundant code paths apply_mirror() / apply_mirror_of_monitor() - have single source available
2020-12-13interfaces: mirror: T3089: Fix the dependency problem between interfacesjack9603301
Since the dependency problem has not been solved before, if the monitoring interface does not exist when the mirror rule is created, the execution will be abnormal
2020-12-13interfaces: T3114: Modify the logic of the second addition to complete the ↵jack9603301
setting and streamline the code
2020-11-27vyos.configdict: T2665: add task id comment for later refactoringChristian Poessinger
2020-11-13vyos.template: provide general is_ip(v4|v6) helpersChristian Poessinger
We had two places were the is_ip, is_ipv4 and is_ipv6 helpers had been defined. All places now have been converged into vyos.template as they are used both in the Jinja2 templates and also in our scripts.
2020-11-10bridge: T3042: Support VLAN filter and VLAN sub-interface on the bridgejack9603301
2020-10-28vyos.util: T2995: rename vyos_dict_search() -> dict_search()Christian Poessinger
Renamed using snippet below: ---------------------------- for file in $(find . -name "*.py") do sed -i "s/vyos_dict_search/dict_search/" $file done
2020-10-27accel: T2631: Add option for radius disable-accountingsever-sever
2020-10-17ifconfig: T2985: support on demand bridge creationChristian Poessinger
The current implementation for bridge based interfaces has an issue which is caused by priority inheritance. We always assumed that the bridge interface will be created last, but this may not be true in all cases, where some interfaces will be created "on demand" - e.g. OpenVPN or late (VXLAN, GENEVE). As we already have a bunch of verify steps in place we should not see a bridge interface leak to the underlaying infrastructure code. This means, whenever an interface will be member of a bridge, and the bridge does yet not exist, we will create it in advance in the interface context, as the bridge code will be run in the same commit but maybe sooner or later. This will also be the solution for T2924.
2020-10-13pppoe-server: T2976: fix local-users default value retrieval from XMLChristian Poessinger
We must use XML node style (hyphen over underscore).
2020-10-04sstp: T2960: migrate to get_config_dict() and reusable templatesChristian Poessinger
2020-10-01vlan: configdict: T2945: determine if vlan is part of bridgeChristian Poessinger
Every interface knows if it is part of a bridge or not - except a VLAN (VIF) interface. Also VLANs should be aware of its master bridge. Add a testcase to ensure when VIFs on an interface change the bridge does not loos one of it's members.
2020-10-01configdict: T2372: use config.exists() when probing for interface removalChristian Poessinger
We must use exists() as get_config_dict() will always return {} - even when an empty interface node like +macsec macsec1 { +} exists.
2020-09-22ifconfig: T2653: bond: bridge: ensure member interface is not a source-interfaceChristian Poessinger
As we already check that a bond/bridge member interface is not a member of any other bridge or bond, the check must be extended. We also need to ensure that the bond member interface is not used as a source-interface to pppoe, macsec, tunnel, pseudo-ethernet, vxlan interfaces.
2020-09-22ifconfig: T2653: move is_member() from vyos.vylidate to vyos.configdictChristian Poessinger
2020-09-20vyos.configdict: T2665: cleanup get_interface_dict() default dict handlingChristian Poessinger
2020-09-15vyos.configdict: T2515: leaf_node_changed() should return list or NoneChristian Poessinger
2020-08-31T2636: remove workarounds for get_config_dict()Christian Poessinger
Now that b40c52682a256 ("config: T2636: get_config_dict() returns a list on multi node by default") is implemented the workarounds can be removed.
2020-08-23T2755: convert jmespath.search() to vyos_dict_search() for performanceChristian Poessinger
2020-08-22dhcpv6-pd: T2677: optimize CLI interface for PD configurationChristian Poessinger
The current CLI did not support multiple prefix-delegations per interface. Some ISPs only send one /64 to a client per prefix-delegation request, but they allow the customer to request multiple prefixes. The 'dhcpv6-options prefix-delegation' node has been renamed and converted to a tag node named 'dhcpv6-options pd'. The tag node specifies a PD request (>=0). In the past the user needed to know what prefix will be assigned and required to calculate the sla-len by himself. The 'sla-len' node was dropped and is now calculated in the background from the 'dhcpv6-options pd 0 length' node. It is no longer mandatory to supply the 'sla-id' node, if sla-id is not specified it is 'guessed' by counting upwards. Example configuration: ---------------------- ethernet eth1 { address dhcpv6 dhcpv6-options { pd 0 { length 56 interface eth2 { address 1 } } } } This will request a /56 assignment from the ISP and will delegate a /64 network to interface eth2. VyOS will use the interface address ::1 on the delegate interface (eth2) as its local address.
2020-08-15vyos.configdict: keep is_member import as local as possibleChristian Poessinger
2020-07-25ifconfig: T2653: make ifname an optional argument to get_interface_dict()Christian Poessinger
Further reduce the boiler-plate code to determine interface tag node or not. It can be passed into get_interface_dict() if explicitly required - else it is taken from the environment.
2020-07-25vyos.configdict: T2653: remove obsolete code from configdict and ifconfig_vlanChristian Poessinger
After all interfaces have been moved to the targetted implementation of T2653 the old implementations of migrating a CLI session to a configuration dict can be dropped.
2020-07-25ifconfig: T2653: move get_ethertype() from configdict to interfaceChristian Poessinger
... as it is only used inside the interface class.
2020-07-25vlan: ifconfig: T2653: move get_removed_vlans() to vyos.configdiffChristian Poessinger
As we wrap up additional functions from this library it should be part of it.
2020-07-25vyos.configdict: T2653: use dict_merge() over update()Christian Poessinger
With dict.update() existing keys will get overwritten when blending in interface default values.
2020-07-25vyos.configdict: T2653: add new reusable helper node_changed()Christian Poessinger
This can be used to see if a tagNode has been changed. It will return a list of changed nodes.
2020-07-25bridge: ifconfig: T2653: move to get_config_dict()Christian Poessinger
The current VyOS CLI parser code written in Python contains a ton of duplicates which I can also hold myself accountable for - or maybe mainly me - depends on the angle of judge. While providing a new update() method in vyos.ifconfig.interfaces() this is extended for bridge interfaces in the derived bridge class. Signed-off-by: Christian Poessinger <christian@poessinger.com>
2020-07-25ethernet: ifconfig: T2653: move to get_config_dict()Christian Poessinger
The current VyOS CLI parser code written in Python contains a ton of duplicates which I can also hold myself accountable for - or maybe mainly me - depends on the angle of judge. While providing a new update() method in vyos.ifconfig.interfaces() this is extended for ethernet based interfaces which also supports 802.1q, 802.1ad VLANs. This commit migrates the existing codebase for an ethernet based interfaces and implements the missing parts for VLANs. Adding or migrating other interfaces (e.g. bridge or bond) will become much easier as they must reuse the entire functionality - we now walk towards a single codepath. Thanks for all who made this combined effort possible! Signed-off-by: Christian Poessinger <christian@poessinger.com>
2020-06-27ifconfig: T2653: move macsec interface to get_config_dict()Christian Poessinger
2020-06-26configdict: T2653: prevent recursive importsChristian Poessinger
2020-06-24dictconfig: T2637: identify sub-interfaces (vif) to deleteThomas Mangin
2020-06-18vyos: configdict: add dict_merge functionChristian Poessinger
Merge two dictionaries. Only keys which are not present in destination will be copied from source, anything else will be kept untouched. Function will return a new dict which has the merged key/value pairs. Before: {'device': {'usb0b2.4p1.0': {'speed': '9600'}, 'usb0b2.4p1.1': {'data-bits': '8', 'parity': 'none', 'speed': '115200', 'stop-bits': '2'}}} After: {'device': {'usb0b2.4p1.0': {'data-bits': '8', 'parity': 'none', 'speed': '9600', 'stop-bits': '1'}, 'usb0b2.4p1.1': {'data-bits': '8', 'parity': 'none', 'speed': '115200', 'stop-bits': '2'}}}
2020-06-06dhcpv6-pd: T2551: fixup configuration pathChristian Poessinger
Commit 728b1feaf744 ("dhcpv6-pd: T2551: fix prefix length not set in config") reworked the way the configuration path is accesses on the individual interfaces, but it was missed out to apply it correctly when reading in sla-len and sla-id values.
2020-06-06dhcpv6-pd: T2551: fix prefix length not set in configChristian Poessinger
Retrieving the CLI nodes from current config was missed out and only implemented for PPPoE.