1a394c6 ipatests: add utility for managing domain name resolvers

Authored and Committed by sorlov 3 years ago
    ipatests: add utility for managing domain name resolvers
    
    Many test scenarios need to configure resolvers on test machines. Most
    notable patterns are:
    
    * using IPA master as DNS resolver on clients and replicas
    * intentionally breaking name resolution
    
    Now it is done by directly editing /etc/resolv.conf file. While being
    simple this approach has following issues:
    
    * NetworkManager restores this file periodically and on specific events
    * This is not how users are expected to manage resolvers on modern
      systems with NetworkManager and systemd-resolved.
    
    This patch introduces three classes for main types of resolvers management:
    * plain file
    * NetworkManager
    * systemd-resolved
    
    For each resolver manager the native way of configuring of nameserves is
    used: direct editing for /etc/resolv.conf or drop-in config files for
    NM and resolved.
    
    The type of resolver is automatically detected for each host and an
    appropriate instance is added to Host object.
    
    The Resolver class (and it's subclasses) provide convenience functions
    for changing nameservers and restoring the original config.
    During all operations (backup, modify, restore) it checks that resolver
    configuration has not been altered unexpectedly and raises exception if it
    was. This helps to detect unexpected changes in resolvers.
    
    Related to https://pagure.io/freeipa/issue/8703
    
    Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>