Updates docs for SR1 with final revision
[genesis.git] / fuel / prototypes / auto-deploy / deploy / tools / transplant_opnfv_settings.py
1 #!/usr/bin/python
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 import yaml
13 import re
14 import sys
15 import os
16
17 if len(sys.argv) != 4:
18     sys.stderr.write("Usage: "+sys.argv[0]+" <file> <deafile> [compute|controller]\n")
19     sys.exit(1)
20
21 file = sys.argv[1]
22 if not os.path.exists(file):
23     sys.stderr.write("ERROR: The file "+file+" could not be opened\n")
24     sys.exit(1)
25
26 deafile = sys.argv[2]
27 namespace = sys.argv[3]
28
29 f1 = open(file, 'r')
30 doc1 = yaml.load(f1)
31 f1.close()
32
33 f2 = open(deafile, 'r')
34 doc2 = yaml.load(f2)
35 f1.close()
36
37 doc1["opnfv"] = doc2["opnfv"][namespace]
38
39 f2 = open(file, 'w')
40 f2.write(yaml.dump(doc1, default_flow_style=False))
41 f2.close()
42