Imported Upstream version 4.8.10
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Authors:
|
||||
# Petr Viktorin <pviktori@redhat.com>
|
||||
@@ -19,19 +19,25 @@
|
||||
# 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 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
|
||||
from ipapython.ipa_log_manager import standard_logging_setup
|
||||
from ipatests.pytest_ipa.integration import config
|
||||
from ipatests.pytest_ipa.integration import tasks
|
||||
from ipatests.pytest_ipa.integration.host import Host
|
||||
from ipatests.pytest_ipa.integration import collect_logs
|
||||
|
||||
try:
|
||||
from pytest_beakerlib import BeakerLibProcess
|
||||
except ImportError:
|
||||
BeakerLibProcess = None
|
||||
|
||||
log = log_mgr.get_logger(__name__)
|
||||
logger = logging.getLogger(os.path.basename(__file__))
|
||||
|
||||
|
||||
class TaskRunner(object):
|
||||
@@ -50,6 +56,9 @@ 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)')
|
||||
@@ -241,9 +250,11 @@ class TaskRunner(object):
|
||||
return parser
|
||||
|
||||
def main(self, argv):
|
||||
|
||||
args = self.get_parser().parse_args(argv)
|
||||
parser = self.get_parser()
|
||||
args = 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 = {}
|
||||
|
||||
@@ -253,6 +264,9 @@ 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
|
||||
|
||||
@@ -274,7 +288,7 @@ class TaskRunner(object):
|
||||
|
||||
try:
|
||||
return args.func(args)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if args.with_beakerlib:
|
||||
beakerlib_process.log_exception()
|
||||
beakerlib_process.run_beakerlib_command(
|
||||
@@ -282,8 +296,10 @@ 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)
|
||||
|
||||
@@ -317,36 +333,37 @@ class TaskRunner(object):
|
||||
|
||||
def install_master(self, args):
|
||||
master = self.get_host(args.host, default=args.domain.master)
|
||||
log.info('Installing master %s', master.hostname)
|
||||
logger.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)
|
||||
log.info('Installing replica %s from %s',
|
||||
replica.hostname, master.hostname)
|
||||
logger.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)
|
||||
log.info('Installing client %s on %s', client.hostname, master.hostname)
|
||||
logger.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)
|
||||
log.info('Uninstalling masters: %s', [h.hostname for h in hosts])
|
||||
logger.info('Uninstalling masters: %s', [h.hostname for h in hosts])
|
||||
for master in hosts:
|
||||
log.info('Uninstalling %s', master.hostname)
|
||||
logger.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)
|
||||
log.info('Uninstalling clients: %s', [h.hostname for h in hosts])
|
||||
logger.info('Uninstalling clients: %s', [h.hostname for h in hosts])
|
||||
for client in hosts:
|
||||
log.info('Uninstalling %s', client.hostname)
|
||||
logger.info('Uninstalling %s', client.hostname)
|
||||
tasks.uninstall_client(client)
|
||||
|
||||
def uninstall_all(self, args):
|
||||
@@ -356,9 +373,9 @@ class TaskRunner(object):
|
||||
def cleanup(self, args):
|
||||
default_hosts = args.domain.hosts
|
||||
hosts = self.get_hosts(args.host, default=default_hosts)
|
||||
log.info('Cleaning up hosts: %s', [h.hostname for h in hosts])
|
||||
logger.info('Cleaning up hosts: %s', [h.hostname for h in hosts])
|
||||
for host in hosts:
|
||||
log.info('Cleaning up %s', host.hostname)
|
||||
logger.info('Cleaning up %s', host.hostname)
|
||||
tasks.unapply_fixes(host)
|
||||
|
||||
def connect_replica(self, args):
|
||||
@@ -373,7 +390,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)
|
||||
@@ -386,7 +403,7 @@ class TaskRunner(object):
|
||||
|
||||
def install_adtrust(self, args):
|
||||
master = self.get_host(args.host, default=args.domain.master)
|
||||
log.info('Configuring AD trust support on %s', master.hostname)
|
||||
logger.info('Configuring AD trust support on %s', master.hostname)
|
||||
tasks.install_adtrust(master)
|
||||
|
||||
def configure_dns_for_trust(self, args):
|
||||
@@ -436,4 +453,4 @@ class TaskRunner(object):
|
||||
tasks.add_a_record(master, host)
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(TaskRunner().main(sys.argv[1:]))
|
||||
sys.exit(TaskRunner().main(sys.argv[1:]))
|
||||
|
||||
Reference in New Issue
Block a user