1 ##############################################################################
2 # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5 # not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
8 # http://www.apache.org/licenses/LICENSE-2.0 #
10 # Unless required by applicable law or agreed to in writing, software #
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
13 # See the License for the specific language governing permissions and #
14 # limitations under the License. #
15 ##############################################################################
23 with open(sys.argv[1]) as f:
24 yaml = yaml.safe_load(f)
26 def create_rc_genesis(source, target_suffix):
27 env = jinja2.Environment()
28 env.trim_blocks = True
29 env.lstrip_blocks = True
31 with open(source) as fd:
32 template = env.from_string(fd.read())
33 data = template.render(yaml=yaml)
34 target_file = yaml['genesis']['name']+target_suffix
35 fd2 = open(target_file,'w')
39 print '{0} -> {1}'.format(source, target_file)
41 def create_rc_masters(source, target_suffix):
42 env = jinja2.Environment()
43 env.trim_blocks = True
44 env.lstrip_blocks = True
46 for master in yaml['masters'] and type(yaml['masters']) is list:
47 with open(source) as fd:
48 template = env.from_string(fd.read())
49 data = template.render(yaml=master)
50 target_file = "server-config/"+master['name']+target_suffix
52 if os.path.exists(target_file):
53 print 'rc file exists maynot be new node'
55 if not os.path.exists(os.path.dirname(target_file)):
56 os.makedirs(os.path.dirname(target_file))
57 fd2 = open(target_file,'w')
61 print '{0} -> {1}'.format(source, target_file)
62 command = '/opt/akraino/tools/apply_dellxml.sh --rc {0} --template dell_r740_g14_uefi_base.xml.template --no-confirm'.format(target_file)
63 print 'command: {0}'.format(command)
66 def create_rc_workers(source, target_suffix):
67 env = jinja2.Environment()
68 env.trim_blocks = True
69 env.lstrip_blocks = True
71 if 'workers' in yaml and type(yaml['workers']) is list:
72 for master in yaml['workers']:
73 with open(source) as fd:
74 template = env.from_string(fd.read())
75 data = template.render(yaml=master)
76 target_file = "server-config/"+master['name']+target_suffix
78 if os.path.exists(target_file):
79 print 'rc file exists maynot be new node'
81 if not os.path.exists(os.path.dirname(target_file)):
82 os.makedirs(os.path.dirname(target_file))
83 fd2 = open(target_file,'w')
87 print '{0} -> {1}'.format(source, target_file)
88 command = '/opt/akraino/tools/apply_dellxml.sh --rc {0} --template dell_r740_g14_uefi_base.xml.template --no-confirm'.format(target_file)
89 print 'command: {0}'.format(command)
92 if len(sys.argv) != 2:
93 print 'usage: update_bios_settings.py <yaml>'
96 #create_rc_genesis("tools/j2/serverrc.j2", "rc")
97 create_rc_masters("tools/j2/serverrc_raid.j2", "rc.raid")
98 create_rc_workers("tools/j2/serverrc_raid.j2", "rc.raid")