Re: [Freeipa-devel] [PATCH 0183] ipa-advise: correct handling of plugin namespace iteration

2016-09-07 Thread Jan Cholasta

On 19.7.2016 09:15, Martin Babinsky wrote:

On 07/18/2016 08:46 AM, Jan Cholasta wrote:

Hi,

On 11.7.2016 14:18, Martin Babinsky wrote:

https://fedorahosted.org/freeipa/ticket/6044


Note that you should use .name rather than .__name__ to get plugin
names, otherwise the code won't work with plugins with non-default names.

There currently aren't any Advice plugins with non-default name, but I
would rather fix this now to avoid surprises later.

Honza



I didn't realize this when doing the patch, here's the fix for that.

I have attached the original closed ticket to the commit message, should
I create a new ticket for such a small change?


Bump. I'm fine with new ticket or no ticket, but don't use 6044.

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0183] ipa-advise: correct handling of plugin namespace iteration

2016-07-19 Thread Martin Babinsky

On 07/18/2016 08:46 AM, Jan Cholasta wrote:

Hi,

On 11.7.2016 14:18, Martin Babinsky wrote:

https://fedorahosted.org/freeipa/ticket/6044


Note that you should use .name rather than .__name__ to get plugin
names, otherwise the code won't work with plugins with non-default names.

There currently aren't any Advice plugins with non-default name, but I
would rather fix this now to avoid surprises later.

Honza



I didn't realize this when doing the patch, here's the fix for that.

I have attached the original closed ticket to the commit message, should 
I create a new ticket for such a small change?


--
Martin^3 Babinsky
From 5da15a1a56174d06120c8296d8878e71ec8a66a4 Mon Sep 17 00:00:00 2001
From: Martin Babinsky 
Date: Mon, 18 Jul 2016 10:44:23 +0200
Subject: [PATCH] advise: Use `name` instead of `__name__` to get plugin names

This change will allow ipa-advise to correctly handle advise plugins with
custom names.

https://fedorahosted.org/freeipa/ticket/6044
---
 ipaserver/advise/base.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipaserver/advise/base.py b/ipaserver/advise/base.py
index a2dc9ccee93811da415c1e1eb0b57f47ac817a3f..f7e8ef5e49c7efc18d5c29583183e908e1284eae 100644
--- a/ipaserver/advise/base.py
+++ b/ipaserver/advise/base.py
@@ -168,11 +168,11 @@ class IpaAdvise(admintool.AdminTool):
 self.print_header('List of available advices')
 
 max_keyword_len = max(
-(len(advice.__name__) for advice in advise_api.Advice))
+(len(advice.name) for advice in advise_api.Advice))
 
 for advice in advise_api.Advice:
 description = getattr(advice, 'description', '')
-keyword = advice.__name__.replace('_', '-')
+keyword = advice.name.replace('_', '-')
 
 # Compute the number of spaces needed for the table to be aligned
 offset = max_keyword_len - len(keyword)
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [PATCH 0183] ipa-advise: correct handling of plugin namespace iteration

2016-07-18 Thread Jan Cholasta

Hi,

On 11.7.2016 14:18, Martin Babinsky wrote:

https://fedorahosted.org/freeipa/ticket/6044


Note that you should use .name rather than .__name__ to get plugin 
names, otherwise the code won't work with plugins with non-default names.


There currently aren't any Advice plugins with non-default name, but I 
would rather fix this now to avoid surprises later.


Honza

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0183] ipa-advise: correct handling of plugin namespace iteration

2016-07-12 Thread Petr Vobornik
On 07/11/2016 02:30 PM, Stanislav Laznicka wrote:
> On 07/11/2016 02:18 PM, Martin Babinsky wrote:
>> https://fedorahosted.org/freeipa/ticket/6044
>>
>>
>>
> ACK.
> 
> 
> 
master:
* c1d8629b7490f443eededf0c0d0472d8285f85e8 ipa-advise: correct handling
of plugin namespace iteration

-- 
Petr Vobornik

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0183] ipa-advise: correct handling of plugin namespace iteration

2016-07-11 Thread Stanislav Laznicka

On 07/11/2016 02:18 PM, Martin Babinsky wrote:

https://fedorahosted.org/freeipa/ticket/6044




ACK.

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

[Freeipa-devel] [PATCH 0183] ipa-advise: correct handling of plugin namespace iteration

2016-07-11 Thread Martin Babinsky

https://fedorahosted.org/freeipa/ticket/6044

--
Martin^3 Babinsky
From 7e971dd965c9b86d4bf1daef9b25eee0e8c8411f Mon Sep 17 00:00:00 2001
From: Martin Babinsky 
Date: Mon, 11 Jul 2016 14:03:36 +0200
Subject: [PATCH] ipa-advise: correct handling of plugin namespace iteration

The API object namespace iterators now yield plugin classes themselves
instead of their names as strings. The method enumerating through available
plugins needs to be made aware of this change.

https://fedorahosted.org/freeipa/ticket/6044
---
 ipaserver/advise/base.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ipaserver/advise/base.py b/ipaserver/advise/base.py
index d083a3c506074f0adbb49e7a6d9935b8d338e941..a2dc9ccee93811da415c1e1eb0b57f47ac817a3f 100644
--- a/ipaserver/advise/base.py
+++ b/ipaserver/advise/base.py
@@ -167,12 +167,12 @@ class IpaAdvise(admintool.AdminTool):
 def print_config_list(self):
 self.print_header('List of available advices')
 
-max_keyword_len = max((len(keyword) for keyword in advise_api.Advice))
+max_keyword_len = max(
+(len(advice.__name__) for advice in advise_api.Advice))
 
-for keyword in advise_api.Advice:
-advice = getattr(advise_api.Advice, keyword, '')
+for advice in advise_api.Advice:
 description = getattr(advice, 'description', '')
-keyword = keyword.replace('_', '-')
+keyword = advice.__name__.replace('_', '-')
 
 # Compute the number of spaces needed for the table to be aligned
 offset = max_keyword_len - len(keyword)
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code