summaryrefslogtreecommitdiffstats
path: root/ipaserver/install
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-01-21 07:40:42 -0500
committerMartin Kosek <mkosek@redhat.com>2013-03-01 16:59:45 +0100
commitf5c404c65d81d9a28f171fabe7c5749d6c37f102 (patch)
tree2144594e18108034898baf93780e37eb8bbe6027 /ipaserver/install
parent66eaf1220da3e3fccd54b8f6a54f7d116818b024 (diff)
downloadfreeipa-f5c404c65d81d9a28f171fabe7c5749d6c37f102.tar.gz
freeipa-f5c404c65d81d9a28f171fabe7c5749d6c37f102.tar.xz
freeipa-f5c404c65d81d9a28f171fabe7c5749d6c37f102.zip
Replace entry.getValue by entry.single_value
Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Diffstat (limited to 'ipaserver/install')
-rw-r--r--ipaserver/install/adtrustinstance.py16
-rw-r--r--ipaserver/install/dsinstance.py2
-rw-r--r--ipaserver/install/krbinstance.py10
-rw-r--r--ipaserver/install/ldapupdate.py4
-rw-r--r--ipaserver/install/plugins/fix_replica_agreements.py4
-rw-r--r--ipaserver/install/replication.py44
6 files changed, 41 insertions, 39 deletions
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index 9cc533b96..52534c19c 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -164,7 +164,7 @@ class ADTRUSTInstance(service.Service):
self.print_msg("Samba domain object not found")
return
- dom_sid = dom_entry.getValue(self.ATTR_SID)
+ dom_sid = dom_entry.single_value(self.ATTR_SID, None)
if not dom_sid:
self.print_msg("Samba domain object does not have a SID")
return
@@ -182,7 +182,7 @@ class ADTRUSTInstance(service.Service):
self.print_msg("IPA admin group object not found")
return
- if admin_entry.getValue(self.ATTR_SID):
+ if admin_entry.single_value(self.ATTR_SID, None):
self.print_msg("Admin SID already set, nothing to do")
else:
try:
@@ -192,7 +192,7 @@ class ADTRUSTInstance(service.Service):
except:
self.print_msg("Failed to modify IPA admin object")
- if admin_group_entry.getValue(self.ATTR_SID):
+ if admin_group_entry.single_value(self.ATTR_SID, None):
self.print_msg("Admin group SID already set, nothing to do")
else:
try:
@@ -224,7 +224,7 @@ class ADTRUSTInstance(service.Service):
self.print_msg("Samba domain object not found")
return
- if dom_entry.getValue(self.ATTR_FALLBACK_GROUP):
+ if dom_entry.single_value(self.ATTR_FALLBACK_GROUP, None):
self.print_msg("Fallback group already set, nothing to do")
return
@@ -269,12 +269,12 @@ class ADTRUSTInstance(service.Service):
"local domain.")
raise RuntimeError("Too many ID ranges\n")
- if res[0].getValue('ipaBaseRID') or \
- res[0].getValue('ipaSecondaryBaseRID'):
+ if res[0].single_value('ipaBaseRID', None) or \
+ res[0].single_value('ipaSecondaryBaseRID', None):
self.print_msg("RID bases already set, nothing to do")
return
- size = res[0].getValue('ipaIDRangeSize')
+ size = res[0].single_value('ipaIDRangeSize', None)
if abs(self.rid_base - self.secondary_rid_base) > size:
self.print_msg("Primary and secondary RID base are too close. " \
"They have to differ at least by %d." % size)
@@ -719,7 +719,7 @@ class ADTRUSTInstance(service.Service):
raise ValueError("No local ID range and no admins group found.\n" \
"Add local ID range manually and try again!")
- base_id = int(entry.getValue('gidNumber'))
+ base_id = int(entry.single_value('gidNumber'))
id_range_size = 200000
id_filter = "(&" \
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index 8ee492c4c..5e69f214b 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -833,7 +833,7 @@ class DsInstance(service.Service):
dn = DN(('cn', 'default'), ('ou', 'profile'), self.suffix)
try:
entry = self.admin_conn.getEntry(dn, ldap.SCOPE_BASE, '(objectclass=*)')
- srvlist = entry.getValue('defaultServerList', '')
+ srvlist = entry.single_value('defaultServerList', '')
srvlist = srvlist.split()
if not self.fqdn in srvlist:
srvlist.append(self.fqdn)
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index d3bee8f45..11cde1cac 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -127,11 +127,10 @@ class KrbInstance(service.Service):
managedby=[host_dn],
)
if 'krbpasswordexpiration' in service_entry.toDict():
- host_entry['krbpasswordexpiration'] = [
- service_entry.getValue('krbpasswordexpiration')]
+ host_entry['krbpasswordexpiration'] = service_entry[
+ 'krbpasswordexpiration']
if 'krbticketflags' in service_entry.toDict():
- host_entry['krbticketflags'] = [
- service_entry.getValue('krbticketflags')]
+ host_entry['krbticketflags'] = service_entry['krbticketflags']
self.admin_conn.addEntry(host_entry)
def __common_setup(self, realm_name, host_name, domain_name, admin_password):
@@ -366,7 +365,8 @@ class KrbInstance(service.Service):
root_logger.critical("Could not find master key in DS")
raise e
- krbMKey = pyasn1.codec.ber.decoder.decode(entry.getValue('krbmkey'))
+ krbMKey = pyasn1.codec.ber.decoder.decode(
+ entry.single_value('krbmkey', None))
keytype = int(krbMKey[0][1][0])
keydata = str(krbMKey[0][1][1])
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 55f0ecaf9..899e31fca 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -458,7 +458,7 @@ class LDAPUpdate:
self.error("Task lookup failure %s", e)
return
- status = entry.getValue('nstaskstatus')
+ status = entry.single_value('nstaskstatus', None)
if status is None:
# task doesn't have a status yet
time.sleep(1)
@@ -816,7 +816,7 @@ class LDAPUpdate:
if entry.dn.endswith(DN(('cn', 'index'), ('cn', 'userRoot'),
('cn', 'ldbm database'), ('cn', 'plugins'),
('cn', 'config'))) and (added or updated):
- taskid = self.create_index_task(entry.getValue('cn'))
+ taskid = self.create_index_task(entry.single_value('cn'))
self.monitor_index_task(taskid)
return
diff --git a/ipaserver/install/plugins/fix_replica_agreements.py b/ipaserver/install/plugins/fix_replica_agreements.py
index 9f2c24146..bbebbbc04 100644
--- a/ipaserver/install/plugins/fix_replica_agreements.py
+++ b/ipaserver/install/plugins/fix_replica_agreements.py
@@ -47,7 +47,7 @@ class update_replica_attribute_lists(PreUpdate):
entries = repl.find_replication_agreements()
self.log.debug("Found %d agreement(s)", len(entries))
for replica in entries:
- self.log.debug(replica.getValue('description'))
+ self.log.debug(replica.single_value('description', None))
self._update_attr(repl, replica,
'nsDS5ReplicatedAttributeList',
@@ -76,7 +76,7 @@ class update_replica_attribute_lists(PreUpdate):
:param values: List of values the attribute should hold
:param template: Template to use when adding attribute
"""
- attrlist = replica.getValue(attribute)
+ attrlist = replica.single_value(attribute, None)
if attrlist is None:
self.log.debug("Adding %s", attribute)
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index eaf4c4950..fcb6ca840 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -102,7 +102,7 @@ def enable_replication_version_checking(hostname, realm, dirman_passwd):
conn.do_sasl_gssapi_bind()
entry = conn.getEntry(DN(('cn', 'IPA Version Replication'), ('cn', 'plugins'), ('cn', 'config')),
ldap.SCOPE_BASE, 'objectclass=*')
- if entry.getValue('nsslapd-pluginenabled') == 'off':
+ if entry.single_value('nsslapd-pluginenabled', None) == 'off':
conn.modify_s(entry.dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginenabled', 'on')])
conn.unbind()
serverid = "-".join(realm.split("."))
@@ -124,8 +124,8 @@ def wait_for_task(conn, dn):
'nsTaskTotalItems']
while True:
entry = conn.get_entry(dn, attrlist)
- if entry.getValue('nsTaskExitCode'):
- exit_code = int(entry.getValue('nsTaskExitCode'))
+ if entry.single_value('nsTaskExitCode', None):
+ exit_code = int(entry.single_value('nsTaskExitCode'))
break
time.sleep(1)
return exit_code
@@ -183,8 +183,8 @@ class ReplicationManager(object):
except errors.NotFound:
pass
else:
- if replica.getValue('nsDS5ReplicaId'):
- return int(replica.getValue('nsDS5ReplicaId'))
+ if replica.single_value('nsDS5ReplicaId', None):
+ return int(replica.single_value('nsDS5ReplicaId'))
# Ok, either the entry doesn't exist or the attribute isn't set
# so get it from the other master
@@ -196,12 +196,12 @@ class ReplicationManager(object):
root_logger.debug("Unable to retrieve nsDS5ReplicaId from remote server")
raise
else:
- if replica.getValue('nsDS5ReplicaId') is None:
+ if replica.single_value('nsDS5ReplicaId', None) is None:
root_logger.debug("Unable to retrieve nsDS5ReplicaId from remote server")
raise RuntimeError("Unable to retrieve nsDS5ReplicaId from remote server")
# Now update the value on the master
- retval = int(replica.getValue('nsDS5ReplicaId'))
+ retval = int(replica.single_value('nsDS5ReplicaId'))
mod = [(ldap.MOD_REPLACE, 'nsDS5ReplicaId', str(retval + 1))]
try:
@@ -275,7 +275,7 @@ class ReplicationManager(object):
return res
for ent in ents:
- res.append(ent.getValue('nsds5replicahost'))
+ res.append(ent.single_value('nsds5replicahost', None))
return res
@@ -382,7 +382,7 @@ class ReplicationManager(object):
('cn', 'config'), ('cn', 'ldbm database'),
('cn', 'plugins'), ('cn', 'config')),
['nsslapd-directory'])
- dbdir = os.path.dirname(ent.getValue('nsslapd-directory'))
+ dbdir = os.path.dirname(ent.single_value('nsslapd-directory', None))
entry = conn.make_entry(
DN(('cn', 'changelog5'), ('cn', 'config')),
@@ -457,7 +457,7 @@ class ReplicationManager(object):
plgent = self.conn.getEntry(DN(('cn', 'Multimaster Replication Plugin'), ('cn', 'plugins'), ('cn', 'config')),
ldap.SCOPE_BASE, "(objectclass=*)", ['nsslapd-pluginPath'])
- path = plgent.getValue('nsslapd-pluginPath')
+ path = plgent.single_value('nsslapd-pluginPath', None)
mod = [(ldap.MOD_REPLACE, 'nsslapd-state', 'backend'),
(ldap.MOD_ADD, 'nsslapd-backend', bename),
@@ -757,9 +757,10 @@ class ReplicationManager(object):
print "Error reading status from agreement", agmtdn
hasError = 1
else:
- refresh = entry.getValue('nsds5BeginReplicaRefresh')
- inprogress = entry.getValue('nsds5replicaUpdateInProgress')
- status = entry.getValue('nsds5ReplicaLastInitStatus')
+ refresh = entry.single_value('nsds5BeginReplicaRefresh', None)
+ inprogress = entry.single_value('nsds5replicaUpdateInProgress',
+ None)
+ status = entry.single_value('nsds5ReplicaLastInitStatus', None)
if not refresh: # done - check status
if not status:
print "No status yet"
@@ -793,15 +794,16 @@ class ReplicationManager(object):
print "Error reading status from agreement", agmtdn
hasError = 1
else:
- inprogress = entry.getValue('nsds5replicaUpdateInProgress')
- status = entry.getValue('nsds5ReplicaLastUpdateStatus')
+ inprogress = entry.single_value('nsds5replicaUpdateInProgress',
+ None)
+ status = entry.single_value('nsds5ReplicaLastUpdateStatus', None)
try:
- start = int(entry.getValue('nsds5ReplicaLastUpdateStart'))
- except (ValueError, TypeError):
+ start = int(entry.single_value('nsds5ReplicaLastUpdateStart'))
+ except (ValueError, TypeError, KeyError):
start = 0
try:
- end = int(entry.getValue('nsds5ReplicaLastUpdateEnd'))
- except (ValueError, TypeError):
+ end = int(entry.single_value('nsds5ReplicaLastUpdateEnd'))
+ except (ValueError, TypeError, KeyError):
end = 0
# incremental update is done if inprogress is false and end >= start
done = inprogress and inprogress.lower() == 'false' and start <= end
@@ -1040,7 +1042,7 @@ class ReplicationManager(object):
root_logger.error("Using the first one only (%s)" % entries[0].dn)
dn = entries[0].dn
- schedule = entries[0].getValue('nsds5replicaupdateschedule')
+ schedule = entries[0].single_value('nsds5replicaupdateschedule', None)
# On the remote chance of a match. We force a synch to happen right
# now by setting the schedule to something and quickly removing it.
@@ -1159,7 +1161,7 @@ class ReplicationManager(object):
try:
dn = DN(('cn', 'default'), ('ou', 'profile'), self.suffix)
ret = self.conn.getEntry(dn, ldap.SCOPE_BASE, '(objectclass=*)')
- srvlist = ret.getValue('defaultServerList', '')
+ srvlist = ret.single_value('defaultServerList', '')
srvlist = srvlist[0].split()
if replica in srvlist:
srvlist.remove(replica)