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
c82e27c7
Commit
c82e27c7
authored
9 years ago
by
Jérémie Gaidamour
Browse files
Options
Downloads
Patches
Plain Diff
[dev] Added --sites and --clusters options to check-cluster-homogeneity.rb
parent
0f86ce78
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generators/input-validators/check-cluster-homogeneity.rb
+32
-7
32 additions, 7 deletions
generators/input-validators/check-cluster-homogeneity.rb
with
32 additions
and
7 deletions
generators/input-validators/check-cluster-homogeneity.rb
+
32
−
7
View file @
c82e27c7
...
@@ -112,7 +112,9 @@ def cluster_ignore_keys(filename)
...
@@ -112,7 +112,9 @@ def cluster_ignore_keys(filename)
return
file_hash
return
file_hash
end
end
def
cluster_homogeneity
(
refapi_hash
,
verbose
=
false
)
def
cluster_homogeneity
(
refapi_hash
,
options
=
{
:verbose
=>
false
})
verbose
=
options
[
:verbose
]
if
verbose
if
verbose
puts
"The change set is represented using the following syntax:"
puts
"The change set is represented using the following syntax:"
puts
' [["+", "path.to.key1", value], # new key'
puts
' [["+", "path.to.key1", value], # new key'
...
@@ -128,9 +130,13 @@ def cluster_homogeneity(refapi_hash, verbose=false)
...
@@ -128,9 +130,13 @@ def cluster_homogeneity(refapi_hash, verbose=false)
count
=
{}
count
=
{}
refapi_hash
[
"sites"
].
sort
.
each
do
|
site_uid
,
site
|
refapi_hash
[
"sites"
].
sort
.
each
do
|
site_uid
,
site
|
next
if
options
.
key?
(
:sites
)
&&
!
options
[
:sites
].
include?
(
site_uid
)
count
[
site_uid
]
=
{}
count
[
site_uid
]
=
{}
site
[
"clusters"
].
sort
.
each
do
|
cluster_uid
,
cluster
|
site
[
"clusters"
].
sort
.
each
do
|
cluster_uid
,
cluster
|
next
if
options
.
key?
(
:clusters
)
&&
!
options
[
:clusters
].
include?
(
cluster_uid
)
count
[
site_uid
][
cluster_uid
]
=
0
count
[
site_uid
][
cluster_uid
]
=
0
refnode_uid
=
cluster
[
'nodes'
].
keys
.
sort
.
first
refnode_uid
=
cluster
[
'nodes'
].
keys
.
sort
.
first
...
@@ -189,10 +195,11 @@ def cluster_homogeneity(refapi_hash, verbose=false)
...
@@ -189,10 +195,11 @@ def cluster_homogeneity(refapi_hash, verbose=false)
return
count
return
count
end
end
def
check_cluster_homogeneity
(
refapi_hash
,
verbose
=
false
)
def
check_cluster_homogeneity
(
refapi_hash
,
options
=
{
:verbose
=>
false
})
verbose
=
options
[
:verbose
]
puts
"Differences found between successive nodes, per cluster:
\n\n
"
puts
"Differences found between successive nodes, per cluster:
\n\n
"
count
=
cluster_homogeneity
(
refapi_hash
,
verbose
)
count
=
cluster_homogeneity
(
refapi_hash
,
options
)
puts
"
\n
"
if
verbose
puts
"
\n
"
if
verbose
puts
count
.
to_yaml
unless
verbose
puts
count
.
to_yaml
unless
verbose
...
@@ -206,26 +213,44 @@ if __FILE__ == $0
...
@@ -206,26 +213,44 @@ if __FILE__ == $0
require
'optparse'
require
'optparse'
options
=
{}
options
=
{}
options
[
:sites
]
=
%w{grenoble lille luxembourg lyon nancy nantes reims rennes sophia}
OptionParser
.
new
do
|
opts
|
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: check-cluster-homogeneity.rb [options]"
opts
.
banner
=
"Usage: check-cluster-homogeneity.rb [options]"
opts
.
separator
""
opts
.
separator
""
opts
.
separator
"Example: ruby check-cluster-homogeneity.rb -v"
opts
.
separator
"Example: ruby check-cluster-homogeneity.rb -v"
###
opts
.
separator
""
opts
.
separator
""
opts
.
separator
"Filters:"
opts
.
on
(
'-s'
,
'--sites a,b,c'
,
Array
,
'Select site(s)'
,
"Default: "
+
options
[
:sites
].
join
(
", "
))
do
|
s
|
raise
"Wrong argument for -s option."
unless
(
s
-
options
[
:sites
]).
empty?
options
[
:sites
]
=
s
end
opts
.
on
(
'-c'
,
'--clusters a,b,c'
,
Array
,
'Select clusters(s). Default: all'
)
do
|
s
|
options
[
:clusters
]
=
s
end
opts
.
separator
""
opts
.
separator
"Common options:"
opts
.
on
(
"-v"
,
"--[no-]verbose"
,
"Run verbosely"
)
do
|
v
|
opts
.
on
(
"-v"
,
"--[no-]verbose"
,
"Run verbosely"
)
do
|
v
|
options
[
:verbose
]
||=
0
options
[
:verbose
]
||=
0
options
[
:verbose
]
=
options
[
:verbose
]
+
1
options
[
:verbose
]
=
options
[
:verbose
]
+
1
end
end
# Print an options summary.
# Print an options summary.
opts
.
on_tail
(
"-h"
,
"--help"
,
"Show this message"
)
do
opts
.
on_tail
(
"-h"
,
"--help"
,
"Show this message"
)
do
puts
opts
puts
opts
exit
exit
end
end
end
.
parse!
end
.
parse!
refapi_hash
=
load_yaml_file_hierarchy
(
"
#{
dir
}
/../../input/grid5000/"
)
refapi_hash
=
load_yaml_file_hierarchy
(
"
#{
dir
}
/../../input/grid5000/"
)
check_cluster_homogeneity
(
refapi_hash
,
options
.
key?
(
:verbose
)
)
check_cluster_homogeneity
(
refapi_hash
,
options
)
end
end
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