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

@ -0,0 +1,20 @@
from data.database import Image
from app import app
import json
store = app.config['STORAGE']
for image in Image.select():
if image.command == None:
image_json_path = store.image_json_path(image.repository.namespace,
image.repository.name,
image.docker_image_id)
if store.exists(image_json_path):
data = json.loads(store.get_content(image_json_path))
command_list = data.get('container_config', {}).get('Cmd', None)
command = json.dumps(command_list) if command_list else None
print 'Setting command to: %s' % command
image.command = command
image.save()