Imported Upstream version 4.7.2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Authors:
|
||||
# Petr Viktorin <pviktori@redhat.com>
|
||||
@@ -19,13 +19,15 @@
|
||||
# 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 sys
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
|
||||
from ipalib.constants import FQDN
|
||||
from ipatests.test_integration import config
|
||||
from ipatests.pytest_ipa.integration import config, env_config
|
||||
|
||||
|
||||
def main(argv):
|
||||
@@ -92,7 +94,8 @@ def main(argv):
|
||||
import yaml
|
||||
return yaml.safe_dump(conf.to_dict(), default_flow_style=False)
|
||||
else:
|
||||
return config.env_to_script(get_object(conf, args).to_env(**kwargs))
|
||||
env = get_object(conf, args).to_env(**kwargs)
|
||||
return env_config.env_to_script(env)
|
||||
|
||||
|
||||
def get_object(conf, args):
|
||||
@@ -102,7 +105,7 @@ def get_object(conf, args):
|
||||
try:
|
||||
return conf.host_by_name(args.host)
|
||||
except LookupError:
|
||||
exit('Host %s not found in config. Try --global' % args.host)
|
||||
sys.exit('Host %s not found in config. Try --global' % args.host)
|
||||
else:
|
||||
if args.domain:
|
||||
try:
|
||||
@@ -110,18 +113,18 @@ def get_object(conf, args):
|
||||
except ValueError:
|
||||
domains = [d for d in conf.domains if d.name == args.domain]
|
||||
if not domains:
|
||||
exit('Domain %s not found' % args.domain)
|
||||
sys.exit('Domain %s not found' % args.domain)
|
||||
domain = domains[0]
|
||||
else:
|
||||
try:
|
||||
domain = conf.domains[num]
|
||||
except LookupError:
|
||||
exit('Domain %s not found.' % args.domain)
|
||||
sys.exit('Domain %s not found.' % args.domain)
|
||||
else:
|
||||
try:
|
||||
domain = conf.domains[0]
|
||||
except IndexError:
|
||||
exit('No domains are configured.')
|
||||
sys.exit('No domains are configured.')
|
||||
if args.master:
|
||||
return domain.master
|
||||
|
||||
@@ -130,27 +133,33 @@ def get_object(conf, args):
|
||||
try:
|
||||
return domain.replicas[args.replica]
|
||||
except LookupError:
|
||||
exit('Domain %s not found in domain %s' % (args.replica,
|
||||
domain.name))
|
||||
sys.exit(
|
||||
'Domain %s not found in domain %s'
|
||||
% (args.replica, domain.name)
|
||||
)
|
||||
|
||||
elif args.client:
|
||||
num = int(args.client) - 1
|
||||
try:
|
||||
return domain.replicas[args.client]
|
||||
except LookupError:
|
||||
exit('Client %s not found in domain %s' % (args.client,
|
||||
domain.name))
|
||||
sys.exit(
|
||||
'Client %s not found in domain %s'
|
||||
% (args.client, domain.name)
|
||||
)
|
||||
|
||||
elif args.role:
|
||||
try:
|
||||
return domain.get_host_by_role(args.role)
|
||||
except LookupError:
|
||||
exit('No host with role %s not found in domain %s'
|
||||
% (args.role, domain.name))
|
||||
sys.exit(
|
||||
'No host with role %s not found in domain %s'
|
||||
% (args.role, domain.name)
|
||||
)
|
||||
|
||||
else:
|
||||
return domain
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print main(sys.argv[1:]),
|
||||
print(main(sys.argv[1:]), end=' ')
|
||||
|
||||
Reference in New Issue
Block a user