Harvest commands from the Docker json information and add to the database.

This commit is contained in:
yackob03 2014-01-13 16:32:51 -05:00
parent 5918082e6d
commit e23c750bfb
6 changed files with 38 additions and 8 deletions

View file

@ -1,12 +1,9 @@
import logging
import string
import shutil
import os
import json
import hashlib
import random
from datetime import datetime, timedelta
from flask import url_for
from peewee import SqliteDatabase, create_model_tables, drop_model_tables
from data.database import *
@ -19,6 +16,12 @@ store = app.config['STORAGE']
SAMPLE_DIFFS = ['test/data/sample/diffs/diffs%s.json' % i
for i in range(1, 10)]
SAMPLE_CMDS = [['/bin/bash'],
["/bin/sh", "-c",
"echo \"PasswordAuthentication no\" >> /etc/ssh/sshd_config"],
["/bin/sh", "-c",
"sed -i 's/#\\(force_color_prompt\\)/\\1/' /etc/skel/.bashrc"],
None]
REFERENCE_DATE = datetime(2013, 6, 23)
TEST_STRIPE_ID = 'cus_2tmnh3PkXQS8NG'
@ -52,11 +55,14 @@ def __create_subtree(repo, structure, parent):
model.set_image_checksum(docker_image_id, repo, checksum)
creation_time = REFERENCE_DATE + timedelta(days=image_num)
command_list = SAMPLE_CMDS[image_num % len(SAMPLE_CMDS)]
command = json.dumps(command_list) if command_list else None
new_image = model.set_image_metadata(docker_image_id, repo.namespace,
repo.name, str(creation_time),
'no comment', parent)
'no comment', command, parent)
model.set_image_size(docker_image_id, repo.namespace, repo.name, random.randrange(1, 1024 * 1024 * 1024))
model.set_image_size(docker_image_id, repo.namespace, repo.name,
random.randrange(1, 1024 * 1024 * 1024))
# Populate the diff file
diff_path = store.image_file_diffs_path(repo.namespace, repo.name,