Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
reference-repository
Commits
b68b7aff
Commit
b68b7aff
authored
Mar 08, 2016
by
Jérémie Gaidamour
Browse files
[dev] Added an option for ssh keys
parent
4d519e3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
generators/oar-properties/lib/lib-oar-properties.rb
View file @
b68b7aff
...
...
@@ -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'
)
}
...
...
generators/oar-properties/oar-properties.rb
View file @
b68b7aff
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment