Skip to content

Commit 6d131a8

Browse files
author
Lucas Nussbaum
committed
[dev] OAR properties generator: unify DO= arguments with other generators
1 parent 6130626 commit 6d131a8

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Rakefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace :gen do
125125
exit(ret)
126126
end
127127

128-
desc "Generate OAR properties -- parameters: [SITE={grenoble,...}] [CLUSTER={yeti,...}] [NODE={dahu-1,...}] DO={output,exec,diff} [VERBOSE={0,1,2,3}]"
128+
desc "Generate OAR properties -- parameters: [SITE={grenoble,...}] [CLUSTER={yeti,...}] [NODE={dahu-1,...}] DO={diff,print,update} [VERBOSE={0,1,2,3}]"
129129
task "oar-properties" do
130130
require 'refrepo/gen/oar-properties'
131131
options = {}
@@ -140,14 +140,14 @@ namespace :gen do
140140
options[:ssh] ||= {}
141141
options[:ssh][:host] = ENV['OAR_SERVER']
142142
end
143-
options[:output] = false
144143
options[:diff] = false
145-
options[:exec] = false
144+
options[:print] = false
145+
options[:update] = false
146146
if ENV['DO']
147147
ENV['DO'].split(',').each do |t|
148148
options[:diff] = true if t == 'diff'
149-
options[:output] = true if t == 'output'
150-
options[:exec] = true if t == 'exec'
149+
options[:print] = true if t == 'print'
150+
options[:update] = true if t == 'update'
151151
end
152152
else
153153
puts "You must specify something to do using DO="

lib/refrepo/gen/oar-properties.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def generate_oar_properties(options)
629629

630630
if missings_alive.size > 0
631631
puts "*** Error: The following nodes exist in the OAR server but are missing in the reference-repo: #{missings_alive.join(', ')}.\n"
632-
ret = false unless options[:exec] || options[:output]
632+
ret = false unless options[:update] || options[:print]
633633
end
634634

635635
skipped_nodes = []
@@ -684,7 +684,7 @@ def generate_oar_properties(options)
684684
puts JSON.pretty_generate(key => { 'old values' => properties_oar, 'new values' => properties_ref })
685685
end
686686
if diff.size != 0
687-
ret = false unless options[:exec] || options[:output]
687+
ret = false unless options[:update] || options[:print]
688688
end
689689
end
690690
end
@@ -700,7 +700,7 @@ def generate_oar_properties(options)
700700
if v_oar && v_oar != v_ref && v_ref != NilClass && v_oar != NilClass
701701
# Detect inconsistency between the type (String/Fixnum) of properties generated by this script and the existing values on the server.
702702
puts "Error: the OAR property '#{k}' is a '#{v_oar}' on the #{site_uid} server and this script uses '#{v_ref}' for this property."
703-
ret = false unless options[:exec] || options[:output]
703+
ret = false unless options[:update] || options[:print]
704704
end
705705
end
706706

@@ -715,19 +715,19 @@ def generate_oar_properties(options)
715715
if options[:verbose] && unknown_properties.size > 0
716716
puts "Properties existing on the #{site_uid} server but not managed/known by the generator: #{unknown_properties.to_a.join(', ')}."
717717
puts "Hint: you can delete properties with 'oarproperty -d <property>' or add them to the ignore list in lib/lib-oar-properties.rb."
718-
ret = false unless options[:exec] || options[:output]
718+
ret = false unless options[:update] || options[:print]
719719
end
720720
puts "Skipped retired nodes: #{skipped_nodes}" if skipped_nodes.any?
721721
end # if options[:diff]
722722
end
723723

724724
# Build and execute commands
725-
if options[:output] || options[:exec]
725+
if options[:print] || options[:update]
726726
skipped_nodes = [] unless options[:diff]
727727
opt = options[:diff] ? 'diff' : 'ref'
728728

729729
properties[opt].each do |site_uid, site_properties|
730-
options[:output].is_a?(String) ? o = File.open(options[:output].gsub('%s', site_uid), 'w') : o = $stdout.dup
730+
options[:print].is_a?(String) ? o = File.open(options[:print].gsub('%s', site_uid), 'w') : o = $stdout.dup
731731

732732
ssh_cmd = []
733733
cmd = []
@@ -767,8 +767,8 @@ def generate_oar_properties(options)
767767
cmd << oarcmd_set_node_properties(node_address, node_properties)
768768
cmd << oarcmd_separator
769769
end
770-
ssh_cmd += cmd if options[:exec]
771-
o.write(cmd.join('')) if options[:output]
770+
ssh_cmd += cmd if options[:update]
771+
o.write(cmd.join('')) if options[:print]
772772
cmd = []
773773
end
774774

@@ -792,14 +792,14 @@ def generate_oar_properties(options)
792792
cmd << oarcmd_separator
793793
end
794794

795-
ssh_cmd += cmd if options[:exec]
796-
o.write(cmd.join('')) if options[:output]
795+
ssh_cmd += cmd if options[:update]
796+
o.write(cmd.join('')) if options[:print]
797797
cmd = []
798798
end
799799
o.close
800800

801801
# Execute commands
802-
if options[:exec]
802+
if options[:update]
803803
printf 'Apply changes to the OAR server ' + options[:ssh][:host].gsub('%s', site_uid) + ' ? (y/N) '
804804
prompt = STDIN.gets.chomp
805805
ssh_exec(ssh_cmd, options, site_uid) if prompt.downcase == 'y'
@@ -809,7 +809,7 @@ def generate_oar_properties(options)
809809
if skipped_nodes.any?
810810
puts "Skipped retired nodes: #{skipped_nodes}" unless options[:diff]
811811
end
812-
end # if options[:output] || options[:exec]
812+
end # if options[:print] || options[:update]
813813

814814
return ret
815815
end

0 commit comments

Comments
 (0)