|
26 | 26 | import logging |
27 | 27 | import ldap |
28 | 28 | import dns.resolver |
29 | | -import re |
30 | 29 |
|
31 | 30 |
|
32 | 31 | class FreeIPAServer(object): |
@@ -57,25 +56,14 @@ def __init__(self, host, domain, binddn, bindpw): |
57 | 56 | self._bindpw = bindpw |
58 | 57 | self._domain = domain |
59 | 58 | self._url = 'ldaps://' + host |
60 | | - self.hostname_short = host |
61 | | - |
| 59 | + self.hostname_short = host.replace('.%s' % domain, '') |
62 | 60 | self._conn = self._get_conn() |
63 | 61 |
|
64 | 62 | if not self._conn: |
65 | 63 | return |
66 | 64 |
|
67 | | - if re.match('^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$', host): |
68 | | - self._log.debug("IP %s supplied as host's address" % host) |
69 | | - self._fqdn = self._get_fqdn() |
70 | | - self.hostname_short = self._fqdn.partition('.')[0] |
71 | | - elif '.' not in host: |
72 | | - self._log.debug("Short hostname %s supplied as host's address" % host) |
73 | | - self._fqdn = self._get_fqdn() |
74 | | - self.hostname_short = host |
75 | | - else: |
76 | | - self._log.debug("FQDN supplied as host's address") |
77 | | - self._fqdn = host |
78 | | - self.hostname_short = host.partition('.')[0] |
| 65 | + self._fqdn = self._get_fqdn() |
| 66 | + self.hostname_short = self._fqdn.replace('.%s' % domain, '') |
79 | 67 |
|
80 | 68 | self._log.debug('FQDN: %s, short hostname: %s' % (self._fqdn, self.hostname_short)) |
81 | 69 |
|
@@ -256,8 +244,8 @@ def _count_services(self): |
256 | 244 | def _count_netgroups(self): |
257 | 245 | self._log.debug('Counting netgroups...') |
258 | 246 | results = self._search( |
259 | | - 'cn=ng,cn=compat,%s' % self._base_dn, |
260 | | - '(cn=*)', |
| 247 | + 'cn=ng,cn=alt,%s' % self._base_dn, |
| 248 | + '(ipaUniqueID=*)', |
261 | 249 | ['dn'], |
262 | 250 | scope=ldap.SCOPE_ONELEVEL |
263 | 251 | ) |
@@ -423,10 +411,10 @@ def _replication_agreements(self): |
423 | 411 | for result in results: |
424 | 412 | dn, attrs = result |
425 | 413 | host = attrs['nsDS5ReplicaHost'][0].decode('utf-8') |
426 | | - host = host.partition('.')[0] |
| 414 | + host = host.replace('.%s' % self._domain, '') |
427 | 415 | status = attrs['nsds5replicaLastUpdateStatus'][0].decode('utf-8') |
428 | 416 | status = status.replace('Error ', '').partition(' ')[0].strip('()') |
429 | | - if status != '0': |
| 417 | + if status not in ['0']: |
430 | 418 | healthy = False |
431 | 419 | msg.append('%s %s' % (host, status)) |
432 | 420 |
|
|
0 commit comments