Class: Chef::Application::LXC

Inherits:
Chef::Application
  • Object
show all
Includes:
LXCHelper
Defined in:
lib/chef/application/lxc.rb

Instance Method Summary collapse

Methods included from LXCHelper

#recipe_in_container

Constructor Details

#initializeLXC

Returns a new instance of LXC.



66
67
68
# File 'lib/chef/application/lxc.rb', line 66

def initialize
  super
end

Instance Method Details

#reconfigureObject



70
71
72
73
74
# File 'lib/chef/application/lxc.rb', line 70

def reconfigure
  parse_options
  Chef::Config.merge!(config)
  configure_logging
end

#runObject



102
103
104
105
# File 'lib/chef/application/lxc.rb', line 102

def run
  reconfigure
  run_application
end

#run_applicationObject



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/chef/application/lxc.rb', line 89

def run_application
  begin
    parse_options
    run_chef_recipe
    Chef::Application.exit! "Exiting", 0
  rescue SystemExit => e
    raise
  rescue Exception => e
    Chef::Application.debug_stacktrace(e)
    Chef::Application.fatal!("#{e.class}: #{e.message}", 1)
  end
end

#run_chef_recipeObject



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/chef/application/lxc.rb', line 76

def run_chef_recipe
  if config[:execute]
    recipe_text = config[:execute]
  elsif config[:stdin]
    recipe_text = STDIN.read
  else
    recipe_text = ::File.read(ARGV.first)
  end
  Chef::Config[:solo] = true
  ct = ::LXC::Container.new(ARGV.first)
  recipe_in_container(ct, recipe_text)
end