Commit Graph

178 Commits

Author SHA1 Message Date
Jakub Hrozek
55479e4512 Normalize and convert default params, too
https://fedorahosted.org/freeipa/ticket/555
2010-12-02 16:06:13 -05:00
Jakub Hrozek
a874d5f8e5 Clarify the description of --raw and -all
https://fedorahosted.org/freeipa/ticket/244
2010-11-08 15:23:03 -05:00
Rob Crittenden
3c795f3251 Return reason for failure when updating group membership fails.
We used to return a list of dns that failed to be added. We now return
a list of tuples instead. The tuple looks like (dn, reason) where reason
is the exception that was returned.

Also made the label we use for failures to be singular instead of plural
since we now print them out individually instead of as comma-separated.

ticket 270
2010-10-28 17:47:20 -04:00
Rob Crittenden
33802ab712 Use context to decide which name to return on RequirementsErrors
When a Requirement fails we throw an exception including the name of the
field that is missing. To make the command-line friendlier we have a
cli_name defined which may or may not match the LDAP attribute. This can
be confusing if you are using ipalib directly because the attribute name
missing may not match what is actually required (desc vs description is
a good example).

If you use the context 'cli' then it will throw exceptions using cli_name.
If you use any other context it will use the name of the attribute.

ticket 187
2010-10-28 16:06:06 -04:00
Pavel Zuna
dff2ff8300 Disallow RDN change and single-value bypass using setattr/addattr.
When setting or adding an attribute wiht setatt/addattr check to
see if there is a Param for the attribute and enforce the multi-value.
If there is no Param check the LDAP schema for SINGLE-VALUE.

Catch RDN mods and try to return a more reasonable error message.

Ticket #230
Ticket #246
2010-10-18 14:44:42 -04:00
Rob Crittenden
53c218cf2f Return non-zero when the number of entries from *-find returned is zero.
ticket 325
2010-10-13 13:00:58 -04:00
Rob Crittenden
be6aa7039b Return non-zero when group membership change fails, no empty fail list.
There is no point (and it is confusing) to print an empty list when
modifying group membership fails, so suppress it.

If any membership change fails we should return non-zero.

tickets 271, 273, 274
2010-10-08 10:11:54 -04:00
Rob Crittenden
1df10a88cd Add support for client failover to the ipa command-line.
This adds a new global option to the ipa command, -f/--no-fallback. If this
is included then just the server configured in /etc/ipa/default.conf is used.
Otherwise that is tried first then all servers in DNS with the ldap SRV record
are tried.

Create a new Local() Command class for local-only commands. The help
command is one of these. It shouldn't need a remote connection to execute.

ticket #15
2010-08-16 10:35:27 -04:00
Adam Young
030b5dab93 Change the behaviour of addattr/setattr parameters.
setattr and addattr can now be used both to set all values of
ANY attribute. the last setattr always resets the attribute to
the specified value and all addattr append to it.

Examples:
user-mod testuser --setattr=title=msc
  title: msc
user-mod testuser --setattr=title=msb
  title: msb
user-mod testuser --addattr=title=msc
  title: msb, msc
user-mod testuser --setattr=title=
  title:
user-mod testuser --setattr=title=msc --addattr=msb
  title: msc, msb
user-mod testuser --setattr=title=ing --addattr=bc
  title: ing, bc
user-mod testuser --setattr=title=doc
  title: doc

It's not very user friendly, but it's going to be used very very
rarely in special conditions in the CLI and we can use it to save
lots of JSON-RPC roundtrips in the webUI.

This version includes calling the validation of Params during the setting of the attrs.
2010-08-13 16:20:41 -04:00
Rob Crittenden
2bb2850fff Include contents of has_output_params in get_output_params 2010-07-13 09:27:50 -04:00
Rob Crittenden
2f50668753 Fix output of summary and embedded dictionaries
Summaries were appearing as "Gettext(...")

