Commit b68b7aff authored by Jérémie Gaidamour's avatar Jérémie Gaidamour
Browse files

[dev] Added an option for ssh keys

parent 4d519e3d
......@@ -196,7 +196,7 @@ end
# Get the OAR properties from the OAR scheduler
# This is only needed for the -d option
def oarcmd_get_nodelist_properties(site_uid, filename=nil)
def oarcmd_get_nodelist_properties(site_uid, filename=nil, sshkeys=[])
oarnodes_yaml = ""
if filename and File.exist?(filename)
......@@ -207,7 +207,7 @@ def oarcmd_get_nodelist_properties(site_uid, filename=nil)
# Download the oar properties from the oar server
puts "Downloading 'oarnodes -Y' from oar.#{site_uid}.g5kadmin ..."
Net::SSH.start("oar.#{site_uid}.g5kadmin", 'g5kadmin', :keys => ['~/.ssh/id_rsa_g5kadmin.pub']) { |ssh|
Net::SSH.start("oar.#{site_uid}.g5kadmin", 'g5kadmin', :keys => sshkeys) { |ssh|
# capture all stderr and stdout output from a remote process
oarnodes_yaml = ssh.exec!('oarnodes -Y')
}
......
......@@ -19,6 +19,7 @@ require '../lib/input_loader'
options = {}
options[:sites] = %w{grenoble lille luxembourg lyon nancy nantes reims rennes sophia}
options[:diff] = false
options[:sshkeys] = []
OptionParser.new do |opts|
opts.banner = "Usage: oar-properties.rb [options]"
......@@ -57,6 +58,10 @@ OptionParser.new do |opts|
opts.on('-e', '--exec', 'Directly apply the changes to the OAR server') do |e|
options[:exec] = e
end
opts.on('-k', '--ssh-keys k1,k2,k3', Array, 'SSH keys') do |k|
options[:sshkeys] = k
end
opts.on("-d", "--diff [YAML filename]",
"Only generates the minimal list of commands needed to update the site configuration",
......@@ -112,7 +117,7 @@ options[:sites].each { |site_uid|
# This is only needed for the -d option
if options[:diff]
filename = options[:diff].is_a?(String) ? options[:diff].gsub("%s", site_uid) : nil
nodelist_properties["oar"][site_uid] = oarcmd_get_nodelist_properties(site_uid, filename)
nodelist_properties["oar"][site_uid] = oarcmd_get_nodelist_properties(site_uid, filename, options[:sshkeys])
end
}
......@@ -191,7 +196,7 @@ if options[:exec]
nodelist_properties[opt].each { |site_uid, site_properties|
puts "Connecting #{site_uid} ..."
Net::SSH.start("oar.#{site_uid}.g5kadmin", 'g5kadmin', :keys => ['~/.ssh/id_rsa_g5kadmin.pub']) { |ssh|
Net::SSH.start("oar.#{site_uid}.g5kadmin", 'g5kadmin', :keys => options[:sshkeys]) { |ssh|
site_properties.each_filtered_node_uid(options[:clusters], options[:nodes]) { |node_uid, node_properties|
cmd = oarcmd_set_node_properties(node_uid, node_properties)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment