diff options
author | Kamen Mazdrashki <kamenim@samba.org> | 2010-09-26 02:25:03 +0300 |
---|---|---|
committer | Kamen Mazdrashki <kamenim@samba.org> | 2010-09-26 02:25:03 +0300 |
commit | 9e6fa8553cb7ca7fece76646c30f7fcb2a86a83a (patch) | |
tree | 07718cd51c765b97b0f0c4f6c918b17a4c494a13 /source4 | |
parent | dda1dd63d3c463a9a26d85acf4a9f7cc53396613 (diff) | |
download | samba-9e6fa8553cb7ca7fece76646c30f7fcb2a86a83a.tar.gz samba-9e6fa8553cb7ca7fece76646c30f7fcb2a86a83a.tar.bz2 samba-9e6fa8553cb7ca7fece76646c30f7fcb2a86a83a.zip |
s4-ldapcmp: Extend ldapcmp to be able to compare more than one context at a time
If no arguments given, ldapcmp will compare all NCs
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/scripting/devel/ldapcmp | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/source4/scripting/devel/ldapcmp b/source4/scripting/devel/ldapcmp index 689c2020c4..e3d5ee7b2c 100755 --- a/source4/scripting/devel/ldapcmp +++ b/source4/scripting/devel/ldapcmp @@ -445,7 +445,7 @@ class LDAPBundel(object): other.update_size() assert self.size == other.size assert sorted([x.upper() for x in self.dn_list]) == sorted([x.upper() for x in other.dn_list]) - self.log( "\n* Objets to be compared: %s" % self.size ) + self.log( "\n* Objects to be compared: %s" % self.size ) index = 0 while index < self.size: @@ -552,8 +552,16 @@ if __name__ == "__main__": if creds.is_anonymous(): parser.error("You must supply at least one username/password pair") - if not (len(args) == 1 and args[0].upper() in ["DOMAIN", "CONFIGURATION", "SCHEMA"]): - parser.error("Incorrect arguments") + # make a list of contexts to compare in + contexts = [] + if len(args) == 0: + # if no argument given, we compare all contexts + contexts = ["DOMAIN", "CONFIGURATION", "SCHEMA"] + else: + for context in args: + if not context.upper() in ["DOMAIN", "CONFIGURATION", "SCHEMA"]: + parser.error("Incorrect argument: %s" % context) + contexts.append(context.upper()) if opts.verbose and opts.quiet: parser.error("You cannot set --verbose and --quiet together") @@ -564,25 +572,30 @@ if __name__ == "__main__": con2 = LDAPBase(opts.host2, opts, creds2, lp) assert len(con2.base_dn) > 0 - b1 = LDAPBundel(con1, context=args[0], cmd_opts=opts) - b2 = LDAPBundel(con2, context=args[0], cmd_opts=opts) - - if b1 == b2: - if not opts.quiet: - print "\n* Final result: SUCCESS" - status = 0 - else: + status = 0 + for context in contexts: if not opts.quiet: - print "\n* Final result: FAILURE" - print "\nSUMMARY" - print "---------" - status = -1 + print "\n* Comparing [%s] context..." % context - assert len(b1.summary["df_value_attrs"]) == len(b2.summary["df_value_attrs"]) - b2.summary["df_value_attrs"] = [] + b1 = LDAPBundel(con1, context=context, cmd_opts=opts) + b2 = LDAPBundel(con2, context=context, cmd_opts=opts) - if not opts.quiet: - b1.print_summary() - b2.print_summary() + if b1 == b2: + if not opts.quiet: + print "\n* Result for [%s]: SUCCESS" % context + else: + if not opts.quiet: + print "\n* Result for [%s]: FAILURE" % context + print "\nSUMMARY" + print "---------" + # mark exit status as FAILURE if a least one comparison failed + status = -1 + + assert len(b1.summary["df_value_attrs"]) == len(b2.summary["df_value_attrs"]) + b2.summary["df_value_attrs"] = [] + + if not opts.quiet: + b1.print_summary() + b2.print_summary() sys.exit(status) |