Skip to content

Commit 779e450

Browse files
author
Zürker Aguilar, Fabian
committed
Add --state-check flag
1 parent e6c76bb commit 779e450

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

check_katello_sync.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ def check_product(product):
9292
:param product: Product dictionary
9393
:type product: dict
9494
"""
95+
if options.state_check:
96+
sync_state = product.get("sync_state")
97+
if not sync_state or "complete" not in sync_state.lower():
98+
LOGGER.debug("Product '%s' (%s) has unsynced state!",
99+
product["label"], (product["description"] or '')
100+
)
101+
PROD_CRIT.append(product["label"])
102+
set_code(2)
103+
return
104+
95105
# check if product unsynced
96106
if product["last_sync"] is None:
97107
LOGGER.debug(
@@ -332,6 +342,10 @@ def parse_options(args=None):
332342
prod_opts.add_argument("-c", "--outdated-critical", dest="outdated_crit", \
333343
default=5, metavar="DAYS", type=int, help="defines outdated products" \
334344
" critical threshold in days (default: 5)")
345+
# --state-check
346+
prod_opts.add_argument("--state-check", dest="state-check", \
347+
default=False, action="store_true", \
348+
help="Check for unsynced status using sync_state field")
335349

336350
# PRODUCT FILTER ARGUMENTS
337351
# -o / --organization

0 commit comments

Comments
 (0)