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
8ac9a3be
Commit
8ac9a3be
authored
9 years ago
by
Jérémie Gaidamour
Browse files
Options
Downloads
Patches
Plain Diff
[dev] Pretty output
parent
d7b19765
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generators/oar-properties/oar-properties.rb
+41
-16
41 additions, 16 deletions
generators/oar-properties/oar-properties.rb
with
41 additions
and
16 deletions
generators/oar-properties/oar-properties.rb
+
41
−
16
View file @
8ac9a3be
...
...
@@ -17,7 +17,7 @@ require '../oar-properties/lib/lib-oar-properties'
require
'../lib/input_loader'
options
=
{}
options
[
:sites
]
=
%w{grenoble lille luxembourg lyon nantes reims rennes sophia}
options
[
:sites
]
=
%w{grenoble lille luxembourg lyon
nancy
nantes reims rennes sophia}
options
[
:diff
]
=
false
OptionParser
.
new
do
|
opts
|
...
...
@@ -33,6 +33,7 @@ OptionParser.new do |opts|
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
...
...
@@ -67,17 +68,14 @@ OptionParser.new do |opts|
options
[
:diff
]
=
d
end
# opts.on("-n", "--dry-run", "Perform a trial run with no changes made") do |n|
# options[:dryrun] = n
# end
###
opts
.
separator
""
opts
.
separator
"Common options:"
opts
.
on
(
"-v"
,
"--[no-]verbose"
,
"Run verbosely"
)
do
|
v
|
options
[
:verbose
]
=
v
opts
.
on
(
"-v"
,
"--[no-]verbose"
,
"Run verbosely"
,
"Multiple -v options increase the verbosity. The maximum is 3."
)
do
|
v
|
options
[
:verbose
]
||=
0
options
[
:verbose
]
=
options
[
:verbose
]
+
1
end
# Print an options summary.
...
...
@@ -87,7 +85,7 @@ OptionParser.new do |opts|
end
end
.
parse!
p
p
options
p
uts
"Options:
#{
options
}
"
if
options
[
:verbose
]
nodelist_properties
=
{}
# ["ref"] : properties from the reference-repo
# ["oar"] : properties from the OAR server
...
...
@@ -121,6 +119,8 @@ options[:sites].each { |site_uid|
#
# Diff
#
header
||=
false
prev_diff
=
{}
nodelist_properties
[
"to_be_updated"
]
=
{}
...
...
@@ -130,23 +130,48 @@ nodelist_properties["ref"].each { |site_uid, site_properties|
node_properties_oar
=
nodelist_properties
[
"oar"
][
site_uid
][
node_uid
]
diff
=
diff_node_properties
(
node_properties_
ref
,
node_properties_
oar
)
diff
=
diff_node_properties
(
node_properties_
oar
,
node_properties_
ref
)
diff_keys
=
diff
.
map
{
|
hashdiff_array
|
hashdiff_array
[
1
]
}
nodelist_properties
[
"to_be_updated"
][
node_uid
]
=
node_properties_ref
.
select
{
|
key
,
value
|
diff_keys
.
include?
(
key
)
}
if
(
options
[
:verbose
]
)
#puts "#{node_uid}: #{diff}"
case
options
[
:verbose
]
when
1
puts
"
#{
node_uid
}
:
#{
diff_keys
}
"
when
2
# Give more details
# puts "#{node_uid}: #{diff}"
if
!
header
header
=
true
puts
"Output format: ['~', 'key', 'old value', 'new value']"
end
if
diff
.
size
==
0
puts
"
#{
node_uid
}
: OK"
elsif
diff
==
prev_diff
puts
"
#{
node_uid
}
: as above"
else
puts
"
#{
node_uid
}
:"
diff
.
each
{
|
d
|
puts
"
#{
d
}
"
}
end
prev_diff
=
diff
when
3
# Even more details
puts
JSON
.
pretty_generate
({
node_uid
=>
{
"old values"
=>
node_properties_oar
,
"new values"
=>
node_properties_oar
}})
end
}
}
#
#
Example
#
Output commands
#
#puts oarcmd_set_node_properties("graphene-1", node_properties["oar"])
#puts oarcmd_set_node_properties("graphene-1", node_properties["to_be_updated"])
# nodelist_properties["ref"].each { |site_uid, site_properties|
# site_properties.each_filtered_node_uid(options[:clusters], options[:nodes]) { |node_uid, node_properties_ref|
# puts oarcmd_set_node_properties("graphene-1", node_properties["oar"])
# puts oarcmd_set_node_properties("graphene-1", node_properties["to_be_updated"])
# }
# }
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