- data = template.render(yaml=yaml)
- target_file = yaml['genesis']['name']+target_suffix
- fd2 = open(target_file,'w')
- fd2.write(data)
- fd2.write("\n")
- fd2.close()
- print '{0} -> {1}'.format(source, target_file)
-
-def create_rc_masters(source, target_suffix):
- env = jinja2.Environment()
- env.trim_blocks = True
- env.lstrip_blocks = True
-
- for master in yaml['masters']:
- with open(source) as fd:
- template = env.from_string(fd.read())
- data = template.render(yaml=master)
- target_file = "server-config/"+master['name']+target_suffix
- print target_file
- if os.path.exists(target_file):
- print 'rc file exists maynot be new node'
- continue
- if not os.path.exists(os.path.dirname(target_file)):
- os.makedirs(os.path.dirname(target_file))
- fd2 = open(target_file,'w')
- fd2.write(data)
- fd2.write("\n")
- fd2.close()
- print '{0} -> {1}'.format(source, target_file)
- command = '/opt/akraino/tools/apply_dellxml.sh --rc {0} --template dell_r740_g14_uefi_base.xml.template --no-confirm'.format(target_file)
- print 'command: {0}'.format(command)
- os.system(command)
-
-def create_rc_workers(source, target_suffix):
- env = jinja2.Environment()
- env.trim_blocks = True
- env.lstrip_blocks = True
-
- if 'workers' in yaml:
- for master in yaml['workers']:
- with open(source) as fd:
- template = env.from_string(fd.read())
- data = template.render(yaml=master)
- target_file = "server-config/"+master['name']+target_suffix
- print target_file
- if os.path.exists(target_file):
- print 'rc file exists maynot be new node'
- continue
- if not os.path.exists(os.path.dirname(target_file)):
- os.makedirs(os.path.dirname(target_file))
- fd2 = open(target_file,'w')
+
+ if type(nodes) is list:
+ for node in nodes:
+ newnode = dict( defaults.items() + node.items() )
+ data = template.render(yaml=newnode)
+ rcfile = "server-config/"+newnode['name']+rcfile_suffix
+ print rcfile
+ if os.path.exists(rcfile):
+ print 'warning: rc file {} exists. maynot be new node. overwriting file'.format(rcfile)
+ #continue
+ if not os.path.exists(os.path.dirname(rcfile)):
+ os.makedirs(os.path.dirname(rcfile),0600)
+ fd2 = open(rcfile,'w')