#!/usr/bin/python
# Copyright European Organization for Nuclear Research (CERN)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - Mario Lassnig, <mario.lassnig@cern.ch>, 2016-2017

"""
Fill the merged metrix into the Redis cache.
"""

import json
import redis

if __name__ == '__main__':

    R = redis.Redis()

    with open('/data/metrix/data/metrix/latest.json', 'rb') as f:
        DATA = json.load(f)

    for link in DATA:
        R.set('metrics#%s' % str(link), json.dumps(DATA[link]))
