if cur.fetchone():
return True
+def count_liveboots():
+ con = db_connect()
+ cur = con.cursor()
+ try:
+ cur.execute("SELECT COUNT(keep_image) FROM liveboot WHERE keep_image = true")
+ except psycopg2.DatabaseError as e:
+ logger.debug("SELECT COUNT(keep_image) FROM liveboot WHERE keep_image = true")
+ return False
+ print cur.fetchone()[0]
+ return True
+
+
def set_liveboot_to_delete(name):
con = db_connect()
cur = con.cursor()
return False
if __name__ == '__main__':
- if len(sys.argv) != 3 or sys.argv[1] not in ('keep', 'delete'):
+ if len(sys.argv) == 1:
+ count_liveboots()
+ sys.exit(0)
+ elif len(sys.argv) != 3 or sys.argv[1] not in ('keep', 'delete'):
print("usage: %s keep $liveboot_name")
print(" will return true or false, depending if 'keep_image' is set for this image")
print("usage: %s delete $liveboot_name")
done
done
done
+
+EXISTING_IMAGES=$(./cleanup_liveboot.py)
+
+if [ "$EXISTING_IMAGES" -gt 10 ] ; then
+ figlet WARNING
+ echo "$EXISTING_IMAGES liveboot images exist, you probably need to delete some..."
+fi