Method: Beaker::Options::Parser#normalize_args
- Defined in:
- lib/beaker/options/parser.rb
#normalize_args ⇒ Object
Validate all merged options values for correctness
Currently checks:
- each host has a valid platform
- if a keyfile is provided then use it
- paths provided to --test, --pre-suite, --post-suite provided lists of .rb files for testing
- --type is one of 'pe' or 'git'
- --fail-mode is one of 'fast', 'stop' or nil
- if using blimpy hypervisor an EC2 YAML file exists
- if using the aix, solaris, or vcloud hypervisors a .fog file exists
- that one and only one master is defined per set of hosts
- that solaris/windows/aix hosts are agent only for PE tests OR
- that windows/aix host are agent only if type is not 'pe'
- sets the default host based upon machine definitions
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/beaker/options/parser.rb', line 249 def normalize_args ['HOSTS'].each_key do |name| if not ['HOSTS'][name]['platform'] parser_error "Host #{name} does not have a platform specified" else ['HOSTS'][name]['platform'] = Platform.new(['HOSTS'][name]['platform']) end end #use the keyfile if present if .has_key?(:keyfile) [:ssh][:keys] = [[:keyfile]] end #split out arguments - these arguments can have the form of arg1,arg2 or [arg] or just arg #will end up being normalized into an array LONG_OPTS.each do |opt| if .has_key?(opt) [opt] = split_arg([opt]) if RB_FILE_OPTS.include?(opt) [opt] = file_list([opt]) end if opt == :install [:install] = parse_git_repos([:install]) end else [opt] = [] end end #check for valid type if [:type] !~ /pe|git|foss|aio/ parser_error "--type must be one of pe, git, foss, or aio not '#{@options[:type]}'" end #check for valid fail mode if [:fail_mode] !~ /stop|fast|slow/ parser_error "--fail-mode must be one of fast or slow, not '#{@options[:fail_mode]}'" end #check for valid preserve_hosts option if [:preserve_hosts] !~ /always|onfail|onpass|never/ parser_error "--preserve_hosts must be one of always, onfail, onpass or never, not '#{@options[:preserve_hosts]}'" end #check for config files necessary for different hypervisors hypervisors = [] [:HOSTS].each_key do |name| hypervisors << [:HOSTS][name][:hypervisor].to_s end hypervisors.uniq! hypervisors.each do |visor| if ['blimpy'].include?(visor) check_yaml_file([:ec2_yaml], "required by #{visor}") end if ['aix', 'solaris', 'vcloud'].include?(visor) check_yaml_file([:dot_fog], "required by #{visor}") end end #check that roles of hosts make sense # - must be one and only one master roles = [] [:HOSTS].each_key do |name| roles << [:HOSTS][name][:roles] end master = 0 roles.each do |role_array| if role_array.include?('master') master += 1 end if role_array.include?('frictionless') and !(role_array & ['master', 'database', 'dashboard', 'console']).empty? parser_error "Only agent nodes may have the role 'frictionless', fix #{@options[:hosts_file]}" end end if master > 1 parser_error "Only one host/node may have the role 'master', fix #{@options[:hosts_file]}" end #check that solaris/windows/el-4 boxes are only agents [:HOSTS].each_key do |name| host = [:HOSTS][name] if (host[:platform] =~ /windows|el-4/) || (.is_pe? && host[:platform] =~ /solaris/) test_host_roles(name, host) end end #set the default role set_default_host!([:HOSTS]) end |