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 if 'masters' in yaml and type(yaml['masters']) is list:
47 for master in yaml['masters']:
48 with open(source) as fd:
49 template = env.from_string(fd.read())
50 data = template.render(yaml=master)
51 target_file = "server-config/"+master['name']+target_suffix
53 if os.path.exists(target_file):
54 print 'rc file exists maynot be new node'
56 if not os.path.exists(os.path.dirname(target_file)):
57 os.makedirs(os.path.dirname(target_file))
58 fd2 = open(target_file,'w')
62 print '{0} -> {1}'.format(source, target_file)
63 command = '/opt/akraino/tools/apply_dellxml.sh --rc {0} --template dell_r740_g14_uefi_base.xml.template --no-confirm'.format(target_file)
64 print 'command: {0}'.format(command)
67 def create_rc_workers(source, target_suffix):
68 env = jinja2.Environment()
69 env.trim_blocks = True
70 env.lstrip_blocks = True
72 if 'workers' in yaml and type(yaml['workers']) is list:
73 for worker in yaml['workers']:
74 with open(source) as fd:
75 template = env.from_string(fd.read())
76 data = template.render(yaml=worker)
77 target_file = "server-config/"+worker['name']+target_suffix
79 if os.path.exists(target_file):
80 print 'rc file exists maynot be new node'
82 if not os.path.exists(os.path.dirname(target_file)):
83 os.makedirs(os.path.dirname(target_file))
84 fd2 = open(target_file,'w')
88 print '{0} -> {1}'.format(source, target_file)
89 command = '/opt/akraino/tools/apply_dellxml.sh --rc {0} --template dell_r740_g14_uefi_base.xml.template --no-confirm'.format(target_file)
90 print 'command: {0}'.format(command)
93 if len(sys.argv) != 2:
94 print 'usage: update_bios_settings.py <yaml>'
97 #create_rc_genesis("tools/j2/serverrc.j2", "rc")
98 create_rc_masters("tools/j2/serverrc_raid.j2", "rc.raid")
99 create_rc_workers("tools/j2/serverrc_raid.j2", "rc.raid")