Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9cc1f161 authored by JACQUOT Pierre's avatar JACQUOT Pierre
Browse files

Merge branch 'oxidizeg5k' into 'master'

Oxidize: Generate oxidize configuration with SSH KexAlgorithm

See merge request !604
parents ecd97c6d 825ac88e
No related branches found
No related tags found
1 merge request!604Oxidize: Generate oxidize configuration with SSH KexAlgorithm
Pipeline #884885 passed
...@@ -18,10 +18,39 @@ def generate_puppet_oxidizedg5k(options) ...@@ -18,10 +18,39 @@ def generate_puppet_oxidizedg5k(options)
if not conf if not conf
warn "No generator configuration for oxidized found in #{options[:conf_dir]}/oxidizedg5k.yaml, skipping oxidized" warn "No generator configuration for oxidized found in #{options[:conf_dir]}/oxidizedg5k.yaml, skipping oxidized"
else else
config_lines = generate_config_lines(conf)
output = ERB.new(File.read(File.expand_path('templates/oxidized.db.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding) output = ERB.new(File.read(File.expand_path('templates/oxidized.db.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/oxidized/oxidized.db") output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/oxidized/oxidized.db")
output_file.dirname.mkpath() output_file.dirname.mkpath()
File.write(output_file, output) File.write(output_file, output)
end end
end
def generate_config_lines(conf)
lines = []
conf.each do |site, groups|
groups.each do |group,devices|
devices.each do |device,values|
missing_info = ["driver","user","password"] - values.keys
if missing_info.length != 0
puts "Skipping #{device}.#{site}, missing #{missing_info}"
next
else
lines << build_line(site, group, device, values)
end
end
end
end
return lines
end
def build_line(site, group, device, hash)
name = device + '.' + site
group_name = site + '-' + group
enable = hash.has_key?('enable') ? hash['enable'] : false
config = [name, group_name, hash['driver'], hash['user'], hash['password'], enable]
if hash.has_key?('ssh_kex')
config << hash['ssh_kex']
end
return config.join(':')
end end
...@@ -5,19 +5,6 @@ ...@@ -5,19 +5,6 @@
### false = already in exec mode ### false = already in exec mode
### true = need the "enable" cmd without password ### true = need the "enable" cmd without password
### p4ssword : the enable password ### p4ssword : the enable password
<%- <%- config_lines.each do |line| -%>
conf.each do |site, groups| <%= line %>
groups.each do |g,devices|
devices.each do |d,v|
missing_info = ["driver","user","password"] - v.keys
if missing_info.length != 0
puts "Skipping #{d}.#{site}, missing #{missing_info.to_s}"
next
else
enable = v.has_key?('enable') ? v['enable'] : false
-%>
<%=[d+'.'+site,site+"-"+g,v['driver'],v['user'],v['password'],enable].join(':') %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%> <%- end -%>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment