[Freeipa-devel] Asking for help to add new options
Petr Viktorin
pviktori at redhat.com
Wed May 14 10:32:09 UTC 2014
On 05/14/2014 12:27 PM, thierry bordaz wrote:
> On 05/14/2014 12:01 PM, Petr Viktorin wrote:
>> On 05/14/2014 11:21 AM, thierry bordaz wrote:
>>> Hello,
>>>
>>> Quite beginner in freeipa land, I am trying to add options to
>>> 'user-add' sub-command but desperately failing to make it work.
>>> I did the following modification:
>>>
>>> diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
>>> index 9b21200..0c36e35 100644
>>> --- a/ipalib/plugins/user.py
>>> +++ b/ipalib/plugins/user.py
>>> @@ -365,6 +365,20 @@ class user(LDAPObject):
>>> csv=True,
>>> flags=['no_search'],
>>> ),
>>> + Flag('tostage?',
>>> + doc=_('Create user in staging container'),
>>> + flags=('no_search', 'virtual_attribute'),
>>> + cli_name='to_stage',
>>> + default=False,
>>> + ),
>>> + Str('uidstaged?',
>>> +
>>> pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$',
>>> + pattern_errmsg='may only include letters, numbers,
>>> _, -, . and $',
>>> + maxlength=255,
>>> + cli_name='from_staged',
>>> + label=_('Activate the User currently in the staging
>>> container'),
>>> + normalizer=lambda value: value.lower(),
>>> + ),
>>> )
>>>
>>> def _normalize_and_validate_email(self, email,
>>> config=None):
>>> @@ -436,12 +450,16 @@ class user_add(LDAPCreate):
>>> msg_summary = _('Added user "%(value)s"')
>>>
>>> has_output_params = LDAPCreate.has_output_params +
>>> user_output_params
>>> +
>>> + #internal_options = ['tostage', 'uidstaged']
>>>
>>> takes_options = LDAPCreate.takes_options + (
>>> Flag('noprivate',
>>> cli_name='noprivate',
>>> doc=_('Don\'t create user private group'),
>>> ),
>>> +
>>> +
>>> )
>>>
>>>
>>> The command 'ipa user-add --help' succeeds giving me the correct
>>> help message. But when I try to add the user it fails:
>>>
>>> ipa user-add foo --to-stage --first=foo --last=foo
>>> ipa: ERROR: Unknown option: tostage
>>>
>>>
>>> This seems to occur because the frontend find this is a 'remaining'
>>> option.. but what does it means ?
>>> I tried to add the new options as internal options, or with
>>> different names, but it gives the same results.
>>> I know it is a very novice question, but I have really no idea I
>>> should fix it. Anyone know what I am missing ?
>>>
>>> regards
>>> thierry
>>
>> Hi,
>> Adding these options works for me; I think the most likely reason is
>> you're still using the old version. Did you install the changed file
>> properly? If you're just copying the .py file to /usr/lib, remember to
>> restart Apache.
>>
> Hi Petr,
>
> Thanks for the info.
> I am using the cli, not the web interface and I installed just
> copying user.py to
> /usr/lib/python2.7/site-packages/ipalib/plugins/user.py.
> I believe I am using the new version as the '--help' option shows
> the new added options '--to-stage' and '--from-stage'.
The CLI talks to the server, and the options are validated again at the
server. The --help shows only the client part of the picture.
Do try restarting Apache (`sudo apachectl graceful`).
> Did you succeed to add a user with something like: ipa user-add foo
> --to-stage --first=foo --last=foo ?
Yes.
> may be something bad with my deployment I am using freeipa 3.3. Did
> you test on master ?
Yes, I tested on master, but I don't think that should be an issue.
--
Petr³
More information about the Freeipa-devel
mailing list