summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)Author
2020-07-26wireguard: 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.
2020-07-26vxlan: ifconfig: T2653: move to get_interface_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.
2020-07-25vyos.configverify: T2653: fix some formatting issuesChristian 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-25bonding: 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.
2020-07-25ifconfig: T2653: move vlan configuration code to base classChristian Poessinger
This is required as other interfaces (e.g. pseudo-ethernet or bond) will have VLANs, too.
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-25ifconfig: T2653: implement update() in derived classes for admin up/downChristian Poessinger
Every derived class must implement update() to set the interfaces admin up/down state. This is required to prevend extensive link flaps when e.g. reconfiguring bond interfaces.
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-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.