Embedded dictionaries, such as group membership failures, didn't have
labels so were basically just being dumped.
2010-05-03 13:40:34 -06:00
Pavel Zuna
c7a35f95c5 Fix output for commands that do not return entries.
I also changed the default value of the print_all argument in
textui.print_entry from False to True. It think it makes more sense this
way, because:

1) if order is None, it will still print something
2) if order is not None, it will print what's in order first and then the
   rest
3) commands that care about the print_all argument have to set it in any
   case, those that don't care usually want to print everything
2010-03-26 16:56:47 -04:00
Pavel Zuna
43ab2c483d Add INTERNAL flag to frontend plugins. If set, the plugin won't show in UI. 2010-03-22 10:41:36 -04:00
Rob Crittenden
b46f262a60 Include params in Method.output_params
Method overrides the Command get_output_params() method and only returns
the object params, not anything defined within the method itself. Return
those as well so they are displayed in output. Some care needs to be taken
to avoid returning duplicate values. In the case of duplicates the
value in obj.params wins.
2010-03-19 04:31:40 -06:00
John Dennis
b75d06e189 localize doc strings
A number of doc strings were not localized, wrap them in _().
Some messages were not localized, wrap them in _()

Fix a couple of failing tests:
The method name in RPC should not be unicode.
The doc attribute must use the .msg attribute for comparison.

Also clean up imports of _() The import should come from
ipalib or ipalib.text, not ugettext from request.
2010-03-08 21:10:36 -07:00
Rob Crittenden
766757e4d4 Fix unicode failures in Env tests and dn failures in XML-RPC tests 2010-02-26 12:31:11 -05:00
Jason Gerard DeRose
8c46e09735 Translatable Param.label, Param.doc 2010-02-24 02:47:39 -07:00
Pavel Zuna
03967f62e9 Auto-generate --all and --raw for commands, that return entries. 2010-02-17 10:56:06 -05:00
Rob Crittenden
58746226d4 Use the Output tuple to determine the order of output
The attributes displayed is now dependant upon their definition in
a Param. This enhances that, giving some level of control over how
the result is displayed to the user.

This also fixes displaying group membership, including failures of
adding/removing entries.

All tests pass now though there is still one problem. We need to
return the dn as well. Once that is fixed we just need to comment
out all the dn entries in the tests and they should once again
pass.
2010-02-15 13:10:11 -07:00
Jason Gerard DeRose
069763c5c6 Add Object.label class attribute, enable in webUI 2010-02-12 17:07:37 -05:00
Jason Gerard DeRose
dc2f246d47 Command.output_params not contains params in Command.params 2010-02-11 14:56:10 -05:00
Jason Gerard DeRose
1d6cc1bb7b Remove __public__ and __proxy__ hold-overs from Plugin class 2010-01-28 13:32:00 -05:00
Jason Gerard DeRose
b6e4972e7f Take 2: Extensible return values and validation; steps toward a single output_for_cli(); enable more webUI stuff 2009-12-10 08:29:15 -07:00
Rob Crittenden
55c62ac79a Add support for setting/adding arbitrary attributes
This introduces 2 new params: --setattr and --addattr

Both take a name/value pair, ala:

ipa user-mod --setattr=postalcode=20601 jsmith

--setattr replaces or sets the current attribute to the value
--addattr adds the value to an attribute (or sets a new attribute)

OptionsParser allows multiple versions of this, so you can have multiple
setattr and addattr, either for the same attribute or for different
attributes.

ipa user-mod --addattr=postalcode=20601 --addattr=postalcode=30330 jsmith

Values are silent dropped if either of these on an existing param:

ipa user-mod --setattr=givenname=Jerry jsmith

Is a no-op.
2009-11-17 09:40:56 -07:00
Jason Gerard DeRose
5c9437b9e6 Removed util.add_global_options() and frontend.Application 2009-10-14 15:07:17 -06:00
Jason Gerard DeRose
f58ff2921d Giant webui patch take 2 2009-10-13 11:28:00 -06:00
Pavel Zuna
e0f3e765db Fix: Object.params_minus_pk was invalid when there was no primary_key. 2009-09-09 09:56:34 -04:00
Jason Gerard DeRose
c0f558d98b Removed PluginProxy and all its uses 2009-08-05 12:18:51 -04:00
Pavel Zuna
8c7883364c Remove use_ldap2 constant. 2009-07-02 13:33:01 -04:00
Pavel Zuna
dc23be6878 Make get_dn parameter list more generic. Fix Attribute name regex.
The old name regex made it impossible to have Attribute instances with
names composed of more than two words separated by underscores.
2009-06-10 11:53:14 -04:00
Jason Gerard DeRose
7e58b29a92 Completed Param.use_in_context() functionality, which is now used by Command and Object 2009-05-21 14:32:45 -04:00
Jason Gerard DeRose
4f9224774f Added Param 'include' and 'exclude' kwargs; added frontend.UsesParams base class with methods implementing the filtering to restrict params to only certain contexts 2009-05-19 13:49:15 -06:00
Rob Crittenden
298d5fbce4 Import the RequiresRoot error and make note to replace this at some point 2009-04-24 16:22:22 -04:00
Pavel Zuna
7d0bd4b895 Rename errors2.py to errors.py. Modify all affected files. 2009-04-23 10:29:14 -04:00
Pavel Zuna
9ecbd845d4 Add conditional (env.use_ldap2 is True) modifications required by new LDAP backend. 2009-04-22 15:14:24 -04:00
Pavel Zuna
016b82250e Add ipalib.frontend.Command method to build an entry from params with attribute=True.
Often plugins need to build LDAP entries from params. This should make things a bit easier.
Crud methods (Create, Retrieve, Update, Delete, Search) have attribute=True by default.
And it also works for multivalue params.
2009-02-23 13:49:21 -05:00
Jason Gerard DeRose
92a150b4f1 Some tweaks in user plugins, ported to new crud base classes 2009-02-03 15:29:05 -05:00
Jason Gerard DeRose
a0aebd46a1 Got new ldap connection working using Connectible.connect() 2009-02-03 15:29:04 -05:00
Jason Gerard DeRose
e0b00d5981 Removed depreciated import of errors in frontend.py 2009-02-03 15:29:02 -05:00
Jason Gerard DeRose
0313f03277 Added ServiceError (KerberosError) and make rpc.KerbTransport raise it if appropriate 2009-02-03 15:29:02 -05:00
Jason Gerard DeRose
114b6b8577 Added some missing parameter unit tests; added docstring about Command._repr_iter() and Param.safe_value() 2009-02-03 15:29:02 -05:00
Jason Gerard DeRose
244346dbcb More work on xmlrpc stuff, started migrated more code to use errors2 instead of errors 2009-02-03 15:29:01 -05:00
Jason Gerard DeRose
24b6cb89d4 Further migration toward new xmlrcp code; fixed problem with unicode Fault.faultString; fixed problem where ServerProxy method was not called correctly 2009-02-03 15:29:01 -05:00
Jason Gerard DeRose
46c10d4608 Removed bogus CLI.set_defaults() method that was causing non-required values to get filled in 2009-02-03 15:29:00 -05:00
Jason Gerard DeRose
6aadeb9aea Added Object.params_minus() method; various small tweaks 2009-02-03 15:29:00 -05:00
Jason Gerard DeRose
f3a84683d2 Removed depreciated Command.args_to_kw() method; updated CLI to use Command.args_options_2_params() instead 2009-02-03 15:29:00 -05:00
Jason Gerard DeRose
ae39dece13 Added Command.args_options_2_params() method and its unit tests 2009-02-03 15:29:00 -05:00
Jason Gerard DeRose
4febb4dd14 Started roughing out new crud base classes 2009-02-03 15:28:59 -05:00
Jason Gerard DeRose
6e53d03c69 Command.takes_options and Command.takes_args class attributes can now also be a callable 2009-02-03 15:28:59 -05:00
Jason Gerard DeRose
0327b83899 New Param: all docstring examples now pass under doctests 2009-01-14 20:36:17 -07:00
Jason Gerard DeRose
09e2f5d615 New Param: got most of unit tests ported (still have 6 errors); haven't ported doctests yet 2009-01-14 13:17:30 -07:00
Jason Gerard DeRose
69acff450c New Param: removed more depreciated 'import ipa_types' 2009-01-14 12:00:47 -07:00
Jason Gerard DeRose
2b2e73e7df Removed depreciated code from frontend.py; frontend.py no longer imports ipa_types 2009-01-14 11:39:29 -07:00
Jason Gerard DeRose
9d091c98f1 Plugin.__init__() now checks that subclass hasn't defined attributes that conflict with the logger methods; added corresponding unit test 2008-12-21 19:34:32 -07:00
Jason Gerard DeRose
69041c3b1b Removed Plugin.name property and replaced with instance attribute created in Plugin.__init__() 2008-12-17 21:47:43 -07:00
Jason Gerard DeRose
29d680b211 Continued work on xmlrpc.dispatch() unit tests; fixed bug in Command.args_to_kw() 2008-11-25 13:52:40 -07:00
Jason Gerard DeRose
2db738e899 Some changes to make reading dubugging output easier 2008-11-24 10:09:30 -07:00
Jason Gerard DeRose
500b816681 Added unit test for Param.ispassword() method 2008-11-18 16:29:08 -07:00
Jason Gerard DeRose
4afee15d4b Calling 'passwd' command now prompts for password using textui.prompt_password() 2008-11-18 13:43:43 -07:00
Jason Gerard DeRose
8474bd01da Command.get_defaults() now returns param.default if param.type is a Bool 2008-11-17 18:50:30 -07:00
Jason Gerard DeRose
9de56d43f0 env plugin now subclasses from RemoteOrLocal 2008-11-14 21:58:39 -07:00
Jason Gerard DeRose
36737c2d91 Added frontend.LocalOrRemote command base class for commands like env 2008-11-14 21:29:46 -07:00
Jason Gerard DeRose
860d391f3e Change Param.__repr__() so it returns the exact expression that could create it; added unit test for Param.__repre__() 2008-11-13 22:16:04 -07:00
Jason Gerard DeRose
1f635269e8 Param.__repr__() now uses util.make_repr() 2008-11-13 21:17:33 -07:00
Jason Gerard DeRose
8ad5502354 Added util.make_repr() function; added corresponding unit tests 2008-11-13 21:07:47 -07:00
Jason Gerard DeRose
f04aaff97c output_for_cli signature is now output_for_cli(textui, result, *args, **options) 2008-11-12 09:55:11 -07:00
Jason Gerard DeRose
09161e399a Command.get_default() will now fill-in None for all missing non-required params 2008-11-12 01:47:37 -07:00
Jason Gerard DeRose
d76202fea3 API.env is now an Env instance rather than an Environment instance 2008-10-27 01:35:40 -06:00
Jason Gerard DeRose
603baf6b10 Fixed typos in tables in docstrings for Attribute and Method 2008-10-21 08:42:52 -06:00
Jason Gerard DeRose
461f547e6a Added docstring (with example) to frontend.Attribute class 2008-10-20 20:28:24 -06:00
Jason Gerard DeRose
c818fe1d2d Added docstring (with examples) to frontend.Method class 2008-10-20 19:57:02 -06:00
Jason Gerard DeRose
bb978e591b Fixed bug in DefaultFrom where impleied keys were using entire func_code.co_varnames instead of an approprate slice 2008-10-20 16:45:32 -06:00
Jason Gerard DeRose
5c5641e8c2 Added some more examples to Param docstrings 2008-10-18 00:16:22 -06:00
Jason Gerard DeRose
721982870e Removed generic Command.output_for_cli() method; CLI.run_interactive() now only calls output_for_cli() if it has been implemented 2008-10-17 21:05:03 -06:00
Jason Gerard DeRose
f1eb74e22c make-test now runs doctests also; fixed several broken doctests 2008-10-17 20:50:34 -06:00
Jason Gerard DeRose
8322138f38 Added new Param.flags attribute (set with flags=foo kwarg) 2008-10-17 19:34:26 -06:00
Jason Gerard DeRose
1480224724 Started roughing out user_add() using api.Backend.ldap; added Command.output_for_cli() to take care of formatting print output 2008-10-14 01:45:30 -06:00
Jason Gerard DeRose
446037fd60 Added Object.get_dn() method; added corresponding unit tests 2008-10-13 23:26:24 -06:00
Jason Gerard DeRose
2357360e2a Command.params are now sorted the same way as Object.params (make user-add prompt for first, last before login) 2008-10-13 21:53:03 -06:00
Jason Gerard DeRose
8674086b85 Param now takes cli_name kwarg that sets Param.cli_name attribute 2008-10-13 17:24:23 -06:00
Jason Gerard DeRose
887016e69d Base Command.execute() method now raises NotImplementedError; updated unit tests 2008-10-08 18:18:13 -06:00
Jason Gerard DeRose
b7fe92f44f Reorganized Command methods so it is easier to understand and added lots of docstrings 2008-10-08 18:01:22 -06:00
Jason Gerard DeRose
3ffbaac64c Backend.xmlrpc and simple-server.py now use the xmlrpc_marshal() and xmlrpc_unmarshal() functions respectively 2008-10-02 19:42:06 -06:00
Jason Gerard DeRose
ed3a5855f3 -m 2008-10-02 17:51:50 -06:00
Jason Gerard DeRose
993b9f4f63 Command.get_default() now only returns a defaults for required values 2008-10-02 17:46:48 -06:00
Jason Gerard DeRose
6000b6b5c6 Implemented basic Command.forward() method 2008-10-02 17:02:24 -06:00
Martin Nagy
afdc721038 Add support for environment variables, change tests accordingly 2008-09-29 17:45:14 -06:00
Jason Gerard DeRose
d77907d2d0 373: Replaced type_ optional arg to Param.__init__() with pure kw arg type; updated unit tests and related code 2008-09-27 01:30:39 +00:00
Jason Gerard DeRose
8901b9a837 372: Started work on docstring for Param class 2008-09-27 00:31:59 +00:00
Jason Gerard DeRose
031daabcc4 371: Added examples to parse_param_spec() docstring and changed syntax guide into a reStructuredText table 2008-09-26 23:41:51 +00:00
Jason Gerard DeRose
7bbd81d831 370: Added detailed examples to decstring for DefaultFrom class 2008-09-26 22:52:15 +00:00
Jason Gerard DeRose
aa45ec616a 369: Added Object.backend attribute used to associated it with a particular backend component 2008-09-26 02:43:11 +00:00
Jason Gerard DeRose
152f3089e1 363: Added Object.params_minus_pk instance attribute 2008-09-25 03:27:40 +00:00
Jason Gerard DeRose
023f612921 361: Implemented crud.Add.get_options() method; added corresponding unit tests 2008-09-25 02:13:16 +00:00
Jason Gerard DeRose
9f704e001d 360: Removed Method.get_options() default implementation; cleaned up unit tests for Method 2008-09-25 01:52:34 +00:00
Jason Gerard DeRose
54c97b4948 359: Added Object.primary_key instance attribute; added corresponding unit tests 2008-09-25 01:44:53 +00:00
Jason Gerard DeRose
4267422793 358: Cleaned up private methods in Object 2008-09-25 01:04:10 +00:00
Jason Gerard DeRose
4747563a80 356: Modified Method.get_options() to now pull from self.obj.params(); updated unit tests for Method.get_options() 2008-09-25 00:42:38 +00:00
Jason Gerard DeRose
79b33ad366 355: Object.set_api() now creates Object.params namespace by merging takes_params and properties together intelegintly 2008-09-25 00:00:58 +00:00
Jason Gerard DeRose
f531f7da81 354: Added NameSpace.__todict__() method that returns copy of NameSpace.__map; updated NameSpace unit test to also test __todict__() 2008-09-24 23:49:44 +00:00