tbot_contrib.utils
¶
Various testcases.
- tbot_contrib.utils.ensure_sd_unit(lnx: LinuxShell, services: List[str]) None [source]¶
check if all systemd services in list services run on linux machine lnx. If not, try to start them.
- Parameters
lnx – linux shell
services – list of systemd services
New in version 0.8.3.
- tbot_contrib.utils.find_ip_address(lnx: LinuxShell, route_target: Optional[str] = None, force: bool = False) str [source]¶
Find out an IP-address of a host.
In times where most hosts have many IP addresses, this is not as trivial as one would like. This testcase approaches the problem by trying to find the IP-address, the host would use on a certain route.
By default, this is the route to reach a theoretical host at
1.0.0.0
. This will yield a sensible result in most cases but of course will not always be the address you want. For more fine-grained control you can pass aroute_target
. This is the IP-address of this theoretical host to reach.- Parameters
lnx (linux.LinuxShell) – The host to work on.
route_target (str) – An optional route target. Defaults to
1.0.0.0
.force (bool) – By default, this testcase caches results for faster lookup when called multiple times. This parameter enforces a re-check which might be useful when the network configuration on
lnx
changed.
- Return type
- Returns
The IP-address which was found.
New in version 0.8.3.
Changed in version 0.9.2: Fixed
find_ip_address()
not working properly when the route target is a local address.
- tbot_contrib.utils.hashcmp(a: Path, b: Path) bool [source]¶
Compare the hashsum of two files (potentially from different hosts).
hashcmp()
automatically selects a hash-summing tool which is available on both hosts and uses it to compare the checksum of the two files. It returnsTrue
if they match andFalse
otherwise. If one of the files does not exist,False
is returned.New in version 0.9.2.