Class: Vanagon::CLI::BuildHostInfo

Inherits:
Vanagon::CLI show all
Defined in:
lib/vanagon/cli/build_host_info.rb

Constant Summary collapse

DOCUMENTATION =
<<~DOCOPT.freeze
  Usage:
  build_host_info [options] <project-name> <platforms>

  Options:
    -h, --help                       Display help
    -c, --configdir DIRECTORY        Configuration directory [default: #{Dir.pwd}/configs]
    -e, --engine ENGINE              Custom engine to use [default: always_be_scheduling]
    -w, --workdir DIRECTORY          Working directory on the local host
    -v, --verbose                    Only here for backwards compatibility. Does nothing.

  Engines:
    always_be_scheduling: default engine using Puppet's ABS infrastructure
    docker: a docker container on the local host
    ec2: an Amazon EC2 instance
    hardware: a dedicated hardware device
    local: the local machine, cannot be used with a target
    pooler: [deprecated] Puppet's vmpooler
DOCOPT

Instance Method Summary collapse

Methods inherited from Vanagon::CLI

#options_validate

Instance Method Details

#options_translate(docopt_options) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/vanagon/cli/build_host_info.rb', line 44

def options_translate(docopt_options)
  translations = {
    '--verbose' => :verbose,
    '--workdir' => :workdir,
    '--configdir' => :configdir,
    '--engine' => :engine,
    '<project-name>' => :project_name,
    '<platforms>' => :platforms,
    '<targets>' => :targets
  }
  return docopt_options.map { |k, v| [translations[k], v] }.to_h
end

#parse(argv) ⇒ Object



27
28
29
30
31
32
# File 'lib/vanagon/cli/build_host_info.rb', line 27

def parse(argv)
  Docopt.docopt(DOCUMENTATION, { argv: argv })
rescue Docopt::Exit => e
  VanagonLogger.error e.message
  exit 1
end

#run(options) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/vanagon/cli/build_host_info.rb', line 34

def run(options)
  platforms = options[:platforms].split(',')
  project = options[:project_name]

  platforms.each do |platform|
    driver = Vanagon::Driver.new(platform, project, options)
    VanagonLogger.warn JSON.generate(driver.build_host_info)
  end
end