This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master
in repository lib389.
commit ca2fdc57b001c5df47198ff2baf9d7a4cd8c4d76
Author: Ilias Stamatis <stamatis.iliass(a)gmail.com>
Date: Wed Apr 19 13:29:45 2017 +0300
Ticket 23 - Use DirSrv.exists() instead of manually checking for instance's
existence
Description: Manual instance existence checks can be replaced by calls
to DirSrv.exists().
https://pagure.io/lib389/issue/23
Author: Ilias95
Review by: wibrown (Thanks for the patch!)
---
lib389/__init__.py | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/lib389/__init__.py b/lib389/__init__.py
index e048f79..44ff322 100644
--- a/lib389/__init__.py
+++ b/lib389/__init__.py
@@ -917,11 +917,9 @@ class DirSrv(SimpleLDAPObject, object):
raise ValueError("invalid state for calling create: %s" %
self.state)
- # Check that the instance does not already exist
- props = self.list()
- if len(props) != 0:
+ if self.exists():
raise ValueError("Error it already exists the instance (%s)" %
- props[0][CONF_INST_DIR])
+ self.list()[0][CONF_INST_DIR])
if not self.serverid:
raise ValueError("SER_SERVERID_PROP is missing, " +
@@ -939,9 +937,8 @@ class DirSrv(SimpleLDAPObject, object):
self._createDirsrv()
# Retrieve sroot from the sys/priv config file
- props = self.list()
- assert len(props) == 1
- self.sroot = props[0][CONF_SERVER_DIR]
+ assert(self.exists())
+ self.sroot = self.list()[0][CONF_SERVER_DIR]
# Now the instance is created but DirSrv is not yet connected to it
self.state = DIRSRV_STATE_OFFLINE
@@ -964,9 +961,7 @@ class DirSrv(SimpleLDAPObject, object):
if self.state == DIRSRV_STATE_ONLINE:
self.close()
- # Check that the instance does not already exist
- props = self.list()
- if len(props) != 1:
+ if not self.exists():
raise ValueError("Error can not find instance %s[%s:%d]" %
(self.serverid, self.host, self.port))
@@ -1532,8 +1527,7 @@ class DirSrv(SimpleLDAPObject, object):
@raise None
'''
- props = self.list()
- return len(props) == 1
+ return len(self.list()) == 1
def toLDAPURL(self):
"""Return the uri ldap[s]://host:[ssl]port."""
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.