On 12/12/2014 02:19 PM, Petr Vobornik wrote:
> On 12/11/2014 03:43 PM, Tomas Babej wrote:
>>
>> On 12/11/2014 11:07 AM, Jan Cholasta wrote:
>>> Hi,
>>>
>>> Dne 11.12.2014 v 09:23 Tomas Babej napsal(a):
>>>> Hi,
>>>>
>>>> When running a idview-apply command, the hosts that were already
>>>> assigned
>>>> the desired view were silently ignored. Make sure such hosts show
>>>> up in
>>>> the list of failed hosts.
>>>>
>>>> https://fedorahosted.org/freeipa/ticket/4743
>>>
>>> Shouldn't the error message strings be translatable?
>>>
>>
>> Sure, why not. Good point, I transformed the other error message string
>> as well.
>>
>> Updated patch attach.
>>
>>> Honza
>>>
>
> Got JSON serialization issues for both "ID View already applied" and
> "not found" errors.
>
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-packages/ipaserver/rpcserver.py", line
> 402, in __call__
>     response = self.wsgi_execute(environ)
>   File "/usr/lib/python2.7/site-packages/ipaserver/rpcserver.py", line
> 387, in wsgi_execute
>     return self.marshal(result, error, _id, version)
>   File "/usr/lib/python2.7/site-packages/ipaserver/rpcserver.py", line
> 467, in marshal
>     return json.dumps(response, sort_keys=True, indent=4)
>   File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
>     sort_keys=sort_keys, **kw).encode(obj)
>   File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
>     chunks = list(chunks)
>   File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
>     for chunk in _iterencode_dict(o, _current_indent_level):
>   File "/usr/lib64/python2.7/json/encoder.py", line 408, in
> _iterencode_dict
>     for chunk in chunks:
>   File "/usr/lib64/python2.7/json/encoder.py", line 408, in
> _iterencode_dict
>     for chunk in chunks:
>   File "/usr/lib64/python2.7/json/encoder.py", line 408, in
> _iterencode_dict
>     for chunk in chunks:
>   File "/usr/lib64/python2.7/json/encoder.py", line 408, in
> _iterencode_dict
>     for chunk in chunks:
>   File "/usr/lib64/python2.7/json/encoder.py", line 332, in
> _iterencode_list
>     for chunk in chunks:
>   File "/usr/lib64/python2.7/json/encoder.py", line 332, in
> _iterencode_list
>     for chunk in chunks:
>   File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
>     o = _default(o)
>   File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
>     raise TypeError(repr(o) + " is not JSON serializable")
> TypeError: Gettext('ID View already applied', domain='ipa',
> localedir=None) is not JSON serializable

Thanks, fixed. Updated patch attached.

-- 
Tomas Babej
Associate Software Engineer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org 

>From 0a2232e031461c294760e1377de45d7d3273f581 Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Thu, 11 Dec 2014 07:50:40 +0100
Subject: [PATCH] idviews: Complain if host is already assigned the ID View in
 idview-apply

When running a idview-apply command, the hosts that were already assigned
the desired view were silently ignored. Make sure such hosts show up in
the list of failed hosts.

https://fedorahosted.org/freeipa/ticket/4743
---
 ipalib/plugins/idviews.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ipalib/plugins/idviews.py b/ipalib/plugins/idviews.py
index 9c8721018325f56e681f168b55c31055bfd07345..c9c1bd848750e7c7e1c472df179368ac2b9d29ce 100644
--- a/ipalib/plugins/idviews.py
+++ b/ipalib/plugins/idviews.py
@@ -260,7 +260,7 @@ class baseidview_apply(LDAPQuery):
             try:
                 hosts_to_apply += get_complete_hostgroup_member_list(hostgroup)
             except errors.NotFound:
-                failed['hostgroup'].append((hostgroup, "not found"))
+                failed['hostgroup'].append((hostgroup, unicode(_("not found"))))
             except errors.PublicError as e:
                 failed['hostgroup'].append((hostgroup, "%s : %s" % (
                                             e.__class__.__name__, str(e))))
@@ -279,10 +279,11 @@ class baseidview_apply(LDAPQuery):
                 completed = completed + 1
                 succeeded['host'].append(host)
             except errors.EmptyModlist:
-                # If view was already applied, do not complain
-                pass
+                # If view was already applied, complain about it
+                failed['host'].append((host,
+                                       unicode(_("ID View already applied"))))
             except errors.NotFound:
-                failed['host'].append((host, "not found"))
+                failed['host'].append((host, unicode(_("not found"))))
             except errors.PublicError as e:
                 failed['host'].append((host, str(e)))
 
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to