Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
reference-repository
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
grid5000
reference-repository
Commits
620be301
Commit
620be301
authored
14 years ago
by
Gaetan SIMO
Browse files
Options
Downloads
Patches
Plain Diff
[lib] Enabling dns resolution over ssh.
parent
005244c8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Gemfile
+1
-0
1 addition, 0 deletions
Gemfile
Gemfile.lock
+2
-0
2 additions, 0 deletions
Gemfile.lock
generators/lib/g5k_generator.rb
+42
-0
42 additions, 0 deletions
generators/lib/g5k_generator.rb
with
45 additions
and
0 deletions
Gemfile
+
1
−
0
View file @
620be301
source
:rubygems
gem
'
json_pure
'
,
'~> 1.5'
gem
'
net-ssh
'
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Gemfile.lock
+
2
−
0
View file @
620be301
...
...
@@ -2,9 +2,11 @@ GEM
remote: http://rubygems.org/
specs:
json_pure (1.5.1)
net-ssh (2.1.0)
PLATFORMS
ruby
DEPENDENCIES
json_pure (~> 1.5)
net-ssh
This diff is collapsed.
Click to expand it.
generators/lib/g5k_generator.rb
+
42
−
0
View file @
620be301
...
...
@@ -63,7 +63,49 @@ module G5K
def
dns_lookup
(
network_address
)
Resolv
.
getaddress
(
network_address
)
end
# Remotly execute commands, and retrieve stdout, stderr and exit code.
def
ssh_exec!
(
ssh
,
command
)
stdout_data
=
""
stderr_data
=
""
exit_code
=
nil
exit_signal
=
nil
ssh
.
open_channel
do
|
channel
|
channel
.
exec
(
command
)
do
|
ch
,
success
|
unless
success
abort
"FAILED: couldn't execute command (ssh.channel.exec)"
end
channel
.
on_data
do
|
ch
,
data
|
stdout_data
+=
data
end
channel
.
on_extended_data
do
|
ch
,
type
,
data
|
stderr_data
+=
data
end
channel
.
on_request
(
"exit-status"
)
do
|
ch
,
data
|
exit_code
=
data
.
read_long
end
channel
.
on_request
(
"exit-signal"
)
do
|
ch
,
data
|
exit_signal
=
data
.
read_long
end
end
end
ssh
.
loop
[
stdout_data
,
stderr_data
,
exit_code
,
exit_signal
]
end
# Get the IP address corresponding to the host fqdn throught ssh channel
def
dns_lookup_through_ssh
(
ssh
,
fqdn
)
results
=
ssh_exec!
ssh
,
"host
#{
fqdn
}
"
if
results
[
2
]
==
0
results
[
0
].
split
(
" "
).
reverse
[
0
]
else
fail
"Failed to get ip address of '
#{
fqdn
}
' :
#{
results
[
1
]
}
"
end
end
# Lookup a key in one of the configuration files passed to the generator
#
# Usage:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment