Add --only-check-contextCSN parameter
This commit is contained in:
parent
9e6de5077f
commit
36f9a09a34
1 changed files with 123 additions and 105 deletions
|
@ -159,6 +159,14 @@ parser.add_argument(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--only-check-contextCSN",
|
||||||
|
dest="onlycheckcontextcsn",
|
||||||
|
action="store_true",
|
||||||
|
help="Only check servers root contextCSN (objects check disabled, default : False)",
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-a", "--attributes",
|
"-a", "--attributes",
|
||||||
dest="attrs",
|
dest="attrs",
|
||||||
|
@ -212,6 +220,12 @@ parser.add_argument(
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
if options.nocheckcontextcsn and options.onlycheckcontextcsn:
|
||||||
|
parser.error("You can't use both --no-check-contextCSN and --only-check-contextCSN parameters and the same time")
|
||||||
|
if options.nagios:
|
||||||
|
sys.exit(3)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if not options.provider or not options.consumer:
|
if not options.provider or not options.consumer:
|
||||||
parser.error("You must provide provider and customer URI")
|
parser.error("You must provide provider and customer URI")
|
||||||
if options.nagios:
|
if options.nagios:
|
||||||
|
@ -427,6 +441,7 @@ for srv in servers:
|
||||||
LdapServersCSN[srv] = LdapServers[srv].getContextCSN(options.basedn, options.serverid)
|
LdapServersCSN[srv] = LdapServers[srv].getContextCSN(options.basedn, options.serverid)
|
||||||
logging.info('ContextCSN of %s: %s', srv, LdapServersCSN[srv])
|
logging.info('ContextCSN of %s: %s', srv, LdapServersCSN[srv])
|
||||||
|
|
||||||
|
if not options.onlycheckcontextcsn:
|
||||||
logging.info('List objects from %s', srv)
|
logging.info('List objects from %s', srv)
|
||||||
LdapObjects[srv] = {}
|
LdapObjects[srv] = {}
|
||||||
|
|
||||||
|
@ -445,18 +460,19 @@ for srv in servers:
|
||||||
logging.info('%s objects founds', len(LdapObjects[srv]))
|
logging.info('%s objects founds', len(LdapObjects[srv]))
|
||||||
|
|
||||||
|
|
||||||
not_found = {}
|
if not options.onlycheckcontextcsn:
|
||||||
not_sync = {}
|
not_found = {}
|
||||||
|
not_sync = {}
|
||||||
|
|
||||||
for srv in servers:
|
for srv in servers:
|
||||||
not_found[srv] = []
|
not_found[srv] = []
|
||||||
not_sync[srv] = []
|
not_sync[srv] = []
|
||||||
|
|
||||||
if options.attrs:
|
if options.attrs:
|
||||||
logging.info("Check if objects a are synchronized (by comparing attributes's values)")
|
logging.info("Check if objects a are synchronized (by comparing attributes's values)")
|
||||||
else:
|
else:
|
||||||
logging.info('Check if objets are synchronized (by comparing entryCSN)')
|
logging.info('Check if objets are synchronized (by comparing entryCSN)')
|
||||||
for obj in LdapObjects[options.provider]:
|
for obj in LdapObjects[options.provider]:
|
||||||
logging.debug('Check obj %s', obj)
|
logging.debug('Check obj %s', obj)
|
||||||
for srv in LdapObjects:
|
for srv in LdapObjects:
|
||||||
if srv == options.provider:
|
if srv == options.provider:
|
||||||
|
@ -508,7 +524,7 @@ for obj in LdapObjects[options.provider]:
|
||||||
orig_value = LdapObjects[options.provider][obj][options.touch]
|
orig_value = LdapObjects[options.provider][obj][options.touch]
|
||||||
LdapServers[options.provider].touch_object(obj, options.touch, orig_value)
|
LdapServers[options.provider].touch_object(obj, options.touch, orig_value)
|
||||||
|
|
||||||
for obj in LdapObjects[options.consumer]:
|
for obj in LdapObjects[options.consumer]:
|
||||||
logging.debug('Check obj %s of consumer', obj)
|
logging.debug('Check obj %s of consumer', obj)
|
||||||
if obj not in LdapObjects[options.provider]:
|
if obj not in LdapObjects[options.provider]:
|
||||||
logging.debug('Obj %s: not found on provider', obj)
|
logging.debug('Obj %s: not found on provider', obj)
|
||||||
|
@ -532,6 +548,7 @@ if options.nagios:
|
||||||
errors.append('ContextCSN of %s not the same of provider' % srv)
|
errors.append('ContextCSN of %s not the same of provider' % srv)
|
||||||
long_output.append('ContextCSN on LDAP server %s = %s' % (srv, LdapServersCSN[srv]))
|
long_output.append('ContextCSN on LDAP server %s = %s' % (srv, LdapServersCSN[srv]))
|
||||||
|
|
||||||
|
if not options.onlycheckcontextcsn:
|
||||||
if not_found[options.consumer]:
|
if not_found[options.consumer]:
|
||||||
errors.append("%s not found object(s) on consumer" % len(not_found[options.consumer]))
|
errors.append("%s not found object(s) on consumer" % len(not_found[options.consumer]))
|
||||||
long_output.append("Object(s) not found on server %s (consumer) :" % options.consumer)
|
long_output.append("Object(s) not found on server %s (consumer) :" % options.consumer)
|
||||||
|
@ -571,6 +588,7 @@ else:
|
||||||
logging.warning('ContextCSN of %s not the same of provider', srv)
|
logging.warning('ContextCSN of %s not the same of provider', srv)
|
||||||
noerror = False
|
noerror = False
|
||||||
|
|
||||||
|
if not options.onlycheckcontextcsn:
|
||||||
if not_found[srv]:
|
if not_found[srv]:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
'Not found objects on %s :\n - %s',
|
'Not found objects on %s :\n - %s',
|
||||||
|
|
Loading…
Reference in a new issue