Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Rakefile 4.44 KB
Newer Older
1 2 3 4 5 6 7
if ENV['COV']
  require 'simplecov'
  SimpleCov.start
end

$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'refrepo'
8 9 10 11 12

REFAPI_DIR = "./generators/reference-api"
PUPPET_DIR = "./generators/puppet"
VALIDATORS_DIR = "./generators/input-validators"

13
G5K_SITES = RefRepo::Utils::get_sites
14

15 16
namespace :puppet do

17
  all_puppet_tasks = [:bindg5k, :conmang5k, :dhcpg5k, :kadeployg5k, :lanpowerg5k, :kavlang5k]
18 19 20 21

  all_puppet_tasks.each { |t|
    desc "Generate #{t} configuration"
    task t do
22
      invoke_script "#{PUPPET_DIR}/#{t}.rb"
23 24 25 26 27 28 29 30
    end
  }

  desc "Launch all puppet generators"
  task :all => all_puppet_tasks

end

31
namespace :valid do
32 33 34

  desc "Check homogeneity of clusters"
  task "homogeneity" do
35
    invoke_script "#{VALIDATORS_DIR}/check-cluster-homogeneity.rb"
36 37 38 39
  end

  desc "Check input data schema validity"
  task "schema" do
40
    invoke_script "#{VALIDATORS_DIR}/yaml-input-schema-validator.rb"
41
  end
42

43
  desc "Check OAR properties -- parameters: [SITE={grenoble,...}] [CLUSTER={yeti,...}] [VERBOSE=1]"
44
  task "oar-properties" do
45
    require 'refrepo/valid/oar-properties'
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    options = {}
    options[:verbose] = true if ENV['VERBOSE']
    if ENV['SITE']
      options[:sites] = ENV['SITE'].split(',')
    else
      options[:sites] = G5K_SITES
    end
    if ENV['CLUSTER']
      options[:clusters] = ENV['CLUSTER'].split(',')
    else
      options[:clusters] = []
    end
    ret = RefRepo::Valid::OarProperties::check(options)
    exit(ret)
  end

62 63
end

64
namespace :gen do
65
  desc "Run wiki generator -- parameters: NAME={hardware,site_hardware,...} SITE={global,grenoble,...} DO={diff,print,update}"
66
  task "wiki" do
67
    require 'refrepo/gen/wiki'
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    options = {}
    if ENV['SITE']
      options[:sites] = ENV['SITE'].split(',')
    else
      options[:sites] = ['global'] + G5K_SITES
    end
    if ENV['NAME']
      options[:generators] = ENV['NAME'].split(',')
    else
      puts "You must specify a generator name using NAME="
      exit(1)
    end
    options[:diff] = false
    options[:print] = false
    options[:update] = false
    if ENV['DO']
      ENV['DO'].split(',').each do |t|
        options[:diff] = true if t == 'diff'
        options[:print] = true if t == 'print'
        options[:update] = true if t == 'update'
      end
    else
      puts "You must specify something to do using DO="
      exit(1)
    end
93 94
    ret = RefRepo::Gen::Wiki::wikigen(options)
    exit(ret)
95
  end
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140

  desc "Generate OAR properties -- parameters: SITE={grenoble,...} CLUSTER={yeti,...} NODE={dahu-1,...} DO={print,exec,diff,check} VERBOSE={0,1,2,3}"
  task "oar-properties" do
    require 'refrepo/gen/oar-properties'
    options = {}
    if ENV['SITE']
      options[:sites] = ENV['SITE'].split(',')
    else
      options[:sites] = G5K_SITES
    end
    if ENV['CLUSTER']
      options[:clusters] = ENV['CLUSTER'].split(',')
    end
    if ENV['NODE']
      options[:nodes] = ENV['NODE'].split(',')
    end
    options[:output] = false
    options[:diff] = false
    options[:exec] = false
    options[:check] = false
    if ENV['DO']
      ENV['DO'].split(',').each do |t|
        options[:diff] = true if t == 'diff'
        options[:output] = true if t == 'output'
        options[:exec] = true if t == 'update'
        if t == 'check'
          options[:diff] = true # check requires diff
          options[:check] = true
        end
      end
    else
      puts "You must specify something to do using DO="
      exit(1)
    end

    if ENV['VERBOSE']
      options[:verbose] = ENV['VERBOSE'].to_i
    else
      options[:verbose] = 0
    end

    ret = generate_oar_properties(options)
    exit(ret)
  end

141 142
end

143
desc "Creates json data from inputs"
144 145 146 147 148 149 150 151 152 153 154 155 156
task "reference-api" do
  invoke_script "#{REFAPI_DIR}/reference-api.rb"
end

#Some scripts may return status != 0 (validators, errors, ...)
#Catch errors and exit properly with status 1 instead of getting Rake errors
def invoke_script(script)
  puts "Running #{script} #{$CMD_ARGS}"
  begin
    ruby "#{script} #{$CMD_ARGS}"
  rescue => e
    exit 1
  end
157 158 159 160 161 162 163 164 165 166 167 168
end

#Hack rake: call only the first task and consider the rest as arguments to this task
currentTask = Rake.application.top_level_tasks.first
taskNames = Rake.application.tasks().map { |task| task.name() }
if (taskNames.include?(currentTask))
  Rake.application.instance_variable_set(:@top_level_tasks, [currentTask])
  ARGV.shift(ARGV.index(currentTask) + 1)
  $CMD_ARGS = ARGV.map{|arg| "'#{arg}'"}.join(' ')
else
  #Not running any task, maybe rake options, invalid, etc...
end