Bug 1456595

Summary: ipa CLI does not check if machine is enrolled before attempting to contact IPA server
Product: Red Hat Enterprise Linux 7 Reporter: Sudhir Menon <sumenon>
Component: ipaAssignee: IPA Maintainers <ipa-maint>
Status: CLOSED DUPLICATE QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: fbarreto, frenaud, pvoborni, rcritten, tscherf
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-08 14:19:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sudhir Menon 2017-05-29 18:27:02 UTC
Description of problem: pa CLI does not check if machine is enrolled before attempting to contact IPA server


Version-Release number of selected component (if applicable):
ipa-server-4.5.0-13.el7.x86_64

How reproducible: Always

Steps to Reproduce:
1. Ensure that IPA server is not installed on a system
2. Now try to run the below command.

#ipa trust-add --type=ad ipaad2008r2.test --admin Administrator --password --two-way=True --server=zombie.ipaad2008r2.test


Actual results:
[root@autohv02 ~]# ipa trust-add --type=ad ipaad2008r2.test --admin Administrator --password --two-way=True --server=zombie.ipaad2008r2.test
ipa: ERROR: IOError: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ipalib/cli.py", line 1348, in run
    api.finalize()
  File "/usr/lib/python2.7/site-packages/ipalib/plugable.py", line 714, in finalize
    self.__do_if_not_done('load_plugins')
  File "/usr/lib/python2.7/site-packages/ipalib/plugable.py", line 421, in __do_if_not_done
    getattr(self, name)()
  File "/usr/lib/python2.7/site-packages/ipalib/plugable.py", line 592, in load_plugins
    for package in self.packages:
  File "/usr/lib/python2.7/site-packages/ipalib/__init__.py", line 948, in packages
    ipaclient.remote_plugins.get_package(self),
  File "/usr/lib/python2.7/site-packages/ipaclient/remote_plugins/__init__.py", line 126, in get_package
    plugins = schema.get_package(server_info, client)
  File "/usr/lib/python2.7/site-packages/ipaclient/remote_plugins/schema.py", line 534, in get_package
    schema = Schema(client)
  File "/usr/lib/python2.7/site-packages/ipaclient/remote_plugins/schema.py", line 385, in __init__
    fingerprint, ttl = self._fetch(client, ignore_cache=read_failed)
  File "/usr/lib/python2.7/site-packages/ipaclient/remote_plugins/schema.py", line 409, in _fetch
    schema = client.forward(u'schema', **kwargs)['result']
  File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 1096, in forward
    return self._call_command(command, params)
  File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 1077, in _call_command
    return command(*params)
  File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 1218, in _call
    return self.__request(name, args)
  File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 1185, in __request
    verbose=self.__verbose >= 3,
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 672, in single_request
    h = self.make_connection(host)
  File "/usr/lib/python2.7/site-packages/ipalib/rpc.py", line 549, in make_connection
    tls_version_max=api.env.tls_version_max)
  File "/usr/lib/python2.7/site-packages/ipalib/util.py", line 322, in create_https_connection
    ctx.load_verify_locations(cafile)
IOError: [Errno 2] No such file or directory
ipa: ERROR: an internal error has occurred

Expected results:
Fix the traceback with proper error message for e.g
"IPA is not configured on the system"


Additional info:

Comment 3 Petr Vobornik 2017-06-09 15:35:52 UTC
Upstream ticket:
https://pagure.io/freeipa/issue/7009

Comment 4 fbarreto 2017-06-13 19:03:30 UTC
When I run the command, I'm getting a different error:

[vagrant@localhost rpms]$ ipa trust-add --type=ad ipaad2008r2.test --admin Administrator --password --two-way=True --server=zombie.ipaad2008r2.test
ipa: ERROR: cannot connect to 'http://localhost:8888/ipa/json': [Errno 111] 
Connection refused

[vagrant@localhost ~]$ ipa --version
VERSION: 4.5.1, API_VERSION: 2.224

Sudhir, what do you mean by "Ensure that IPA server is not installed on a system"? It means that the client (or another component) is installed?

Comment 6 Florence Blanc-Renaud 2017-08-08 14:19:09 UTC
This issue is a duplicate of BZ 1368345 https://bugzilla.redhat.com/show_bug.cgi?id=1368345

*** This bug has been marked as a duplicate of bug 1368345 ***