#23 Use DirSrv.exists() instead of manually checking for instance's existance
Closed: Fixed Opened by ilias95.

We have implemented an exists() method in the DirSrv class to check wether an instance exists or not, but instead of using it, we have manual checks in a few places. Let's not repeat ourselfs and replace this code.

NOTICE:
There's this line that checks len(props) against 0 instead of 1.
https://pagure.io/lib389/blob/master/f/lib389/init.py#_922

Can this be safely replaced by a call to exists()?

Also, I replaced this:

props = self.list()
assert len(props) == 1
self.sroot = props[0][CONF_SERVER_DIR]

With this:

assert self.exists()
self.sroot = self.list()[0][CONF_SERVER_DIR]

While logically equivalent, with the second one we have 2 calls to self.list().

Thoughts on all this?

0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch


I think this looks okay myself. Have you run the tests with it?

Metadata Update from @ilias95:
- Issue assigned to ilias95

Yes, I have run the tests and they all pass except for some errors and failures that I had anyway due to other bugs. I also attach a new patch implementing the change I mentioned in the notice. The tests again pass.
0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch

Metadata Update from @ilias95:
- Custom field Review Status adjusted to review

Sorry, I had a typo in the commit message. Fixed.

0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch

Looks good to me! Thanks for the improvement.

commit ca2fdc57b001c5df47198ff2baf9d7a4cd8c4d76
To ssh://git@pagure.io/lib389.git
de3d644..ca2fdc5 master -> master

Metadata Update from @firstyear:
- Custom field Review Status adjusted to ack (was: review)
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

Metadata