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 ##############################################################################
12 # Remove control and management network transformations from file.
13 # Only to be used together with f_control_bond_example (enable in
21 if len(sys.argv) != 2:
22 sys.stderr.write("Usage: "+sys.argv[0]+" <filename>\n")
25 filename = sys.argv[1]
26 if not os.path.exists(filename):
27 sys.stderr.write("ERROR: The file "+filename+" could not be opened\n")
30 ignore_values = [ "eth0", "eth1", "br-mgmt", "br-fw-admin" ]
32 infile = open(filename, 'r')
33 doc = yaml.load(infile)
39 if scheme == "network_scheme":
41 for operation in doc[scheme]:
42 if operation == "transformations":
43 # We need the base bridges for l23network to be happy,
44 # remove everything else.
45 mytrans = [ { "action": "add-br", "name": "br-mgmt" },
46 { "action": "add-br", "name": "br-fw-admin" } ]
47 for trans in doc[scheme][operation]:
49 for ignore in ignore_values:
50 matchObj = re.search(ignore,str(trans))
57 #print "Deleted", trans
59 mytransformation[operation] = mytrans
61 mytransformation[operation] = doc[scheme][operation]
62 out[scheme] = mytransformation
64 out[scheme] = doc[scheme]
66 outfile = open(filename, 'w')
67 outfile.write(yaml.dump(out, default_flow_style=False))