vagrant-lxc 0.8.0 → 1.0.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/BOXES.md +13 -21
  4. data/CHANGELOG.md +49 -0
  5. data/CONTRIBUTING.md +5 -2
  6. data/Gemfile +12 -13
  7. data/Gemfile.lock +66 -51
  8. data/README.md +39 -25
  9. data/development/Vagrantfile +0 -2
  10. data/lib/vagrant-backports/README.md +12 -0
  11. data/lib/vagrant-backports/action/handle_box.rb +1 -0
  12. data/lib/vagrant-backports/action/is_state.rb +34 -0
  13. data/lib/vagrant-backports/action/message.rb +20 -0
  14. data/lib/{vagrant-lxc → vagrant-backports}/action/wait_for_communicator.rb +6 -5
  15. data/lib/vagrant-backports/ui.rb +12 -0
  16. data/lib/vagrant-backports/utils.rb +27 -0
  17. data/lib/vagrant-lxc.rb +8 -0
  18. data/lib/vagrant-lxc/action.rb +81 -48
  19. data/lib/vagrant-lxc/action/boot.rb +2 -1
  20. data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +1 -0
  21. data/lib/vagrant-lxc/action/handle_box_metadata.rb +36 -14
  22. data/lib/vagrant-lxc/action/message.rb +0 -23
  23. data/lib/vagrant-lxc/action/prepare_nfs_settings.rb +64 -0
  24. data/lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb +19 -0
  25. data/lib/vagrant-lxc/action/setup_package_files.rb +6 -2
  26. data/lib/vagrant-lxc/{action → backports/action}/share_folders.rb +0 -0
  27. data/lib/vagrant-lxc/command/root.rb +58 -0
  28. data/lib/vagrant-lxc/command/sudoers.rb +87 -0
  29. data/lib/vagrant-lxc/driver.rb +21 -11
  30. data/lib/vagrant-lxc/plugin.rb +23 -5
  31. data/lib/vagrant-lxc/provider/cap/public_address.rb +17 -0
  32. data/lib/vagrant-lxc/synced_folder.rb +42 -0
  33. data/lib/vagrant-lxc/version.rb +1 -1
  34. data/locales/en.yml +6 -5
  35. data/scripts/lxc-template +165 -0
  36. data/spec/spec_helper.rb +9 -13
  37. data/spec/unit/action/clear_forwarded_ports_spec.rb +3 -3
  38. data/spec/unit/action/compress_rootfs_spec.rb +7 -5
  39. data/spec/unit/action/forward_ports_spec.rb +8 -8
  40. data/spec/unit/action/handle_box_metadata_spec.rb +71 -15
  41. data/spec/unit/action/setup_package_files_spec.rb +32 -8
  42. data/spec/unit/driver/cli_spec.rb +31 -30
  43. data/spec/unit/driver_spec.rb +35 -27
  44. data/spec/unit/support/unit_example_group.rb +6 -6
  45. data/spec/unit_helper.rb +4 -2
  46. data/tasks/spec.rake +18 -11
  47. data/vagrant-lxc.gemspec +7 -0
  48. data/vagrant-spec.config.rb +24 -0
  49. metadata +24 -36
  50. data/boxes/build-all.sh +0 -22
  51. data/boxes/build-debian-box.sh +0 -167
  52. data/boxes/build-openmandriva-box.sh +0 -159
  53. data/boxes/build-ubuntu-box.sh +0 -151
  54. data/boxes/common/cleanup +0 -7
  55. data/boxes/common/install-babushka +0 -16
  56. data/boxes/common/install-chef +0 -15
  57. data/boxes/common/install-puppet +0 -13
  58. data/boxes/common/install-salt +0 -12
  59. data/boxes/common/install-salt-debian +0 -28
  60. data/boxes/common/lxc-template +0 -226
  61. data/boxes/common/lxc-template-openmandriva +0 -225
  62. data/boxes/common/lxc.conf +0 -49
  63. data/boxes/common/metadata.json +0 -5
  64. data/lib/vagrant-lxc/action/check_created.rb +0 -21
  65. data/lib/vagrant-lxc/action/check_running.rb +0 -21
  66. data/lib/vagrant-lxc/action/created.rb +0 -20
  67. data/lib/vagrant-lxc/action/disconnect.rb +0 -18
  68. data/lib/vagrant-lxc/action/is_running.rb +0 -19
  69. data/spec/acceptance/sanity_check_spec.rb +0 -111
  70. data/spec/acceptance/support/acceptance_example_group.rb +0 -76
  71. data/spec/acceptance/support/machine_ext.rb +0 -12
  72. data/spec/acceptance/support/test_ui.rb +0 -22
  73. data/spec/acceptance_helper.rb +0 -21
