2018-02-28 15:37:37 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import json
|
|
|
|
import argparse
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Add missing uuids in clusters')
|
2018-02-28 16:19:16 +01:00
|
|
|
parser.add_argument("-f", "--filename", required=True, help="name of the cluster")
|
2018-02-28 15:37:37 +01:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2018-02-28 16:19:16 +01:00
|
|
|
with open(args.filename) as json_file:
|
2018-02-28 15:37:37 +01:00
|
|
|
data = json.load(json_file)
|
|
|
|
json_file.close()
|
|
|
|
|
|
|
|
for value in data['values']:
|
|
|
|
if 'uuid' not in value:
|
|
|
|
value['uuid'] = str(uuid.uuid4())
|
|
|
|
|
2018-02-28 16:19:16 +01:00
|
|
|
with open(args.filename, 'w') as json_file:
|
2018-02-28 15:37:37 +01:00
|
|
|
json.dump(data, json_file, indent=4)
|