Class: Beaker::Subcommand

Inherits:
Thor
  • Object
show all
Defined in:
lib/beaker/subcommand.rb

Constant Summary collapse

SubcommandUtil =
Beaker::Subcommands::SubcommandUtil

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Subcommand

Returns a new instance of Subcommand.



9
10
11
12
# File 'lib/beaker/subcommand.rb', line 9

def initialize(*args)
  super
  @@config = SubcommandUtil.init_config()
end

Instance Method Details

#init(hypervisor = 'vagrant') ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/beaker/subcommand.rb', line 61

def init(hypervisor='vagrant')
  if options[:help]
    invoke :help, [], ["init"]
    return
  end
  SubcommandUtil.verify_init_args(hypervisor)
  SubcommandUtil.require_tasks()
  SubcommandUtil.init_hypervisor(hypervisor)
  say "Writing host config to .beaker/acceptance/config/default_#{hypervisor}_hosts.yaml"
  SubcommandUtil.store_config({:hypervisor => hypervisor})
  SubcommandUtil.delete_config([:provisioned])
end

#provisionObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/beaker/subcommand.rb', line 81

def provision()
  if options[:help]
    invoke :help, [], ["provision"]
    return
  end

  hypervisor = @@config.transaction { @@config[:hypervisor] }

  unless hypervisor
    SubcommandUtil.error_with("Please initialise a configuration")
  end

  provisioned = @@config.transaction { @@config[:provisioned] }

  if !provisioned or options[:force]
    SubcommandUtil.provision(hypervisor, options)
    SubcommandUtil.store_config({:provisioned => true})
  else
    say "Hosts have already been provisioned"
  end
end