<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<br>
<div class="moz-cite-prefix">On 29.01.2016 08:42, Stanislav Laznicka
wrote:<br>
</div>
<blockquote cite="mid:56AB17E8.4060804@redhat.com" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
On 01/26/2016 06:56 PM, Martin Basti wrote:<br>
<blockquote cite="mid:56A7B365.6090608@redhat.com" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<br>
<br>
<div class="moz-cite-prefix">On 25.01.2016 16:41, Stanislav
Laznicka wrote:<br>
</div>
<blockquote cite="mid:56A64223.4030809@redhat.com" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
Hi,<br>
<br>
Worked those comments into the code. Also added a bit
different info message in clean_ruv with ca=True
(ipa-replica-manage:430).<br>
<br>
Also adding stepst to reproduce:<br>
1. Create a master and some replica (3 replicas is a good
solution - 1 with CA, 1 without, 1 to be dangling (with CA))<br>
2. Change domain level to 0 and ipactl restart<br>
3. Remove the "dangling-to-be" replica from masters.ipa.etc
and from both ipaca and domain subtrees in mapping tree.config<br>
4. Try to remove the dangling ruvs with the command<br>
<br>
Cheers,<br>
Standa<br>
<br>
<br>
<div class="moz-cite-prefix">On 01/22/2016 01:22 PM, Martin
Basti wrote:<br>
</div>
<blockquote cite="mid:56A21F17.40406@redhat.com" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
Hello,<br>
<br>
I have a few comments<br>
<br>
PATCH Automatically detect and remove dangling RUVs<br>
<br>
1)<br>
+ # get the Directory Manager password<br>
+ if options.dirman_passwd:<br>
+ dirman_passwd = options.dirman_passwd<br>
+ else:<br>
+ dirman_passwd =
installutils.read_password('Directory Manager',<br>
+ confirm=False, validate=False, retry=False)<br>
+ if dirman_passwd is None:<br>
+ sys.exit('Directory Manager password is
required')<br>
+<br>
+ options.dirman_passwd = dirman_passwd<br>
<br>
IMO you need only else branch here<br>
<br>
if not options.dirman_password:<br>
dirman_passwd =
installutils.read_password('Directory Manager',<br>
confirm=False, validate=False, retry=False)<br>
if dirman_passwd is None:<br>
sys.exit('Directory Manager password is
required')<br>
options.dirman_passwd = dirman_passwd<br>
<br>
<br>
2)<br>
We should use new formatting in new code (more times in
code)<br>
<br>
+ sys.exit(<br>
+ "Failed to get data from '%s' while trying to
list replicas: %s" %<br>
+ (host, e)<br>
+ )<br>
<br>
sys.exit(<br>
"Failed to get data from '{host}' while trying
to list replicas: {e}".format(<br>
host=host, e=e<br>
)<br>
)<br>
<br>
3)<br>
+ # get all masters<br>
+ masters_dn = DN(('cn', 'masters'), ('cn', 'ipa'),
('cn', 'etc'),<br>
+ ipautil.realm_to_suffix(realm))<br>
<br>
IMO you should use constants:<br>
masters_dn = DN(api.env.container_masters, api.env.basedn)<br>
<br>
4)<br>
+ # Get realm string for config tree<br>
+ s = realm.split('.')<br>
+ s = ['dc={dc},'.format(dc=x.lower()) for x in s]<br>
+ realm_config = DN(('cn', ''.join(s)[0:-1]))<br>
<br>
Can be api.env.basedn used instead of this block of code?<br>
<br>
5)<br>
+ masters = [x.single_value['cn'] for x in masters]<br>
....<br>
+ for master in masters:<br>
<br>
is there any reason why not iterate over the keys in info
dict?<br>
<br>
for master_name, master_data/values/whatever in
info.items():<br>
master_data['online'] = True<br>
<br>
Looks better than: info[master]['online'] = True<br>
<br>
6)<br>
I asked python gurus, for empty lists and dicts, please use
[] and {} instead of list() and dict()<br>
It is preferred and faster.<br>
<br>
7)<br>
+ if(info[master]['ca']):<br>
+ entry = conn.get_entry(csreplica_dn)<br>
+ csruv = (master,
entry.single_value.get('nsDS5ReplicaID'))<br>
+ if csruv not in csruvs:<br>
+ csruvs.append(csruv)<br>
<br>
I dont like too much adding tuples into list and then doing
search there, but it is as designed<br>
<br>
However can you use set() instead of list when the purpose
of variable is only testing existence?<br>
<br>
related to:<br>
csruvs<br>
ruvs<br>
offlines<br>
clean_list<br>
cleaned<br>
<br>
8)<br>
conn in finally block may be undefined<br>
<br>
9)<br>
unused local variables<br>
<br>
clean_list<br>
entry on line 570<br>
<br>
10)<br>
optional, comment what keys means in info structure<br>
<br>
</blockquote>
<br>
</blockquote>
Hello,<br>
<br>
1)<br>
I accept your silence as the following code cannot use nothing
from api.env<br>
+ # Get realm string for config tree<br>
+ s = realm.split('.')<br>
+ s = ['dc={dc},'.format(dc=x.lower()) for x in s]<br>
+ realm_config = DN(('cn', ''.join(s)[0:-1]))<br>
<br>
but then please use:<br>
s = ['dc={dc}'.format(dc=x.lower()) for x in s]<br>
realm_config = DN(('cn', ','.join(s)))<br>
<br>
But I still think that api.env.basedn can be used, because it
contains the same format as you need<br>
realm_config = DN(('cn', api.env.basedn))<br>
<br>
</blockquote>
Sorry, forgot to mention that in the last email. However, turns
out you are right. I didn't think DN works like this but it does,
so this is now in it.<br>
<blockquote cite="mid:56A7B365.6090608@redhat.com" type="cite"> 2)
nitpick<br>
ca_dn = DN(('cn', 'ca'), DN(master.dn))<br>
<br>
AFAIK can be just<br>
<br>
ca_dn = DN(('cn', 'ca'), master.dn)<br>
<br>
</blockquote>
My bad, fixed.<br>
<blockquote cite="mid:56A7B365.6090608@redhat.com" type="cite"> 3)
uber nitpick<br>
This is PEP8 valid, but somehow inconsistent with the rest of
code and it hit my eyes<br>
<br>
print('\t\tid: {id}, hostname: {host}'<br>
.format(id=csruv[1], host=csruv[0])<br>
)<br>
<br>
we use in code<br>
<br>
print(<br>
something1,<br>
something2<br>
)<br>
<br>
or<br>
<br>
print(something1,<br>
something2)<br>
<br>
</blockquote>
And that shouldn't be there anymore, too :)<br>
<blockquote cite="mid:56A7B365.6090608@redhat.com" type="cite">
Otherwise LGTM<br>
</blockquote>
<br>
</blockquote>
<br>
ACK<br>
<br>
Pushed to:<br>
ipa-4-3: 44018142747e933f7d680c8d7bacfbd883ffddf6<br>
master: c8eabaff9ef49d3f51b02d613c25c09bf155bb3c<br>
<br>
</body>
</html>