kcc topology generator written as python

Andrew Tridgell tridge at samba.org
Tue Nov 1 23:23:20 MDT 2011

Hi Dave,

> As per your suggestions I have rewritten the major portion of the
> KCC in python.   The patchsets are available at:
> https://github.com/wimberosa/samba/tree/kcc-stable

thanks! That looks really good. Amitay and I have been going over it
today, and only have a few comments:

 - in identify_by_basedn() we should probably use DN comparison, forming
   a ldb.Dn() object. This is only because the case sensitivity of
   components can vary in DNs (for the DNs you're comparing, this won't
   happen, so its a very minor point)

 - the method of walking over the keys() in functions like
   load_connection() is unusual. It will work fine, but I think it may
   be clearer to ask for that attribute directly. The pattern we usually
   use is:

 if 'options' in msg:
    self.options = int(msg['options'][0])

 if you want to make that neater, we could add a helper function a bit
 like getattr() that takes a default value. For example:

    self.options = ldb_msg_value(msg, 'options', 0)

> I realize you've been out so I may have gotten a little
> ahead of you here.  Two of the patches are large but actually
> are self contained python scripts.
>       scripting/bin/kcccompute
>       scripting/python/samba/kcc_utils.py

yep, that's fine. I think I'd prefer it to be called samba_kcc, just so
when it is installed in /usr/bin that admins know what it is for (the
term 'kcc' isn't in the lexicon of many Unix admins).

also, trying kcccompute on a standalone DC I get:

  Unable to satisfy max edge criteria

I presume that should be 'min' not 'max'? Are there separate rules we
need to apply for a single DC or a very small domain? (obviously a
standalone DC is a pretty boring case, and maybe we can just check that
at the top?)

> The python scripts currently enumerate all steps as outlined
> in the KCC technical reference.   A few of the functions are
> not implemented (are no-ops) but are there to give the exact
> flow that will be required for a complete run of the KCC and
> update of the database.

that's fine, I really like the structure you've created for this, and I
think it is a very good basis for future development of the kcc.

Do you want any help in getting this called from the C kcc server? (or
just look at the call to samba_runcmd_send() in the DNS server for an

> The current code base builds all appropriate classes and methods
> (mostly appearing in kcc_utils.py) such as DirectoryServiceAgent, Site,
> GraphNode, NTDSConnection,  NamingContext,  NCReplica
> from the database.   The kcc class appearing in kcccompute
> successfully computes the graph tree for intrasite topology
> and builds the new NTDSConnections in memory.    The commit
> code to the database is pretty small but not done yet.

ok, no problem.

> I need to get some input on whether I can get this into the
> code base so I can build off of it and finish the rest of the
> functions.    Input requested.....

I think it's great. I suspect the kcc is going to end up being quite
complex, and having a good structure for it is fantastic. Thanks so much
for your effort!

Do you want me to push what you've done now, or wait till its integrated
into the kcc task so it runs instead of the old C kcc?

Cheers, Tridge

More information about the samba-technical mailing list