Skip to content

Commit

Permalink
Merge branch 'fixrubocop' into 'master'
Browse files Browse the repository at this point in the history
Fixrubocop

See merge request grid5000/reference-repository!418
  • Loading branch information
petitalb committed Oct 17, 2022
2 parents ace1c51 + 98069c0 commit 4cf53fc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
@@ -1,6 +1,3 @@
---
Lint/UnusedBlockArgument:
Severity: convention

Lint/ErbNewArguments:
Enabled: false
2 changes: 1 addition & 1 deletion lib/refrepo/gen/puppet/dhcpg5k.rb
Expand Up @@ -42,7 +42,7 @@ def write_dhcp_files(data, options)
end

["dhcp", "dhcpv6"].each { |dhcpkind|
output = ERB.new(File.read(File.expand_path("templates/dhcp.erb", File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path("templates/dhcp.erb", File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}/platforms/production/modules/generated/files/grid5000/#{dhcpkind}/#{data.fetch("site_uid")}/#{data.fetch('filename')}")
output_file.dirname.mkpath()
File.write(output_file, output)
Expand Down
2 changes: 1 addition & 1 deletion lib/refrepo/gen/puppet/kadeployg5k.rb
Expand Up @@ -150,7 +150,7 @@ def generate_puppet_kadeployg5k(options)
next
end

output = ERB.new(File.read(File.expand_path('templates/kadeployg5k.conf.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kadeployg5k.conf.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)

output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kadeploy/server#{suffix.tr('-', '_')}/#{site_uid}/#{cluster_uid}-cluster.conf")

Expand Down
10 changes: 5 additions & 5 deletions lib/refrepo/gen/puppet/kavlang5k.rb
Expand Up @@ -44,24 +44,24 @@ def generate_puppet_kavlang5k(options)

next unless options[:sites].include?(site_uid)

conf = YAML::load(ERB.new(File.read("#{options[:conf_dir]}/kavlang5k.yaml"), nil, '-').result(binding))[site_uid]
conf = YAML::load(ERB.new(File.read("#{options[:conf_dir]}/kavlang5k.yaml"), trim_mode: '-').result(binding))[site_uid]
if not conf
warn "No generator configuration for site #{site_uid} found in #{options[:conf_dir]}/kavlang5k.yaml, skipping kavlan.conf"
else
output = ERB.new(File.read(File.expand_path('templates/kavlan.conf.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kavlan.conf.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kavlan/#{site_uid}/kavlan.conf")
output_file.dirname.mkpath()
File.write(output_file, output)
end

output = ERB.new(File.read(File.expand_path('templates/kavlan-cluster.conf.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kavlan-cluster.conf.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kavlan/#{site_uid}/#{site_uid}.conf")
output_file.dirname.mkpath()
File.write(output_file, output)

(1..9).each do |kavlan_id|
["dhcpd", "dhcpd6"].each { |dhcpkind|
output = ERB.new(File.read(File.expand_path('templates/kavlan-dhcp.conf.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kavlan-dhcp.conf.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kavlan/#{site_uid}/dhcp/#{dhcpkind}-#{kavlan_id}.conf")
output_file.dirname.mkpath()
File.write(output_file, output)
Expand All @@ -72,7 +72,7 @@ def generate_puppet_kavlang5k(options)
# TODO fix dirty convertion to_i below
kavlan_id = refapi['sites'][site_uid]['kavlans'].each_key.select {|k| k.to_i > 9}.pop().to_i
["dhcpd", "dhcpd6"].each { |dhcpkind|
output = ERB.new(File.read(File.expand_path('templates/kavlan-dhcp.conf.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kavlan-dhcp.conf.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kavlan/#{site_uid}/dhcp/#{dhcpkind}-0.conf")
File.write(output_file, output)
}
Expand Down
8 changes: 4 additions & 4 deletions lib/refrepo/gen/puppet/kwollectg5k.rb
Expand Up @@ -39,7 +39,7 @@ def generate_puppet_kwollectg5k(options)
ipmi_credentials.map! { |s| ERB::Util.url_encode(s) }
ipmi_credentials = ipmi_credentials.join(":")

output = ERB.new(File.read(File.expand_path('templates/kwollect-node.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kwollect-node.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kwollect/#{site_uid}/#{node_uid}.conf")
output_file.dirname.mkpath()
File.write(output_file, output)
Expand All @@ -49,7 +49,7 @@ def generate_puppet_kwollectg5k(options)
# Metrics configuration for network device
site['network_equipments'].each { |neteq_uid, neteq|

output = ERB.new(File.read(File.expand_path('templates/kwollect-network.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kwollect-network.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kwollect/#{site_uid}/#{neteq_uid}.conf")
output_file.dirname.mkpath()
File.write(output_file, output)
Expand All @@ -74,7 +74,7 @@ def generate_puppet_kwollectg5k(options)
## Then, write PDU metrics config
site.fetch('pdus', {}).each { |pdu_uid, pdu|

output = ERB.new(File.read(File.expand_path('templates/kwollect-pdu.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kwollect-pdu.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kwollect/#{site_uid}/#{pdu_uid}.conf")
output_file.dirname.mkpath()
File.write(output_file, output)
Expand All @@ -94,7 +94,7 @@ def generate_puppet_kwollectg5k(options)
}
}
if not wattmetre_port_per_node.empty?
output = ERB.new(File.read(File.expand_path('templates/kwollect-wattmetre-mapping.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output = ERB.new(File.read(File.expand_path('templates/kwollect-wattmetre-mapping.erb', File.dirname(__FILE__))), trim_mode: '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kwollect-wattmetre/#{site_uid}/wattmetre-mapping.conf")
output_file.dirname.mkpath()
File.write(output_file, output)
Expand Down
2 changes: 1 addition & 1 deletion lib/refrepo/gen/puppet/oxidizedg5k.rb
Expand Up @@ -18,7 +18,7 @@ def generate_puppet_oxidizedg5k(options)
if not conf
warn "No generator configuration for oxidized found in #{options[:conf_dir]}/oxidizedg5k.yaml, skipping oxidized"
else
output = ERB.new(File.read(File.expand_path('templates/oxidized.db.erb', File.dirname(__FILE__))), nil, '-').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.dirname.mkpath()
File.write(output_file, output)
Expand Down

0 comments on commit 4cf53fc

Please sign in to comment.