Commit Graph

56 Commits

Author SHA1 Message Date
John Dennis
94d457e83c Use DN objects instead of strings
* Convert every string specifying a DN into a DN object

* Every place a dn was manipulated in some fashion it was replaced by
  the use of DN operators

* Add new DNParam parameter type for parameters which are DN's

* DN objects are used 100% of the time throughout the entire data
  pipeline whenever something is logically a dn.

* Many classes now enforce DN usage for their attributes which are
  dn's. This is implmented via ipautil.dn_attribute_property(). The
  only permitted types for a class attribute specified to be a DN are
  either None or a DN object.

* Require that every place a dn is used it must be a DN object.
  This translates into lot of::

    assert isinstance(dn, DN)

  sprinkled through out the code. Maintaining these asserts is
  valuable to preserve DN type enforcement. The asserts can be
  disabled in production.

  The goal of 100% DN usage 100% of the time has been realized, these
  asserts are meant to preserve that.

  The asserts also proved valuable in detecting functions which did
  not obey their function signatures, such as the baseldap pre and
  post callbacks.

* Moved ipalib.dn to ipapython.dn because DN class is shared with all
  components, not just the server which uses ipalib.

* All API's now accept DN's natively, no need to convert to str (or
  unicode).

* Removed ipalib.encoder and encode/decode decorators. Type conversion
  is now explicitly performed in each IPASimpleLDAPObject method which
  emulates a ldap.SimpleLDAPObject method.

* Entity & Entry classes now utilize DN's

* Removed __getattr__ in Entity & Entity clases. There were two
  problems with it. It presented synthetic Python object attributes
  based on the current LDAP data it contained. There is no way to
  validate synthetic attributes using code checkers, you can't search
  the code to find LDAP attribute accesses (because synthetic
  attriutes look like Python attributes instead of LDAP data) and
  error handling is circumscribed. Secondly __getattr__ was hiding
  Python internal methods which broke class semantics.

* Replace use of methods inherited from ldap.SimpleLDAPObject via
  IPAdmin class with IPAdmin methods. Directly using inherited methods
  was causing us to bypass IPA logic. Mostly this meant replacing the
  use of search_s() with getEntry() or getList(). Similarly direct
  access of the LDAP data in classes using IPAdmin were replaced with
  calls to getValue() or getValues().

* Objects returned by ldap2.find_entries() are now compatible with
  either the python-ldap access methodology or the Entity/Entry access
  methodology.

* All ldap operations now funnel through the common
  IPASimpleLDAPObject giving us a single location where we interface
  to python-ldap and perform conversions.

* The above 4 modifications means we've greatly reduced the
  proliferation of multiple inconsistent ways to perform LDAP
  operations. We are well on the way to having a single API in IPA for
  doing LDAP (a long range goal).

* All certificate subject bases are now DN's

* DN objects were enhanced thusly:
  - find, rfind, index, rindex, replace and insert methods were added
  - AVA, RDN and DN classes were refactored in immutable and mutable
    variants, the mutable variants are EditableAVA, EditableRDN and
    EditableDN. By default we use the immutable variants preserving
    important semantics. To edit a DN cast it to an EditableDN and
    cast it back to DN when done editing. These issues are fully
    described in other documentation.
  - first_key_match was removed
  - DN equalty comparison permits comparison to a basestring

* Fixed ldapupdate to work with DN's. This work included:
  - Enhance test_updates.py to do more checking after applying
    update. Add test for update_from_dict(). Convert code to use
    unittest classes.
  - Consolidated duplicate code.
  - Moved code which should have been in the class into the class.
  - Fix the handling of the 'deleteentry' update action. It's no longer
    necessary to supply fake attributes to make it work. Detect case
    where subsequent update applies a change to entry previously marked
    for deletetion. General clean-up and simplification of the
    'deleteentry' logic.
  - Rewrote a couple of functions to be clearer and more Pythonic.
  - Added documentation on the data structure being used.
  - Simplfy the use of update_from_dict()

