rrs_upgrade_history.py: add maintenance plan handling

Instead of processing all layerbranches, only process those associated
with an enabled maintenance plan. This is one step towards being able to
use the RRS together with a more general layer index database.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-02-27 17:17:16 +13:00
parent 8370c10306
commit 252578e26d

View File

@ -212,6 +212,7 @@ def do_loop(layerbranch, ct, logger, dry_run):
"""
def upgrade_history(options, logger):
from layerindex.models import LayerBranch
from rrs.models import MaintenancePlan
# start date
now = datetime.today()
@ -223,8 +224,13 @@ def upgrade_history(options, logger):
else:
since = (now - timedelta(days=8)).strftime("%Y-%m-%d")
# do
for layerbranch in LayerBranch.objects.all():
maintplans = MaintenancePlan.objects.filter(updates_enabled=True)
if not maintplans.exists():
logger.error('No enabled maintenance plans found')
sys.exit(1)
for maintplan in maintplans:
for maintplanbranch in maintplan.maintenanceplanlayerbranch_set.all():
layerbranch = maintplanbranch.layerbranch
layer = layerbranch.layer
urldir = layer.get_fetch_dir()
repodir = os.path.join(fetchdir, urldir)