
o-c-c has a special mode which explodes deployments into individual files. This will effectively do the same for local copies of server metadata. Change-Id: I505d02a190ac93f243aeaf6d05256e66e832c8bf
28 lines
895 B
Python
28 lines
895 B
Python
#!/usr/bin/python
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('path', default='/var/lib/os-collect-config/local-data')
|
|
parser.add_argument('--deployments-key', default='deployments')
|
|
|
|
args = parser.parse_args()
|
|
|
|
for fname in os.listdir(args.path):
|
|
f = os.path.join(args.path, fname)
|
|
with open(f) as infile:
|
|
x = json.loads(infile.read())
|
|
dp = args.deployments_key
|
|
final_list = []
|
|
if dp in x:
|
|
if isinstance(x[dp], list):
|
|
for d in x[dp]:
|
|
name = d['name']
|
|
if d.get('group', 'Heat::Ungrouped') in ('os-apply-config', 'Heat::Ungrouped'):
|
|
final_list.append((name, d['config']))
|
|
for oname, oconfig in final_list:
|
|
with open('%s%s' % (f, oname), 'w') as outfile:
|
|
outfile.write(json.dumps(oconfig))
|