* Removed all usage of get_schema() which was being called prior to
  accessing the .schema attribute of an object. If a class is using
  internal lazy loading as an optimization it's not right to require
  users of the interface to be aware of internal
  optimization's. schema is now a property and when the schema
  property is accessed it calls a private internal method to perform
  the lazy loading.

* Added SchemaCache class to cache the schema's from individual
  servers. This was done because of the observation we talk to
  different LDAP servers, each of which may have it's own
  schema. Previously we globally cached the schema from the first
  server we connected to and returned that schema in all contexts. The
  cache includes controls to invalidate it thus forcing a schema
  refresh.

* Schema caching is now senstive to the run time context. During
  install and upgrade the schema can change leading to errors due to
  out-of-date cached schema. The schema cache is refreshed in these
  contexts.

* We are aware of the LDAP syntax of all LDAP attributes. Every
  attribute returned from an LDAP operation is passed through a
  central table look-up based on it's LDAP syntax. The table key is
  the LDAP syntax it's value is a Python callable that returns a
  Python object matching the LDAP syntax. There are a handful of LDAP
  attributes whose syntax is historically incorrect
  (e.g. DistguishedNames that are defined as DirectoryStrings). The
  table driven conversion mechanism is augmented with a table of
  hard coded exceptions.

  Currently only the following conversions occur via the table:

  - dn's are converted to DN objects

  - binary objects are converted to Python str objects (IPA
    convention).

  - everything else is converted to unicode using UTF-8 decoding (IPA
    convention).

  However, now that the table driven conversion mechanism is in place
  it would be trivial to do things such as converting attributes
  which have LDAP integer syntax into a Python integer, etc.

* Expected values in the unit tests which are a DN no longer need to
  use lambda expressions to promote the returned value to a DN for
  equality comparison. The return value is automatically promoted to
  a DN. The lambda expressions have been removed making the code much
  simpler and easier to read.

* Add class level logging to a number of classes which did not support
  logging, less need for use of root_logger.

* Remove ipaserver/conn.py, it was unused.

* Consolidated duplicate code wherever it was found.

* Fixed many places that used string concatenation to form a new
  string rather than string formatting operators. This is necessary
  because string formatting converts it's arguments to a string prior
  to building the result string. You can't concatenate a string and a
  non-string.

* Simplify logic in rename_managed plugin. Use DN operators to edit
  dn's.

* The live version of ipa-ldap-updater did not generate a log file.
  The offline version did, now both do.

https://fedorahosted.org/freeipa/ticket/1670
https://fedorahosted.org/freeipa/ticket/1671
https://fedorahosted.org/freeipa/ticket/1672
https://fedorahosted.org/freeipa/ticket/1673
https://fedorahosted.org/freeipa/ticket/1674
https://fedorahosted.org/freeipa/ticket/1392
https://fedorahosted.org/freeipa/ticket/2872
2012-08-12 16:23:24 -04:00
Jan Cholasta
e7a6d10555 Finalize plugin initialization on demand.
This patch changes the way plugins are initialized. Instead of
finalizing all the plugins at once, plugins are finalized only after
they are accessed (currently applies to Command, Object and
Attribute subclasses, only in CLI by default).

This change provides significant performance boost, as only the
plugins that are actually used are finalized.

ticket 1336
2011-11-22 00:52:24 -05:00
Rob Crittenden
8810758c11 Let the framework be able to override the hostname.
The hostname is passed in during the server installation. We should use
this hostname for the resulting server as well. It was being discarded
and we always used the system hostname value.

Important changes:
- configure ipa_hostname in sssd on masters
- set PKI_HOSTNAME so the hostname is passed to dogtag installer
- set the hostname when doing ldapi binds

This also reorders some things in the dogtag installer to eliminate an
unnecessary restart. We were restarting the service twice in a row with
very little time in between and this could result in a slew of reported
errors, though the server installed ok.