@@ -52,8 +52,6 @@ Vagrant.configure("2") do |config|
52
52
  config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root', nfs: true
53
53
 
54
54
  config.cache.scope = :machine
55
- config.cache.auto_detect = true
56
- config.cache.enable_nfs = true
57
55
 
58
56
  ip_suffix = 30
59
57
  BOXES.each do |box_name, box_config|
@@ -0,0 +1,12 @@
1
+ # vagrant-backports
2
+
3
+ <!--
4
+ [![Build Status](https://travis-ci.org/fgrehm/vagrant-backports.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-backports) [![Gem Version](https://badge.fury.io/rb/vagrant-backports.png)](http://badge.fury.io/rb/vagrant-backports) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-backports.png)](https://codeclimate.com/github/fgrehm/vagrant-backports) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-backports/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-backports) [![Gittip](http://img.shields.io/gittip/fgrehm.svg)](https://www.gittip.com/fgrehm/)
5
+ -->
6
+
7
+ A _"hypothetical"_ gem that helps Vagrant plugin developers to stay sane when
8
+ keeping up with Vagrant improvements by backporting parts of its recent versions
9
+ functionality.
10
+
11
+ More information will be provided if there is enough interest on having this
12
+ extracted as a separate gem.
@@ -0,0 +1 @@
1
+ Vagrant::Action::Builtin.const_set :HandleBox, Vagrant::Action::Builtin::HandleBoxUrl
@@ -0,0 +1,34 @@
1
+ module Vagrant
2
+ module Backports
3
+ module Action
4
+ # This middleware is meant to be used with Call and can check if
5
+ # a machine is in the given state ID.
6
+ class IsState
7
+ # Note: Any of the arguments can be arrays as well.
8
+ #
9
+ # @param [Symbol] target_state The target state ID that means that
10
+ # the machine was properly shut down.
11
+ # @param [Symbol] source_state The source state ID that the machine
12
+ # must be in to be shut down.
13
+ def initialize(app, env, check, **opts)
14
+ @app = app
15
+ @logger = Log4r::Logger.new("vagrant::action::builtin::is_state")
16
+ @check = check
17
+ @invert = !!opts[:invert]
18
+ end
19
+
20
+ def call(env)
21
+ @logger.debug("Checking if machine state is '#{@check}'")
22
+ state = env[:machine].state.id
23
+ @logger.debug("-- Machine state: #{state}")
24
+
25
+ env[:result] = @check == state
26
+ env[:result] = !env[:result] if @invert
27
+ @app.call(env)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ Vagrant::Action::Builtin.const_set :IsState, Vagrant::Backports::Action::IsState
@@ -0,0 +1,20 @@
1
+ module Vagrant
2
+ module Backports
3
+ module Action
4
+ # This middleware simply outputs a message to the UI.
5
+ class Message
6
+ def initialize(app, env, message, **opts)
7
+ @app = app
8
+ @message = message
9
+ end
10
+
11
+ def call(env)
12
+ env[:ui].info(@message)
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ Vagrant::Action::Builtin.const_set :Message, Vagrant::Backports::Action::Message
@@ -1,12 +1,11 @@
1
- # This acts like a backport of Vagrant's built in action from 1.3+ for older versions
2
- # and will probably be deprecated on 0.8+
1
+ # This acts like a backport of Vagrant's built in action from 1.3+ for previous version
3
2
  # https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/action/builtin/wait_for_communicator.rb
4
3
  module Vagrant
5
- module LXC
4
+ module Backports
6
5
  module Action
7
6
  class WaitForCommunicator
8
7
  def initialize(app, env)
9
- @app = app
8
+ @app = app
10
9
  end
11
10
 
12
11
  def call(env)
@@ -21,7 +20,7 @@ module Vagrant
21
20
  max_tries = @env[:machine].config.ssh.max_tries.to_i
22
21
  max_tries.times do |i|
23
22
  if @env[:machine].communicate.ready?
24
- @env[:ui].info I18n.t("vagrant_lxc.messages.container_ready")
23
+ @env[:ui].info 'Machine booted and ready!'
25
24
  return true
26
25
  end
27
26
 
@@ -39,3 +38,5 @@ module Vagrant
39
38
  end
40
39
  end
41
40
  end
41
+
42
+ Vagrant::Action::Builtin.const_set :WaitForCommunicator, Vagrant::Backports::Action::WaitForCommunicator
@@ -0,0 +1,12 @@
1
+ module Vagrant
2
+ module UI
3
+ class Interface
4
+ def output(*args)
5
+ info(*args)
6
+ end
7
+ def detail(*args)
8
+ info(*args)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ module Vagrant
2
+ module Backports
3
+ class << self
4
+ def vagrant_1_2_or_later?
5
+ greater_than?('1.2.0')
6
+ end
7
+
8
+ def vagrant_1_3_or_later?
9
+ greater_than?('1.3.0')
10
+ end
11
+
12
+ def vagrant_1_4_or_later?
13
+ greater_than?('1.4.0')
14
+ end
15
+
16
+ def vagrant_1_5_or_later?
17
+ greater_than?('1.5.0')
18
+ end
19
+
20
+ private
21
+
22
+ def greater_than?(version)
23
+ Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(version)
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/vagrant-lxc.rb CHANGED
@@ -1,2 +1,10 @@
1
1
  require "vagrant-lxc/version"
2
2
  require "vagrant-lxc/plugin"
3
+
4
+ module Vagrant
5
+ module LXC
6
+ def self.source_root
7
+ @source_root ||= Pathname.new(File.dirname(__FILE__)).join('..').expand_path
8
+ end
9
+ end
10
+ end
@@ -1,28 +1,28 @@
1
1
  require 'vagrant-lxc/action/boot'
2
- require 'vagrant-lxc/action/check_created'
3
- require 'vagrant-lxc/action/check_running'
4
2
  require 'vagrant-lxc/action/clear_forwarded_ports'
5
3
  require 'vagrant-lxc/action/create'
6
- require 'vagrant-lxc/action/created'
7
4
  require 'vagrant-lxc/action/destroy'
8
5
  require 'vagrant-lxc/action/destroy_confirm'
9
- require 'vagrant-lxc/action/disconnect'
10
6
  require 'vagrant-lxc/action/compress_rootfs'
11
7
  require 'vagrant-lxc/action/fetch_ip_with_lxc_attach'
12
8
  require 'vagrant-lxc/action/fetch_ip_from_dnsmasq_leases'
13
9
  require 'vagrant-lxc/action/forced_halt'
14
10
  require 'vagrant-lxc/action/forward_ports'
15
11
  require 'vagrant-lxc/action/handle_box_metadata'
16
- require 'vagrant-lxc/action/is_running'
17
- require 'vagrant-lxc/action/message'
12
+ require 'vagrant-lxc/action/prepare_nfs_settings'
13
+ require 'vagrant-lxc/action/prepare_nfs_valid_ids'
18
14
  require 'vagrant-lxc/action/remove_temporary_files'
19
15
  require 'vagrant-lxc/action/setup_package_files'
20
- require 'vagrant-lxc/action/share_folders'
21
16
  require 'vagrant-lxc/action/warn_networks'
22
17
 
23
- unless Vagrant::LXC.vagrant_1_3_or_later
24
- require 'vagrant-lxc/action/wait_for_communicator'
25
- Vagrant::Action::Builtin.const_set :WaitForCommunicator, Vagrant::LXC::Action::WaitForCommunicator
18
+ unless Vagrant::Backports.vagrant_1_3_or_later?
19
+ require 'vagrant-backports/action/wait_for_communicator'
20
+ end
21
+ unless Vagrant::Backports.vagrant_1_5_or_later?
22
+ require 'vagrant-backports/ui'
23
+ require 'vagrant-backports/action/handle_box'
24
+ require 'vagrant-backports/action/message'
25
+ require 'vagrant-backports/action/is_state'
26
26
  end
27
27
 
28
28
  module Vagrant
@@ -37,9 +37,9 @@ module Vagrant
37
37
  # machine back up with the new configuration.
38
38
  def self.action_reload
39
39
  Builder.new.tap do |b|
40
- b.use Builtin::Call, Created do |env1, b2|
41
- if !env1[:result]
42
- b2.use Message, :not_created
40
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2|
41
+ if env1[:result]
42
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
43
43
  next
44
44
  end
45
45
 
@@ -57,7 +57,15 @@ module Vagrant
57
57
  b.use Builtin::Provision
58
58
  b.use Builtin::EnvSet, :port_collision_repair => true
59
59
  b.use Builtin::HandleForwardedPortCollisions
60
- b.use ShareFolders
60
+ if Vagrant::Backports.vagrant_1_4_or_later?
61
+ b.use PrepareNFSValidIds
62
+ b.use Builtin::SyncedFolderCleanup
63
+ b.use Builtin::SyncedFolders
64
+ b.use PrepareNFSSettings
65
+ else
66
+ require 'vagrant-lxc/backports/action/share_folders'
67
+ b.use ShareFolders
68
+ end
61
69
  b.use Builtin::SetHostname
62
70
  b.use WarnNetworks
63
71
  b.use ForwardPorts
@@ -70,15 +78,15 @@ module Vagrant
70
78
  def self.action_provision
71
79
  Builder.new.tap do |b|
72
80
  b.use Builtin::ConfigValidate
73
- b.use Builtin::Call, Created do |env1, b2|
74
- if !env1[:result]
75
- b2.use Message, :not_created
81
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2|
82
+ if env1[:result]
83
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
76
84
  next
77
85
  end
78
86
 
79
- b2.use Builtin::Call, IsRunning do |env2, b3|
87
+ b2.use Builtin::Call, Builtin::IsState, :running do |env2, b3|
80
88
  if !env2[:result]
81
- b3.use Message, :not_running
89
+ b3.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_running")
82
90
  next
83
91
  end
84
92
 
@@ -93,7 +101,7 @@ module Vagrant
93
101
  def self.action_start
94
102
  Builder.new.tap do |b|
95
103
  b.use Builtin::ConfigValidate
96
- b.use Builtin::Call, IsRunning do |env, b2|
104
+ b.use Builtin::Call, Builtin::IsState, :running do |env, b2|
97
105
  # If the VM is running, then our work here is done, exit
98
106
  next if env[:result]
99
107
  b2.use action_boot
@@ -106,10 +114,10 @@ module Vagrant
106
114
  def self.action_up
107
115
  Builder.new.tap do |b|
108
116
  b.use Builtin::ConfigValidate
109
- b.use Builtin::Call, Created do |env, b2|
117
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
110
118
  # If the VM is NOT created yet, then do the setup steps
111
- if !env[:result]
112
- b2.use Builtin::HandleBoxUrl
119
+ if env[:result]
120
+ b2.use Builtin::HandleBox
113
121
  b2.use HandleBoxMetadata
114
122
  b2.use Create
115
123
  end
@@ -122,19 +130,18 @@ module Vagrant
122
130
  # the virtual machine, gracefully or by force.
123
131
  def self.action_halt
124
132
  Builder.new.tap do |b|
125
- b.use Builtin::Call, Created do |env, b2|
133
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
126
134
  if env[:result]
127
- # TODO: Remove once we drop support for vagrant 1.1
128
- b2.use Disconnect
129
- b2.use ClearForwardedPorts
130
- b2.use RemoveTemporaryFiles
131
- b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3|
132
- if !env2[:result]
133
- b3.use ForcedHalt
134
- end
135
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
136
+ next
137
+ end
138
+
139
+ b2.use ClearForwardedPorts
140
+ b2.use RemoveTemporaryFiles
141
+ b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3|
142
+ if !env2[:result]
143
+ b3.use ForcedHalt
135
144
  end
136
- else
137
- b2.use Message, :not_created
138
145
  end
139
146
  end
140
147
  end
@@ -144,9 +151,9 @@ module Vagrant
144
151
  # freeing the resources of the underlying virtual machine.
145
152
  def self.action_destroy
146
153
  Builder.new.tap do |b|
147
- b.use Builtin::Call, Created do |env1, b2|
148
- if !env1[:result]
149
- b2.use Message, :not_created
154
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2|
155
+ if env1[:result]
156
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
150
157
  next
151
158
  end
152
159
 
@@ -157,11 +164,11 @@ module Vagrant
157
164
  b3.use Builtin::EnvSet, :force_halt => true
158
165
  b3.use action_halt
159
166
  b3.use Destroy
160
- if Vagrant::LXC.vagrant_1_3_or_later
167
+ if Vagrant::Backports.vagrant_1_3_or_later?
161
168
  b3.use Builtin::ProvisionerCleanup
162
169
  end
163
170
  else
164
- b3.use Message, :will_not_destroy
171
+ b3.use Builtin::Message, I18n.t("vagrant_lxc.messages.will_not_destroy")
165
172
  end
166
173
  end
167
174
  end
@@ -171,9 +178,9 @@ module Vagrant
171
178
  # This action packages the virtual machine into a single box file.
172
179
  def self.action_package
173
180
  Builder.new.tap do |b|
174
- b.use Builtin::Call, Created do |env1, b2|
175
- if !env1[:result]
176
- b2.use Message, :not_created
181
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2|
182
+ if env1[:result]
183
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
177
184
  next
178
185
  end
179
186
 
@@ -198,18 +205,44 @@ module Vagrant
198
205
  # This is the action that will exec into an SSH shell.
199
206
  def self.action_ssh
200
207
  Builder.new.tap do |b|
201
- b.use CheckCreated
202
- b.use CheckRunning
203
- b.use Builtin::SSHExec
208
+ b.use Builtin::ConfigValidate
209
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
210
+ if env[:result]
211
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
212
+ next
213
+ end
214
+
215
+ b2.use Builtin::Call, Builtin::IsState, :running do |env1, b3|
216
+ if !env1[:result]
217
+ b3.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_running")
218
+ next
219
+ end
220
+
221
+ b3.use Builtin::SSHExec
222
+ end
223
+ end
204
224
  end
205
225
  end
206
226
 
207
227
  # This is the action that will run a single SSH command.
208
228
  def self.action_ssh_run
209
229
  Builder.new.tap do |b|
210
- b.use CheckCreated
211
- b.use CheckRunning
212
- b.use Builtin::SSHRun
230
+ b.use Builtin::ConfigValidate
231
+ b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
232
+ if env[:result]
233
+ b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
234
+ next
235
+ end
236
+
237
+ b2.use Builtin::Call, Builtin::IsState, :running do |env1, b3|
238
+ if !env1[:result]
239
+ raise Vagrant::Errors::VMNotRunningError
240
+ next
241
+ end
242
+
243
+ b3.use Builtin::SSHRun
244
+ end
245
+ end
213
246
  end
214
247
  end
215
248
  end
@@ -11,7 +11,8 @@ module Vagrant
11
11
 
12
12
  config = env[:machine].provider_config
13
13
 
14
- config.customize 'utsname', env[:machine].id
14
+ utsname = env[:machine].config.vm.hostname || env[:machine].id
15
+ config.customize 'utsname', utsname
15
16
 
16
17
  env[:ui].info I18n.t("vagrant_lxc.messages.starting")
17
18
  env[:machine].provider.driver.start(config.customizations)
@@ -35,6 +35,7 @@ module Vagrant
35
35
  /var/lib/misc/dnsmasq.leases
36
36
  /var/lib/dnsmasq/dnsmasq.leases
37
37
  /var/db/dnsmasq.leases
38
+ /var/lib/libvirt/dnsmasq/*.leases
38
39
  )
39
40
 
40
41
  def read_dnsmasq_leases
@@ -3,7 +3,8 @@ module Vagrant
3
3
  module Action
4
4
  # Prepare arguments to be used for lxc-create
5
5
  class HandleBoxMetadata
6
- SUPPORTED_VERSIONS = [2, 3]
6
+ SUPPORTED_VERSIONS = ['1.0.0', '2', '3']
7
+
7
8
  def initialize(app, env)
8
9
  @app = app
9
10
  @logger = Log4r::Logger.new("vagrant::lxc::action::handle_box_metadata")
@@ -16,34 +17,51 @@ module Vagrant
16
17
  @env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
17
18
  :name => @env[:machine].box.name)
18
19
 
19
- @logger.debug 'Validating box contents'
20
+ @logger.info 'Validating box contents'
20
21
  validate_box
21
22
 
22
- @logger.debug 'Setting box options on environment'
23
- @env[:lxc_template_opts] = template_opts
23
+ @logger.info 'Setting box options on environment'
24
24
  @env[:lxc_template_src] = template_src
25
+ @env[:lxc_template_opts] = template_opts
26
+
27
+ # FIXME: Remove support for pre 1.0.0 boxes
28
+ if box_version != '1.0.0'
29
+ @env[:ui].warn "WARNING: You are using a base box that has a format that has been deprecated, please upgrade to a new one."
30
+ @env[:lxc_template_opts].merge!(
31
+ '--auth-key' => Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s
32
+ )
33
+ end
25
34
 
26
35
  if template_config_file.exist?
27
- @env[:lxc_template_config] = template_config_file.to_s
36
+ @env[:lxc_template_opts].merge!('--config' => template_config_file.to_s)
37
+ elsif old_template_config_file.exist?
38
+ @env[:lxc_template_config] = old_template_config_file.to_s
28
39
  end
29
40
 
30
41
  @app.call env
31
42
  end
32
43
 
33
44
  def template_src
34
- @template_src ||= @box.directory.join('lxc-template').to_s
45
+ @template_src ||=
46
+ if (box_template = @box.directory.join('lxc-template')).exist?
47
+ box_template.to_s
48
+ else
49
+ Vagrant::LXC.source_root.join('scripts/lxc-template').to_s
50
+ end
35
51
  end
36
52
 
37
53
  def template_config_file
38
- @template_config_file ||= @box.directory.join('lxc.conf')
54
+ @template_config_file ||= @box.directory.join('lxc-config')
55
+ end
56
+
57
+ # TODO: Remove this once we remove compatibility for < 1.0.0 boxes
58
+ def old_template_config_file
59
+ @old_template_config_file ||= @box.directory.join('lxc.conf')
39
60
  end
40
61
 
41
62
  def template_opts
42
63
  @template_opts ||= @box.metadata.fetch('template-opts', {}).dup.merge!(
43
- '--tarball' => rootfs_tarball,
44
- # TODO: Deprecate this, the rootfs should be ready for vagrant-lxc
45
- # SSH access at this point
46
- '--auth-key' => Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s
64
+ '--tarball' => rootfs_tarball
47
65
  )
48
66
  end
49
67
 
@@ -52,10 +70,10 @@ module Vagrant
52
70
  end
53
71
 
54
72
  def validate_box
55
- unless SUPPORTED_VERSIONS.include? @box.metadata.fetch('version').to_i
73
+ unless SUPPORTED_VERSIONS.include? box_version
56
74
  raise Errors::IncompatibleBox.new name: @box.name,
57
- found: @box.metadata.fetch('version').to_i,
58
- supported: SUPPORTED_VERSIONS.join(' and ')
75
+ found: box_version,
76
+ supported: SUPPORTED_VERSIONS.join(', ')
59
77
  end
60
78
 
61
79
  unless File.exists?(template_src)
@@ -66,6 +84,10 @@ module Vagrant
66
84
  raise Errors::RootFSTarballMissing.new name: @box.name
67
85
  end
68
86
  end
87
+
88
+ def box_version
89
+ @box.metadata.fetch('version')
90
+ end
69
91
  end
70
92
  end
71
93
  end