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
|
||||
)
|
||||
|
||||
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(
|
||||
"-a", "--attributes",
|
||||
dest="attrs",
|
||||
|
@ -212,6 +220,12 @@ parser.add_argument(
|
|||
|
||||
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:
|
||||
parser.error("You must provide provider and customer URI")
|
||||
if options.nagios:
|
||||
|
@ -427,6 +441,7 @@ for srv in servers:
|
|||
LdapServersCSN[srv] = LdapServers[srv].getContextCSN(options.basedn, options.serverid)
|
||||
logging.info('ContextCSN of %s: %s', srv, LdapServersCSN[srv])
|
||||
|
||||
if not options.onlycheckcontextcsn:
|
||||
logging.info('List objects from %s', srv)
|
||||
LdapObjects[srv] = {}
|
||||
|
||||
|
@ -445,6 +460,7 @@ for srv in servers:
|
|||
logging.info('%s objects founds', len(LdapObjects[srv]))
|
||||
|
||||
|
||||
if not options.onlycheckcontextcsn:
|
||||
not_found = {}
|
||||
not_sync = {}
|
||||
|
||||
|
@ -532,6 +548,7 @@ if options.nagios:
|
|||
errors.append('ContextCSN of %s not the same of provider' % srv)
|
||||
long_output.append('ContextCSN on LDAP server %s = %s' % (srv, LdapServersCSN[srv]))
|
||||
|
||||
if not options.onlycheckcontextcsn:
|
||||
if 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)
|
||||
|
@ -571,6 +588,7 @@ else:
|
|||
logging.warning('ContextCSN of %s not the same of provider', srv)
|
||||
noerror = False
|
||||
|
||||
if not options.onlycheckcontextcsn:
|
||||
if not_found[srv]:
|
||||
logging.warning(
|
||||
'Not found objects on %s :\n - %s',
|
||||
|
|
Loading…
Reference in a new issue