Imported Upstream version 4.0.5

This commit is contained in:
Mario Fetka
2021-07-25 07:50:50 +02:00
parent 8ff3be4216
commit 3bfaa6e020
2049 changed files with 317193 additions and 1632423 deletions

View File

@@ -19,25 +19,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import logging
import sys
import os
import argparse
from ipapython.ipa_log_manager import standard_logging_setup
from ipatests.pytest_plugins.integration import config
from ipatests.pytest_plugins.integration import tasks
from ipatests.pytest_plugins.integration.host import Host
from ipatests.pytest_plugins.integration import collect_logs
from ipapython.ipa_log_manager import log_mgr, standard_logging_setup
from ipatests.test_integration import config
from ipatests.test_integration import tasks
from ipatests.test_integration.host import Host
from ipatests.beakerlib_plugin import BeakerLibProcess
try:
from pytest_beakerlib import BeakerLibProcess
except ImportError:
BeakerLibProcess = None
logger = logging.getLogger(os.path.basename(__file__))
log = log_mgr.get_logger(__name__)
class TaskRunner(object):
@@ -56,9 +50,6 @@ class TaskRunner(object):
help="""Issue BeakerLib commands for logging
and log collection""")
parser.add_argument('--logfile-dir', dest='logfile_dir',
help="""Directory to collect logs in""")
subparsers = parser.add_subparsers(
metavar='SUBCOMMAND',
help='The action to perform (* indicates an idempotent operation)')
@@ -250,11 +241,9 @@ class TaskRunner(object):
return parser
def main(self, argv):
parser = self.get_parser()
args = parser.parse_args(argv)
args = self.get_parser().parse_args(argv)
self.config = config.Config.from_env(os.environ)
if not self.config:
raise EnvironmentError('Multihost environment not configured')
logs_to_collect = {}
@@ -264,9 +253,6 @@ class TaskRunner(object):
self.collect_log = collect_log
if args.with_beakerlib:
if BeakerLibProcess is None:
parser.error(
'pytest_beakerlib not installed, cannot use BeakerLib')
beakerlib_process = BeakerLibProcess()
args.verbose = True
@@ -288,7 +274,7 @@ class TaskRunner(object):
try:
return args.func(args)
except Exception as e:
except Exception, e:
if args.with_beakerlib:
beakerlib_process.log_exception()
beakerlib_process.run_beakerlib_command(
@@ -296,10 +282,8 @@ class TaskRunner(object):
raise
finally:
if args.with_beakerlib:
collect_logs('ipa-test-task', logs_to_collect,
logfile_dir=args.logfile_dir,
beakerlib_plugin=beakerlib_process)
beakerlib_process.end()
beakerlib_process.collect_logs(logs_to_collect)
for host in self._prepared_hosts:
host.remove_log_collector(self.collect_log)
@@ -333,37 +317,36 @@ class TaskRunner(object):
def install_master(self, args):
master = self.get_host(args.host, default=args.domain.master)
logger.info('Installing master %s', master.hostname)
log.info('Installing master %s', master.hostname)
tasks.install_master(master)
def install_replica(self, args):
replica = self.get_host(args.replica)
master = self.get_host(args.master, default=args.domain.master)
logger.info('Installing replica %s from %s',
replica.hostname, master.hostname)
log.info('Installing replica %s from %s',
replica.hostname, master.hostname)
tasks.install_replica(master, replica)
def install_client(self, args):
client = self.get_host(args.client)
master = self.get_host(args.master, default=args.domain.master)
logger.info('Installing client %s on %s',
client.hostname, master.hostname)
log.info('Installing client %s on %s', client.hostname, master.hostname)
tasks.install_client(master, client)
def uninstall_master(self, args):
default_hosts = [args.domain.master] + args.domain.replicas
hosts = self.get_hosts(args.host, default=default_hosts)
logger.info('Uninstalling masters: %s', [h.hostname for h in hosts])
log.info('Uninstalling masters: %s', [h.hostname for h in hosts])
for master in hosts:
logger.info('Uninstalling %s', master.hostname)
log.info('Uninstalling %s', master.hostname)
tasks.uninstall_master(master)
def uninstall_client(self, args):
default_hosts = args.domain.clients
hosts = self.get_hosts(args.host, default=default_hosts)
logger.info('Uninstalling clients: %s', [h.hostname for h in hosts])
log.info('Uninstalling clients: %s', [h.hostname for h in hosts])
for client in hosts:
logger.info('Uninstalling %s', client.hostname)
log.info('Uninstalling %s', client.hostname)
tasks.uninstall_client(client)
def uninstall_all(self, args):
@@ -373,9 +356,9 @@ class TaskRunner(object):
def cleanup(self, args):
default_hosts = args.domain.hosts
hosts = self.get_hosts(args.host, default=default_hosts)
logger.info('Cleaning up hosts: %s', [h.hostname for h in hosts])
log.info('Cleaning up hosts: %s', [h.hostname for h in hosts])
for host in hosts:
logger.info('Cleaning up %s', host.hostname)
log.info('Cleaning up %s', host.hostname)
tasks.unapply_fixes(host)
def connect_replica(self, args):
@@ -390,7 +373,7 @@ class TaskRunner(object):
def list_topos(self, args):
for name, topo in tasks.topologies.items():
print('%s: %s' % (name, topo.__doc__))
print '%s: %s' % (name, topo.__doc__)
def install_topo(self, args):
master = self.get_host(args.master, default=args.domain.master)
@@ -403,7 +386,7 @@ class TaskRunner(object):
def install_adtrust(self, args):
master = self.get_host(args.host, default=args.domain.master)
logger.info('Configuring AD trust support on %s', master.hostname)
log.info('Configuring AD trust support on %s', master.hostname)
tasks.install_adtrust(master)
def configure_dns_for_trust(self, args):