summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)Author
2020-07-25ifconfig: T2653: move bridge member check to base classChristian Poessinger
This test is reused by a lot of instances and thus must be moved to the base class.
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-25vlan: ifconfig: T2653: only enable interface when lower interface is upChristian Poessinger
A VLAN interface can only be placed in admin up state when the lower interface is up, too. If this is not the case the operating system will throw and exception.
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-07-25vyos.util: add common helper to load kernel modulesChristian Poessinger
l2tpv3, wireguard, wirelessmodem, nat all require additional Kernel modules to be present on the system. Each and every interface implemented their own way of loading a module - by copying code. Use a generic function, vyos.util.check_kmod() to load any arbitrary kernel module passed as string or list.
2020-07-22xml: T2582: use xml for is_tag and is_leafThomas Mangin
2020-07-22config: T2707: use ConfigSource and refactor Config methodsJohn Estabrook
2020-07-22config: T2707: add ConfigSource classes for alternative init dataJohn Estabrook
2020-07-19interface: T2519: add broadcast address when adding IPv4 addressesJernej Jakob
This adds the last IP of the subnet being added as the broadcast address. Example: adding 192.0.2.1/24 would yield: inet 192.0.2.1/24 brd 192.0.2.255 scope global dum0 Without this the broadcast address would be missing. Addidionally join two is_ipv4 calls into one.
2020-07-18configdiff: T2689: add configdiff classJohn Estabrook
The configdiff class provides: (1) An abstract representation of VyOS config state, for use in configuration mode scripts. (2) Methods to query the differences between the effective and session config.
2020-07-18vyos.ifconfig: T2673: Fix admin state if the mac address is changed for an ↵srividya0208
interface Changes are made in the interface.py script in order to bring the admin state to 'UP' after the mac is manually added in system config.The script is marking the interface from up to down state(as the MAC address can only be changed if interface is in 'down' state) but it is not bringing it up after the change
2020-07-17config: T2689: cache config_dictJohn Estabrook
This is a minor modification of the implementation by Thomas Mangin.
2020-07-15xml: T2588: defaults should return gracefully on key errorJohn Estabrook
2020-07-12snmp: T2687: replace 3rd party hash library with custom codeChristian Poessinger
The 3rd party library used for calculating the SNMP hashes in advance only worked for SHA and nod for MD5 as SHA was hardcoded [1]. The code has been replaced by a class-less implementation providing only the required functionality. [1]: https://github.com/TheMysteriousX/SNMPv3-Hash-Generator/issues/2
2020-07-12vyos.snmpv3_hashgen: add license textChristian Poessinger
2020-07-11snmp: T2687: precalculate snmpv3 encrypted keysChristian Poessinger
As of now when adding new credentials for any SNMPv3 user we submit the credential either plaintext or encrypted. A plaintext credential will be hashed by SNMPd in the background and then passed back into the CLI so it's not stored in cleartext. This feels like the wrong way in changing the CLI content with data produced by a 3rd party daemon which implements the service. It feels like the tail wiggles the entire dog. This should be changed in the following way: - After retrieving the plaintext password from CLI, use Python to hash the key in advance - Re-populate the encrypted key into the CLI and drop the plaintext one - Generate service configuration and continue startup of SNMPd This also fixes a race condition when SNMPd started up but not properly provided the hasehd keys in the configuration resulting in a ConfigurationError. Now as we also support binding SNMPd to a VRF this fixes a deadlock situation on bootup as we can only bind late to the VRF and require up to 5 restarts of the service - but the service will never start.
2020-07-05xml: T2582: rename xml tagsThomas Mangin
The current use of () does not allow to use found() Converting to [] like all other tags
2020-07-03config_dict: update docstringJohn Estabrook
2020-07-03config_dict: T2670: remove dependency on show_configJohn Estabrook
2020-07-03ntp: T2676: mive to get_config_dict()Christian Poessinger
2020-07-03vyos.template: T2676: add custom Jinja2 filter for IP handlingChristian Poessinger
NTP configuration file requires the IP address and a netmask for client subnets but the CLI will only provide a prefix based ntoation. Use custom, reusable JInja2 template to transform a CIDR based prefix into its address and netmask portion for IPv4 and IPv6. Jinja2 custom filters are regular python functions - thus they can be re-used directly when e.g. verifying the configuration in vyos-smoketests.
2020-07-01config_dict: T2668: move keyword arg get_first_key into get_sub_dictJohn Estabrook
2020-07-01config_dict: T2667: clarify docstringJohn Estabrook
2020-07-01config: T2667: add missing checkJohn Estabrook
2020-07-01Merge pull request #486 from jestabro/sub_dictChristian Poessinger
2020-07-01config: T2667: use get_sub_dict for get_config_dict(path, ...)John Estabrook
2020-07-01config: T2667: add utility function get_sub_dictJohn Estabrook
2020-07-01ifconfig: T2653: use better names for vyos.configverify functionsChristian Poessinger
2020-07-01ifconfig: T2653: move pppoe interface to get_config_dict()Christian Poessinger
2020-07-01Merge pull request #483 from runborg/frr-modChristian Poessinger
T2638: FRR: New framework for configuring FRR
2020-06-28T2638: FRR: New framework for configuring FRRRunar Borge
This commit adds the python module vyos.frr that support reading and modifying the frr cofiguration. Functions get_configuration() : Collects the configuration from FRR and returns it as a string reload_configuration() : uses frr-reload.py to activate a new configuration. The configuration applied will overwrite the current configuration. mark_configuration() : Does syntax check/validation and add "end" tags to the configuration The marked configuration will be returned as a string A syntax fault will render an Exception execute() : Execute a command inside vtysh configure() : Executes a command in vtysh config mode replace_section() / _replace_section() : Adds the ability to replace a section of frr code remove_section() : Removes the specified configuration block from the config For now this supports replacing complete config sub-blocks of configuration and selecting the daemon to replace inside. This should work for most daemons, but static routing will still be an issue because this is not a separate sub-config mode
2020-06-27xml: T2660: do replace - with _ for defaults when not flatteningThomas Mangin
2020-06-27xml: T2656: do not flatten dict by defaultChristian Poessinger
2020-06-27Merge branch 'T2656' of https://github.com/thomas-mangin/vyos-1x into currentChristian Poessinger
* 'T2656' of https://github.com/thomas-mangin/vyos-1x: xml: T2656: option to not flatten the default dict
2020-06-27xml: T2656: option to not flatten the default dictThomas Mangin
2020-06-27ifconfig: T2653: move macsec interface to get_config_dict()Christian Poessinger
2020-06-27ifconfig: T2653: add vyos.configverify.verify_source_interface() helperChristian Poessinger
2020-06-26ifconfig: T2653: add common vyos.configverify helpersChristian Poessinger
While moving towards a general interface abstraction based on get_config_dict() and the use of vyos.ifconfig.Interfaces().update() it also makes sense, to split out common verification code to a common util file - instead of duplicating the code, which is infact one of the main forces drivind this transition. vyos.configverify will hold common functions called via verify() from our src/conf_mode scripts so we do not need to copy/paste general verifications methods.
2020-06-26ifconfig: T2653: move loopback interface to get_config_dict()Christian Poessinger
2020-06-26ifconfig: T2653: move dummy interface to get_config_dict()Christian Poessinger
This changes the dummy interface implementation to make use of get_config_dict() and also implement a new vyos.ifconfig.Interface().update() function to gather all the scattered calls to update common interface configuration options. Derived classes of Interface() should extend update() to their needs for their special interface type - e.g. bond or bridge.
2020-06-26configdict: T2653: prevent recursive importsChristian Poessinger
2020-06-25xml: T2528: fix defaultsThomas Mangin
2020-06-25xml: T2528: fix to work with named tags (edit mode)Thomas Mangin
2020-06-25T2487: add an exception for the case when VRRP stats aren't available.Daniil Baturin
2020-06-24wireguard: T2632: add quotes when passing allowed-ipsChristian Poessinger
Commit 289f513 ("wireguard: T2632: support PSK on multiple peers") introduced a regression when multiple allowed-ips have been configured. They were not properly quoted when passing them down to the wg binary.
2020-06-24Merge pull request #474 from thomas-mangin/T2637Christian Poessinger
dictconfig: T2637: identify sub-interfaces (vif) to delete
2020-06-24dictconfig: T2637: identify sub-interfaces (vif) to deleteThomas Mangin
2020-06-24ifconfig: vxlan: T2629: append() takes exactly one argumentChristian Poessinger
Commit 9390988709 ("vxlan: T2629: fix multiple configuration issues") called append() on a list and passed two arguments which is invalid. Traceback (most recent call last): File "/usr/libexec/vyos/conf_mode/interfaces-vxlan.py", line 300, in <module> apply(c) File "/usr/libexec/vyos/conf_mode/interfaces-vxlan.py", line 245, in apply v = VXLANIf(vxlan['intf'], **conf) File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 221, in __init__ self._create() File "/usr/lib/python3/dist-packages/vyos/ifconfig/vxlan.py", line 84, in _create cmdline.append('group', 'src_interface') TypeError: append() takes exactly one argument (2 given)
2020-06-23Merge pull request #473 from thomas-mangin/T2630Christian Poessinger
validation: T2630: bound to interface mtu if available
2020-06-23validation: T2630: bound to interface mtu if availableThomas Mangin