ticket 1052
2011-06-23 02:11:34 -04:00
Rob Crittenden
359d54e741 Don't perform some API self-tests in production mode for performance reasons
The API does a fair number of self tests and locking to assure that the
registered commands are consistent and will work. This does not need
to be done on a production system and adds additional overhead causing
somewhere between a 30 and 50% decrease in performance.

Because makeapi is executed when a build is done ensure that it is
executed in developer mode to ensure that the framework is ok.

ticket 751
2011-01-28 18:49:17 -05:00
Jakub Hrozek
7493d781df Change FreeIPA license to GPLv3+
The changes include:
 * Change license blobs in source files to mention GPLv3+ not GPLv2 only
 * Add GPLv3+ license text
 * Package COPYING not LICENSE as the license blobs (even the old ones)
   mention COPYING specifically, it is also more common, I think

 https://fedorahosted.org/freeipa/ticket/239
2010-12-20 17:19:53 -05:00
Rob Crittenden
0ceba59d87 Add Requires on ipa-client to ipa-admintools, ensure ipa client is configured
It makes little sense to install ipa-admintools without ipa-client, require it.

Also see if the client has been configured. This is a bit tricky since we
have a full set of defaults. Add a new env option that gets set if at least
one configuration file is loaded.

ticket 213
2010-10-15 15:03:51 -04: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
Pavel Zuna
03f16810ee Use unicode instead of str for environmental variables in Env. 2010-02-19 14:38:58 -05:00
Rob Crittenden
338578d10a Allow one-character Param names
This is done explicitly to support the l/localityname attribute.
2010-02-12 13:14:29 -07:00
Rob Crittenden
cc23838db2 Use the FQDN and not just the hostname internally. 2009-10-16 14:57:33 -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
Jason Gerard DeRose
ae38a2461f Force xmlrpc tests to run with in_tree=True so config files in /etc/ipa/ don't get read; cleaned up config.Env automagic with regard to running in-tree vs. installed 2009-05-11 16:17:08 -04:00
Jason Gerard DeRose
3274577cd6 Finished small tweaks to get new ipaserver.xmlrpc() mod_python handler working 2009-02-03 15:29:05 -05:00
Jason Gerard DeRose
c2b0c80140 Started work on a much simplified mod_python server 2009-02-03 15:29:05 -05:00
Jason Gerard DeRose
12c4879613 Added ca_host, ca_port, and ca_ssl_port Env variables that Andrew requested 2009-02-03 15:29:00 -05:00
Jason Gerard DeRose
4a24b49d5d A few docstring improvements in Env 2009-01-05 03:28:27 -07:00
Jason Gerard DeRose
7be459af0b Added a bit to config.Env docstring about that variable names must pass check_name() function 2009-01-02 01:14:37 -07:00
Jason Gerard DeRose
e9be796950 Fixed Env._bootstrap() docstring typo 2008-12-30 15:14:33 -07:00
Jason Gerard DeRose
379c549fc1 Env now supports float values 2008-12-30 15:02:15 -07:00
Jason Gerard DeRose
ecccc5c236 Added my name to Athors of config.py 2008-12-30 14:05:08 -07:00
Jason Gerard DeRose
03c9114958 More docstring cleanup in ipalib.config 2008-12-30 13:52:36 -07:00
Jason Gerard DeRose
11e165073e Docstring cleanup in the Env bootstraping methods 2008-12-30 03:11:45 -07:00
Jason Gerard DeRose
447c88a2bb Started moving some core classes and functions from plugable.py to new base.py module 2008-12-30 00:45:48 -07:00
Jason Gerard DeRose
e14fc84dfc Renamed Env._merge_config() to Env._merge_from_file() 2008-12-29 21:23:34 -07:00
Jason Gerard DeRose
7766f0be61 Yet more small docstring cleanup in Env 2008-12-23 01:59:31 -07:00
Jason Gerard DeRose
f7cae9a27c More docstring cleanup in Env and its methods 2008-12-23 01:28:00 -07:00
Jason Gerard DeRose
16526142f3 Finished Env class docstring; more organizational cleanup in Env and its unit tests 2008-12-23 01:11:03 -07:00
Jason Gerard DeRose
fd43b39145 Moved setting of run-time variables from Env.__init__() to Env._bootstrap() 2008-12-22 23:09:35 -07:00
Jason Gerard DeRose
01cae56e0a Some more reorganization in Env and added class docstring to Env with lots of examples 2008-12-22 21:02:43 -07:00
Jason Gerard DeRose
6b055b435f Cleaned up Env.__setattr__() and Env.__setitem__() a bit updated their unit tests 2008-12-22 17:29:11 -07:00
Jason Gerard DeRose
014cca57ad The Env.__setitem__() implied conversion is now case sensitive; Env.__setitem__() now also accepts None as a value 2008-12-22 16:16:57 -07:00
Jason Gerard DeRose
c070d390e9 Removed Env.__getattr__(); Env no longer accepts callables for values (no more dynamic/lazy values) 2008-12-22 15:51:54 -07:00
Jason Gerard DeRose
5b637f6a18 Removed depreciated code from config.py; removed corresponding unit tests 2008-12-22 15:41:24 -07:00
Jason Gerard DeRose
9aa14333a4 Added 'conf_dir' env variable, which is directory containing config files 2008-11-10 15:53:10 -07:00
Jason Gerard DeRose
c26a3c8542 Finished fist draft of plugin tutorial in ipalib/__init__.py docstring 2008-11-07 02:26:38 -07:00
Jason Gerard DeRose
9f45cdbe2f Merge branch 'master' of git://git.engineering.redhat.com/users/rcritten/freeipa2 2008-10-29 18:10:38 -06:00
Rob Crittenden
54f37503d2 Implement host groups 2008-10-27 12:24:17 -04:00
Jason Gerard DeRose
25a7df9615 Env._finalize_core() now also loads config from Env.conf_default 2008-10-27 01:09:53 -06:00
Jason Gerard DeRose
28dd8e74bd Env._bootstrap() now also sets Env.conf_default 2008-10-27 00:58:25 -06:00
Jason Gerard DeRose
759734864e Finished Env._finalize() and corresponding unit tests 2008-10-24 20:21:27 -06:00
Jason Gerard DeRose
ac4efac394 Finished Env._finalize_core() and corresponding unit tests 2008-10-24 20:02:14 -06:00
Jason Gerard DeRose
2a41db33c6 Env._bootstrap() now raises StandardError if called more than once 2008-10-24 15:35:58 -06:00
Jason Gerard DeRose
f80beb948b Added ipalib/constants.py; added Env._load_config() method along with comprehensive unit tests for same 2008-10-24 15:07:07 -06:00
Jason Gerard DeRose
2ec0312eb6 Finished doodle with stricter version of Environment 2008-10-24 01:51:36 -06:00
Rob Crittenden
06a82bf4b6 Fix ipa command running in server_context=True
Make the LDAP host and port environment variables
More changes so that commands have a shell return value
lite-xmlrpc no longer hardcodes the kerberos credentials cache location
2008-10-23 11:00:50 -04:00
Rob Crittenden
1daf319a19 Implement the host commands
In order for this to work against a v1 database the update host.update needs to
be applied
2008-10-22 17:54:04 -04:00
Martin Nagy
18e74643a6 Add comments in config.py and fix Environment.get() 2008-10-20 19:54:30 +02:00
Martin Nagy
3a80297b04 Reworking Environment, moved it to config.py 2008-10-17 23:11:51 +02:00
Rob Crittenden
cfc8450efd Port user-show to new CrudBackend framework 2008-10-14 22:22:01 -04:00
Martin Nagy
ff88652a40 Convert string values to boolean when generating environment 2008-10-14 21:22:44 +02:00