Adding in some metrics around clair sec scan.
This commit is contained in:
parent
2c637fe5ce
commit
edd9dcd7f6
4 changed files with 56 additions and 16 deletions
|
@ -3,7 +3,7 @@ import dateutil.parser
|
|||
import hashlib
|
||||
import json
|
||||
|
||||
from peewee import JOIN_LEFT_OUTER, IntegrityError
|
||||
from peewee import JOIN_LEFT_OUTER, IntegrityError, fn
|
||||
from datetime import datetime
|
||||
|
||||
from data.model import (DataModelException, db_transaction, _basequery, storage,
|
||||
|
@ -471,6 +471,40 @@ def ensure_image_locations(*names):
|
|||
data = [{'name': name} for name in insert_names]
|
||||
ImageStorageLocation.insert_many(data).execute()
|
||||
|
||||
|
||||
def get_max_id_for_sec_scan():
|
||||
""" Gets the maximum id for a clair sec scan """
|
||||
return Image.select(fn.Max(Image.id)).scalar()
|
||||
|
||||
|
||||
def get_min_id_for_sec_scan(version):
|
||||
""" Gets the minimum id for a clair sec scan """
|
||||
return (Image
|
||||
.select(fn.Min(Image.id))
|
||||
.where(Image.security_indexed_engine < version)
|
||||
.scalar())
|
||||
|
||||
|
||||
def total_image_count():
|
||||
""" Returns the total number of images in DB """
|
||||
return Image.select().count()
|
||||
|
||||
|
||||
def get_image_id():
|
||||
""" Returns the primary key for Image DB model """
|
||||
return Image.id
|
||||
|
||||
|
||||
def get_images_eligible_for_scan(clair_version):
|
||||
""" Returns a query that gives all images eligible for a clair scan """
|
||||
return get_image_with_storage_and_parent_base().where(Image.security_indexed_engine < clair_version)
|
||||
|
||||
|
||||
def get_count_of_images_eligible_for_scan(clair_version):
|
||||
""" Returns a query that gives all images eligible for a clair scan """
|
||||
return get_images_eligible_for_scan(clair_version).count()
|
||||
|
||||
|
||||
def get_image_with_storage_and_parent_base():
|
||||
Parent = Image.alias()
|
||||
ParentImageStorage = ImageStorage.alias()
|
||||
|
|
Reference in a new issue