summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
AgeCommit message (Collapse)Author
2021-11-18wwan: T3795: make connect and disconnect op-mode commands aware to WWAN ↵Christian Poessinger
interfaces
2021-09-20vyos.util: add is_systemd_service_active() helper functionChristian Poessinger
Required by the vyos.ifconfig library - backported from 1.4 (current)
2021-09-06vyos.util: T2755: rename dict_search() function args to match other ↵Christian Poessinger
implementations (cherry picked from commit 9d0c37fbbc91acc9f2c0f2abaab360479e451f0f)
2021-08-14vyos.util: T1503: use build in methods to determine current user for ↵Christian Poessinger
commit_in_progress() (cherry picked from commit a74e67a778a6c698e44cbc6c5d184d03c9c12396)
2021-08-09openconnect: T3695: Add systemd service checker on commitDmitriyEshenko
2021-07-25vyos.util: backport 1.4 changes on dict_search()Christian Poessinger
2021-07-13T3663: add a small sleep between polling for a new inotify event.Daniil Baturin
2021-07-13vyos.util: T3663: move inotify-based imports to function levelChristian Poessinger
Keep the vyos.util function clean and not pull in the rest of the world when importing it.
2021-07-13T3663: add pre_hook argument to util.wait_for_inotifyDaniil Baturin
When waiting for processes that don't take long, we need add an inotify watcher _before_ starting that process. The pre-hook arguments allows the user to pass a () -> () anonymous function to be called before adding a watch.
2021-07-13T3663: fix the call to time.time() to match the new import scheme.Daniil Baturin
2021-07-13T3663: prerequisites for inotify-based watching implementations.Daniil Baturin
2021-05-20vyos.util: T3532: Replace func get_interface_configViacheslav Hletenko
Replace function get_interface_config to function get_interface_config, as we have in 1.4 branch. It need after this cherry-picked commit edcdea8
2021-05-18revert: "util: T2467: add autosudo as an option to command"Christian Poessinger
Implementing a wrapper which will - based on the command - add a sudo prefix to the execution string seemed to be a nice idea but unfortunately it did not only not get momentum but also the codebase somethis added an implicit "sudo" call a second time. This resulted in a call: "sudo sudo systemctl" The entire functionality was removed again and if an op-mode script requires root priviledges it must be explicitly called with them - no black magic. (cherry picked from commit b76931e6d3a4bd0cdb74ca447a746ab6855fcf55)
2021-04-18config: T3481: add switch to prevent mangling of tag node valuesJohn Estabrook
(cherry picked from commit e96932cbd99f508f9f5c24b207b5650aa8817e45)
2021-03-06vyos.util: provide single implementation for get_json_iface_options()Christian Poessinger
There had been four implementations of "ip -d -j link show interface" scattered accross the codebase. Those implementations have now been combined into a new helper: vyos.util.get_json_iface_options() (cherry picked from commit f13cc56d665a91ff3fac47df260301afefb1a3a5)
2021-01-31vyos: T3274: Handle EOF in ask_yes_no()erkin
(cherry picked from commit 55c5d662290aea9f2c3abe911bd9920f4f9d7d9a)
2021-01-07login: radius: T3192: migrate to get_config_dict()Christian Poessinger
2020-12-28webproxy: T563: squidguard: support default rulesetChristian Poessinger
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-24vyos.util: drop obsolete function ifname_from_config()Christian Poessinger
2020-10-24vyos.util: drop obsolete function get_bridge_member_config()Christian Poessinger
2020-10-19unittests: T2995: vyos_dict_search() must return None on non-existing keysChristian Poessinger
The current wversion unfortunately will raise a KeyError: >>> data = {} >>> vyos_dict_search('foo', data) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3/dist-packages/vyos/util.py", line 685, in vyos_dict_search return dict[path] KeyError: 'foo'
2020-09-13vyos.util: add missing ConfigError import in check_kmod()Christian Poessinger
2020-08-23T2755: convert jmespath.search() to vyos_dict_search() for performanceChristian Poessinger
2020-08-23vyos.util: T2755: add vyos_dict_search() to traverse a dictionaryChristian Poessinger
This is faster implementation then using jmespath.search('foo.bar', dict).
2020-08-16Merge pull request #510 from efficiosoft/vyos_template_rewriteChristian Poessinger
vyos.template: T2720: Rework vyos.template Python library
2020-08-15lcd: T2564: flatten CLI interfaceChristian Poessinger
* set system lcd device <device> * set system lcd model <modeml> Both device and model have completion helpers for supported interfaces and LCD displays.
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-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-21vyos.util: T2720: Add file descriptor support to chmod and chownRobert Schindler
Extended the chmod() and chown() functions in vyos.util to also operate on open file descriptors in addition to paths. This allows code that creates files to quickly change mode and owner even before anything has actually been written to the file.
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 utility function get_sub_dictJohn Estabrook
2020-06-18T2614: add a key mangling option to vyos.config.get_config_dict()Daniil Baturin
2020-05-20util: T2467: fix missing importThomas Mangin
2020-05-19util: T2467: add systemctl to autosudoThomas Mangin
2020-05-19util: T2467: add autosudo as an option to commandThomas Mangin
2020-05-06validator: T2417: try to make the code clearerThomas Mangin
2020-05-04util: T2241: add get_bridge_member_config functionJernej Jakob
Function that parses the config of a bridge member into a dict that is needed to apply all port config when adding a port to a bridge. Needed because other interfaces will be adding themselves to the bridge outside of the bridge conf_mode script and they need a common place to get their config. Can't be put as method of BridgeIf as we can't invoke it without it creating the bridge (create=False raises an exception), we need to get the configuration before we create the interface.
2020-05-04util: T2241: add func that gets interface name from current config levelJernej Jakob
2020-04-27template: T2388: fix typoJohn Estabrook
2020-04-27Merge pull request #381 from thomas-mangin/T2388Christian Poessinger
template: T2388: move mkdir/chmod/chown within render()
2020-04-27template: T2388: move mkdir/chmod/chown within render()Thomas Mangin
2020-04-26util: T2226: a way to report noteworthy eventThomas Mangin
debug.noteworthy can be used to record noteworhy event during the lifetime of the program. Should anything then cause the program to fail and cause an airbag report to the user, then this information will also be included.
2020-04-26util: T2226: expected return code for cmdThomas Mangin
add an option to cmd() allowing to define a list of error codes which are expected when runnin the command. the default is only to expect zero (no error).
2020-04-26util: T2226: better handle stderrThomas Mangin
Do not agreggate stderr with stdout. So if a command reports a message on stderr but does not report an error, it will not be send to the user to confuse him. Explicitely set encoding to utf-8, which does not change the code behaviour but simplify the code.
2020-04-22Merge pull request #360 from thomas-mangin/T2186-syslogChristian Poessinger
airbag: T2186: generic syslog and better text
2020-04-20vyos.util: T2347: call will print output only if non-emptyJohn Estabrook
2020-04-20airbag: T2186: improve information reportedThomas Mangin
2020-04-19bridge: T2232: move helper to vyos.validateChristian Poessinger