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
Show more breadcrumbs
grid5000
reference-repository
Commits
2181f487
Commit
2181f487
authored
3 years ago
by
Samir Noir
Browse files
Options
Downloads
Patches
Plain Diff
[scripts] fix some errors in edit-input-files script
parent
61623529
Branches
Branches containing commit
No related tags found
1 merge request
!267
WIP: [all] add SR-IOV detection on network interfaces
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/edit-input-files.rb
+22
-16
22 additions, 16 deletions
scripts/edit-input-files.rb
with
22 additions
and
16 deletions
scripts/edit-input-files.rb
+
22
−
16
View file @
2181f487
...
@@ -9,7 +9,7 @@ require 'erb'
...
@@ -9,7 +9,7 @@ require 'erb'
require
'fileutils'
require
'fileutils'
require
'pathname'
require
'pathname'
require
'yaml'
require
'yaml'
require
'.
.
/lib/hash/hash'
require
'./lib/
refrepo/
hash/hash'
if
RUBY_VERSION
<
"2.1"
if
RUBY_VERSION
<
"2.1"
puts
"This script requires ruby >= 2.1"
puts
"This script requires ruby >= 2.1"
...
@@ -50,32 +50,38 @@ end.parse!
...
@@ -50,32 +50,38 @@ end.parse!
if
options
[
:site
].
empty?
||
options
[
:clusters
].
empty?
if
options
[
:site
].
empty?
||
options
[
:clusters
].
empty?
puts
"Not copying anything, post-processing file from 'output'"
puts
"Not copying anything, post-processing file from 'output'"
else
else
options
[
:clusters
].
each
{
|
cluster_uid
|
FileUtils
.
mkdir_p
'output'
node_files
=
Dir
[
"../../input/grid5000/sites/
#{
options
[
:site
]
}
/clusters/
#{
cluster_uid
}
/nodes/*.yaml"
]
options
[
:clusters
].
each
do
|
cluster_uid
|
node_files
.
each
{
|
f
|
node_files
=
Dir
[
"./input/grid5000/sites/
#{
options
[
:site
]
}
/clusters/
#{
cluster_uid
}
/nodes/*.yaml"
]
node_files
.
each
do
|
f
|
filename
=
[
f
.
split
(
"/"
).
last
.
split
(
"."
).
first
,
options
[
:site
],
"grid5000"
,
"fr"
,
"yaml"
].
join
(
"."
)
filename
=
[
f
.
split
(
"/"
).
last
.
split
(
"."
).
first
,
options
[
:site
],
"grid5000"
,
"fr"
,
"yaml"
].
join
(
"."
)
puts
"Copying
#{
filename
}
to output/"
puts
"Copying
#{
filename
}
to output/"
FileUtils
.
cp
(
f
,
"./output/
#{
filename
}
"
)
FileUtils
.
cp
(
f
,
"./output/
#{
filename
}
"
)
}
end
}
end
end
end
##Modify node yaml hash here
##Modify node yaml hash here
def
modify_node_data
(
hash
,
node_uid
,
cluster_uid
,
site_uid
)
#rubocop:disable Lint/UnusedMethodArgument
def
modify_node_data
(
hash
,
node_uid
,
cluster_uid
,
site_uid
)
#rubocop:disable Lint/UnusedMethodArgument
#example content:
#example content:
hash
[
"network_adapters"
].
each
{
|
na_id
,
na
|
hash
[
"network_adapters"
].
each
do
|
na_id
,
na
|
if
(
na_id
==
"ib0"
&&
na
[
"firmware_version"
]
!=
"2.7.700"
)
if
!
na
[
'management'
]
&&
!
na
[
'sriov'
]
&&
na
[
'interface'
]
==
'Ethernet'
puts
"
#{
node_uid
}
"
+
na
.
inspect
if
na_id
==
'eth0'
||
na_id
==
'eth1'
na
[
"firmware_version"
]
=
"2.7.700"
na
[
'sriov'
]
=
true
# na["mac"] = "80:00:02:0a:fe:" + na["mac"].split(":")[5..20].join(":")
na
[
'sriov_totalvfs'
]
=
63
else
na
[
'sriov'
]
=
true
na
[
'sriov_totalvfs'
]
=
7
end
end
end
}
end
hash
hash
end
end
list_of_yaml_files
=
Dir
[
'output/*.y*ml'
].
sort_by
{
|
x
|
-
x
.
count
(
'/'
)
}
list_of_yaml_files
=
Dir
[
'output/*.y*ml'
].
sort_by
{
|
x
|
-
x
.
count
(
'/'
)
}
list_of_yaml_files
.
each
{
|
filename
|
list_of_yaml_files
.
each
do
|
filename
|
begin
begin
file
=
filename
.
split
(
"/"
)[
1
]
file
=
filename
.
split
(
"/"
)[
1
]
node_uid
=
file
.
split
(
"."
)[
0
]
node_uid
=
file
.
split
(
"."
)[
0
]
...
@@ -96,7 +102,7 @@ list_of_yaml_files.each { |filename|
...
@@ -96,7 +102,7 @@ list_of_yaml_files.each { |filename|
hash
=
{
node_uid
=>
hash
}
hash
=
{
node_uid
=>
hash
}
new_filename
=
Pathname
(
".
./..
/input/grid5000/sites/
#{
site_uid
}
/clusters/
#{
cluster_uid
}
/nodes/"
+
node_uid
+
".yaml"
)
new_filename
=
Pathname
(
"./input/grid5000/sites/
#{
site_uid
}
/clusters/
#{
cluster_uid
}
/nodes/"
+
node_uid
+
".yaml"
)
new_filename
.
dirname
.
mkpath
()
new_filename
.
dirname
.
mkpath
()
...
@@ -105,14 +111,14 @@ list_of_yaml_files.each { |filename|
...
@@ -105,14 +111,14 @@ list_of_yaml_files.each { |filename|
contents
=
File
.
read
(
new_filename
)
contents
=
File
.
read
(
new_filename
)
File
.
open
(
new_filename
,
'w'
)
{
|
fd
|
File
.
open
(
new_filename
,
'w'
)
{
|
fd
|
fd
.
write
(
"# Generated by g5k-checks (g5k-checks -m api)
\n
"
)
fd
.
write
(
"# Generated by g5k-checks (g5k-checks -m api)
\n
"
)
fd
.
write
(
contents
)
fd
.
write
(
contents
)
}
}
rescue
StandardError
=>
e
rescue
StandardError
=>
e
puts
"
#{
node_uid
}
-
#{
e
.
class
}
:
#{
e
.
message
}
"
puts
"
#{
node_uid
}
-
#{
e
.
class
}
:
#{
e
.
message
}
"
puts
e
.
backtrace
puts
e
.
backtrace
end
end
}
end
if
options
[
:rm_output
]
if
options
[
:rm_output
]
puts
"Cleaning up output directory"
puts
"Cleaning up output directory"
...
...
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