From e4e4551aea1f4fb5d53e4c2554dbb6a870a7318a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Bog=C3=A1r?= Date: Tue, 19 Nov 2013 22:23:25 +0000 Subject: [PATCH 01/19] fix incompatibility issue with ppa:ubuntu-lxc/stable and ppa:ubuntu-lxc/daily --- lib/vagrant-lxc/driver/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index 80e538f..dde4864 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -38,7 +38,7 @@ module Vagrant end def state - if @name && run(:info, '--name', @name, retryable: true) =~ /^state:[^A-Z]+([A-Z]+)$/ + if @name && run(:info, '--name', @name, retryable: true) =~ /^[Ss]tate: *[^A-Z]+([A-Z]+)$/ $1.downcase.to_sym elsif @name :unknown From d8a8dbaa9bd755749ec80f0a60c8306b7144c673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Bog=C3=A1r?= Date: Tue, 19 Nov 2013 22:24:36 +0000 Subject: [PATCH 02/19] fix long waiting time with centos 6.4 containers on ubuntu 13.10 host --- lib/vagrant-lxc/driver/cli.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index dde4864..7f08c4e 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -69,6 +69,7 @@ module Vagrant end def stop + attach '/sbin/halt' run :stop, '--name', @name end From a436e30214d056c451a400233fa1ae9c6e46eaed Mon Sep 17 00:00:00 2001 From: Hiro Date: Tue, 24 Dec 2013 18:35:19 +0900 Subject: [PATCH 03/19] fixed, case insensitive matching lxc version: 1.0.0.alpha3 $ sudo lxc-info -n test_default-1387877096 Name: test_default-1387877096 State: RUNNING .... --- lib/vagrant-lxc/driver/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index 80e538f..3ce080c 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -38,7 +38,7 @@ module Vagrant end def state - if @name && run(:info, '--name', @name, retryable: true) =~ /^state:[^A-Z]+([A-Z]+)$/ + if @name && run(:info, '--name', @name, retryable: true) =~ /^state:[^A-Z]+([A-Z]+)$/i $1.downcase.to_sym elsif @name :unknown From ffb573a7f115dfe2172d5fe7342c437c38988093 Mon Sep 17 00:00:00 2001 From: Cam Cope Date: Wed, 1 Jan 2014 16:54:27 -0500 Subject: [PATCH 04/19] allow setting the container name in the vagrantfile --- lib/vagrant-lxc/action/create.rb | 10 +++++++--- lib/vagrant-lxc/config.rb | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index 018db0d..abca848 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -7,9 +7,13 @@ module Vagrant end def call(env) - container_name = "#{env[:root_path].basename}_#{env[:machine].name}" - container_name.gsub!(/[^-a-z0-9_]/i, "") - container_name << "-#{Time.now.to_i}" + if env[:machine].provider_config.static_name + container_name = env[:machine].name.to_s + else + container_name = "#{env[:root_path].basename}_#{env[:machine].name}" + container_name.gsub!(/[^-a-z0-9_]/i, "") + container_name << "-#{Time.now.to_i}" + end env[:machine].provider.driver.create( container_name, diff --git a/lib/vagrant-lxc/config.rb b/lib/vagrant-lxc/config.rb index 2065bc8..59739ec 100644 --- a/lib/vagrant-lxc/config.rb +++ b/lib/vagrant-lxc/config.rb @@ -12,9 +12,13 @@ module Vagrant # on /etc/sudoers attr_accessor :sudo_wrapper + # A String that sets a static name + attr_accessor :static_name + def initialize @customizations = [] @sudo_wrapper = UNSET_VALUE + @static_name = UNSET_VALUE end # Customize the container by calling `lxc-start` with the given @@ -34,6 +38,7 @@ module Vagrant def finalize! @sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE + @static_name = nil if @static_name == UNSET_VALUE end def validate(machine) From b34dd7d8e70206cb990135613a8632cae37d039a Mon Sep 17 00:00:00 2001 From: Michael Owings Date: Fri, 31 Jan 2014 11:01:27 -0600 Subject: [PATCH 05/19] Allow two ways to name a container --- README.md | 31 +++++++++++++++++++++++++++++++ lib/vagrant-lxc/action/create.rb | 4 +++- lib/vagrant-lxc/config.rb | 13 +++++++++---- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 36e9f64..f679e06 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,37 @@ Vagrant.configure("2") do |config| end ``` +You also have some control over the container name. By default, +vagrant-lxc will attempt to generate a unique container name for you. +However, you may use the `container_name` attribute to explicitly set +the container name to a value of your choosing, or you can use +`use_machine_name` to ensure that the container name is the same as the +vagrant machine name: + +```ruby +Vagrant.configure("2") do |config| + config.vm.box = "quantal64" + config.vm.provider :lxc do |lxc| + # Same effect as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox + lxc.customize 'cgroup.memory.limit_in_bytes', '1024M' + lxc.container_name = "my-container" # Set the container name explicitly + end +end +``` + +```ruby +Vagrant.configure("2") do |config| + config.vm.box = "quantal64" + config.vm.define "foo" do |inst| + inst.vm.provider :lxc do |lxc| + # Same effect as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox + lxc.customize 'cgroup.memory.limit_in_bytes', '1024M' + lxc.use_machine_name = true # Set container name to "foo" + end + end +end +``` + vagrant-lxc will then write out `lxc.cgroup.memory.limit_in_bytes='1024M'` to the container config file (usually kept under `/var/lib/lxc//config`) prior to starting it. diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index abca848..38f7f62 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -7,8 +7,10 @@ module Vagrant end def call(env) - if env[:machine].provider_config.static_name + if env[:machine].provider_config.use_machine_name container_name = env[:machine].name.to_s + elsif env[:machine].provider_config.container_name + container_name = env[:machine].provider_config.container_name else container_name = "#{env[:root_path].basename}_#{env[:machine].name}" container_name.gsub!(/[^-a-z0-9_]/i, "") diff --git a/lib/vagrant-lxc/config.rb b/lib/vagrant-lxc/config.rb index 59739ec..c9e63a5 100644 --- a/lib/vagrant-lxc/config.rb +++ b/lib/vagrant-lxc/config.rb @@ -12,13 +12,17 @@ module Vagrant # on /etc/sudoers attr_accessor :sudo_wrapper - # A String that sets a static name - attr_accessor :static_name + # A boolean that sets the container name to the machine name + attr_accessor :use_machine_name + + # A string to explicitly set the container name + attr_accessor :container_name def initialize @customizations = [] @sudo_wrapper = UNSET_VALUE - @static_name = UNSET_VALUE + @use_machine_name = UNSET_VALUE + @container_name = UNSET_VALUE end # Customize the container by calling `lxc-start` with the given @@ -38,7 +42,8 @@ module Vagrant def finalize! @sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE - @static_name = nil if @static_name == UNSET_VALUE + @use_machine_name = false if @use_machine_name == UNSET_VALUE + @container_name = nil if @container_name == UNSET_VALUE end def validate(machine) From 20a558097c82cdf752a276936e3cb8615517c463 Mon Sep 17 00:00:00 2001 From: Michael Owings Date: Fri, 31 Jan 2014 11:50:14 -0600 Subject: [PATCH 06/19] README fix --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f679e06..0ed4cc6 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,12 @@ Vagrant.configure("2") do |config| end ``` +vagrant-lxc will then write out `lxc.cgroup.memory.limit_in_bytes='1024M'` to the +container config file (usually kept under `/var/lib/lxc//config`) +prior to starting it. + +For other configuration options, please check the [lxc.conf manpages](http://manpages.ubuntu.com/manpages/quantal/man5/lxc.conf.5.html). + You also have some control over the container name. By default, vagrant-lxc will attempt to generate a unique container name for you. However, you may use the `container_name` attribute to explicitly set @@ -120,12 +126,6 @@ Vagrant.configure("2") do |config| end ``` -vagrant-lxc will then write out `lxc.cgroup.memory.limit_in_bytes='1024M'` to the -container config file (usually kept under `/var/lib/lxc//config`) -prior to starting it. - -For other configuration options, please check the [lxc.conf manpages](http://manpages.ubuntu.com/manpages/quantal/man5/lxc.conf.5.html). - ### Avoiding `sudo` passwords This plugin requires **a lot** of `sudo`ing since [user namespaces](https://wiki.ubuntu.com/UserNamespace) From 2be86bb7d00e44a05249f7604c0c9e7ad7cbb2ce Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 2 Feb 2014 18:07:50 -0200 Subject: [PATCH 07/19] Up version for dev --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/vagrant-lxc/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ca5036..d2b907f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [0.7.1](https://github.com/fgrehm/vagrant-lxc/compare/v0.7.0...master) (unreleased) +## [0.8.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.7.0...master) (unreleased) BUG FIXES: diff --git a/Gemfile.lock b/Gemfile.lock index 53b5ef5..b9edf35 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,7 +25,7 @@ GIT PATH remote: . specs: - vagrant-lxc (0.7.1.dev) + vagrant-lxc (0.8.0.dev) GEM remote: https://rubygems.org/ diff --git a/lib/vagrant-lxc/version.rb b/lib/vagrant-lxc/version.rb index 660ea9c..0f61018 100644 --- a/lib/vagrant-lxc/version.rb +++ b/lib/vagrant-lxc/version.rb @@ -1,5 +1,5 @@ module Vagrant module LXC - VERSION = "0.7.1.dev" + VERSION = "0.8.0.dev" end end From e3b8ead93bff92d9cdc32244f821be737386be88 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 2 Feb 2014 18:08:13 -0200 Subject: [PATCH 08/19] Mention support for naming containers from Vagrantfiles on changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2b907f..67030d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [0.8.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.7.0...master) (unreleased) +FEATURES: + + - Support for naming containers from Vagrantfiles [#132](https://github.com/fgrehm/vagrant-lxc/issues/132) + BUG FIXES: - Properly detect if lxc is installed on hosts that do not have `lxc-version` on their paths [#186](https://github.com/fgrehm/vagrant-lxc/issues/186) From 786bb8a3fe782cf6df6bd4351ac33c6aa4417b52 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 2 Feb 2014 18:35:48 -0200 Subject: [PATCH 09/19] Simplify code related to container naming [GH-132] --- README.md | 32 ++++++++++---------------------- lib/vagrant-lxc/action/create.rb | 19 +++++++++++-------- lib/vagrant-lxc/config.rb | 6 ++---- 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 0ed4cc6..07f5b10 100644 --- a/README.md +++ b/README.md @@ -95,32 +95,20 @@ prior to starting it. For other configuration options, please check the [lxc.conf manpages](http://manpages.ubuntu.com/manpages/quantal/man5/lxc.conf.5.html). -You also have some control over the container name. By default, -vagrant-lxc will attempt to generate a unique container name for you. -However, you may use the `container_name` attribute to explicitly set -the container name to a value of your choosing, or you can use -`use_machine_name` to ensure that the container name is the same as the -vagrant machine name: +### Container naming + +By default vagrant-lxc will attempt to generate a unique container name +for you. However, if the container name is important to you, you may use the +`container_name` attribute to set it explicitly from the `provider` block: ```ruby Vagrant.configure("2") do |config| config.vm.box = "quantal64" - config.vm.provider :lxc do |lxc| - # Same effect as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox - lxc.customize 'cgroup.memory.limit_in_bytes', '1024M' - lxc.container_name = "my-container" # Set the container name explicitly - end -end -``` -```ruby -Vagrant.configure("2") do |config| - config.vm.box = "quantal64" - config.vm.define "foo" do |inst| - inst.vm.provider :lxc do |lxc| - # Same effect as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox - lxc.customize 'cgroup.memory.limit_in_bytes', '1024M' - lxc.use_machine_name = true # Set container name to "foo" + config.vm.define "db" do |node| + node.vm.provider :lxc do |lxc| + lxc.container_name = :machine # Sets the container name to 'db' + lxc.container_name = 'mysql' # Sets the container name to 'mysql' end end end @@ -130,7 +118,7 @@ end This plugin requires **a lot** of `sudo`ing since [user namespaces](https://wiki.ubuntu.com/UserNamespace) are not supported on mainstream kernels. Have a look at the [Wiki](https://github.com/fgrehm/vagrant-lxc/wiki/Avoiding-'sudo'-passwords) -to find out how to work around that specially if you are running an OS with sudo +to find out how to work around that specially if you are running an OS with `sudo` < 1.8.4 (like Ubuntu 12.04) as you might be affected by a bug. ### Base boxes diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index 38f7f62..dc519bb 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -7,14 +7,17 @@ module Vagrant end def call(env) - if env[:machine].provider_config.use_machine_name - container_name = env[:machine].name.to_s - elsif env[:machine].provider_config.container_name - container_name = env[:machine].provider_config.container_name - else - container_name = "#{env[:root_path].basename}_#{env[:machine].name}" - container_name.gsub!(/[^-a-z0-9_]/i, "") - container_name << "-#{Time.now.to_i}" + container_name = env[:machine].provider_config.container_name + + case container_name + when :machine + container_name = env[:machine].name.to_s + when String + # Nothing to do here, move along... + else + container_name = "#{env[:root_path].basename}_#{env[:machine].name}" + container_name.gsub!(/[^-a-z0-9_]/i, "") + container_name << "-#{Time.now.to_i}" end env[:machine].provider.driver.create( diff --git a/lib/vagrant-lxc/config.rb b/lib/vagrant-lxc/config.rb index c9e63a5..a780a81 100644 --- a/lib/vagrant-lxc/config.rb +++ b/lib/vagrant-lxc/config.rb @@ -12,10 +12,8 @@ module Vagrant # on /etc/sudoers attr_accessor :sudo_wrapper - # A boolean that sets the container name to the machine name - attr_accessor :use_machine_name - - # A string to explicitly set the container name + # A string to explicitly set the container name (use :machine) to set it + # to the corresponding machine name. attr_accessor :container_name def initialize From 7e00b96520b66cd91d7ad8a29e78e0ee7496efc8 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 2 Feb 2014 19:27:08 -0200 Subject: [PATCH 10/19] Show something meaningful to the user in case the container already exists [GH-132] --- lib/vagrant-lxc/driver/cli.rb | 6 ++++++ lib/vagrant-lxc/errors.rb | 13 +++++++++++++ lib/vagrant-lxc/sudo_wrapper.rb | 3 ++- locales/en.yml | 5 +++++ spec/unit/driver/cli_spec.rb | 31 +++++++++++++++++++------------ 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index 80e538f..c7fd882 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -58,6 +58,12 @@ module Vagrant '--name', @name, *(config_opts), *extra + rescue Errors::ExecuteError => e + if e.stderr =~ /already exists/i + raise Errors::ContainerAlreadyExists, name: @name + else + raise + end end def destroy diff --git a/lib/vagrant-lxc/errors.rb b/lib/vagrant-lxc/errors.rb index 557cbaa..c75bfa3 100644 --- a/lib/vagrant-lxc/errors.rb +++ b/lib/vagrant-lxc/errors.rb @@ -5,7 +5,16 @@ module Vagrant module Errors class ExecuteError < Vagrant::Errors::VagrantError error_key(:lxc_execute_error) + attr_reader :stderr, :stdout + def initialize(message, *args) + super + if message.is_a?(Hash) + @stderr = message[:stderr] + @stdout = message[:stdout] + end + end end + class NamespacesNotSupported < Vagrant::Errors::VagrantError end @@ -13,6 +22,10 @@ module Vagrant error_key(:lxc_not_installed) end + class ContainerAlreadyExists < Vagrant::Errors::VagrantError + error_key(:lxc_container_already_exists) + end + # Box related errors class TemplateFileMissing < Vagrant::Errors::VagrantError error_key(:lxc_template_file_missing) diff --git a/lib/vagrant-lxc/sudo_wrapper.rb b/lib/vagrant-lxc/sudo_wrapper.rb index cfce001..d906d1e 100644 --- a/lib/vagrant-lxc/sudo_wrapper.rb +++ b/lib/vagrant-lxc/sudo_wrapper.rb @@ -51,7 +51,8 @@ module Vagrant if @interrupted @logger.info("Exit code != 0, but interrupted. Ignoring.") else - raise LXC::Errors::ExecuteError, :command => command.inspect + raise LXC::Errors::ExecuteError, + command: command.inspect, stderr: r.stderr, stdout: r.stdout end end end diff --git a/locales/en.yml b/locales/en.yml index 8a24d1d..2958b99 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -60,3 +60,8 @@ en: lxc_redir_not_installed: |- `redir` is not installed or is not accessible on the PATH. + + lxc_container_already_exists: |- + There is container on your system with the same name you've specified + on your Vagrantfile (%{name}), please choose a different one or + run `lxc-destroy --name %{name}` and try again. diff --git a/spec/unit/driver/cli_spec.rb b/spec/unit/driver/cli_spec.rb index 1b7e00c..5e8dd23 100644 --- a/spec/unit/driver/cli_spec.rb +++ b/spec/unit/driver/cli_spec.rb @@ -49,20 +49,27 @@ describe Vagrant::LXC::Driver::CLI do before do subject.stub(:run) { |*args| @run_args = args } - subject.create(template, config_file, template_args) end - it 'issues a lxc-create with provided template, container name and hash of arguments' do - subject.should have_received(:run).with( - :create, - '--template', template, - '--name', name, - '-f', config_file, - '--', - '--extra-param', 'param', - '--other', 'value' - ) - end + it 'issues a lxc-create with provided template, container name and hash of arguments' do + subject.create(template, config_file, template_args) + subject.should have_received(:run).with( + :create, + '--template', template, + '--name', name, + '-f', config_file, + '--', + '--extra-param', 'param', + '--other', 'value' + ) + end + + it 'wraps a low level error into something more meaningful in case the container already exists' do + subject.stub(:run) { raise Vagrant::LXC::Errors::ExecuteError, stderr: 'alreAdy Exists' } + expect { + subject.create(template, config_file, template_args) + }.to raise_error(Vagrant::LXC::Errors::ContainerAlreadyExists) + end end describe 'destroy' do From 6e7ab85dadcb04a49bd4eeadf311e2fbc5bd2c8b Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 2 Feb 2014 19:42:32 -0200 Subject: [PATCH 11/19] Use a safer random name for containers (closes GH-192) if the same vagrantfile is up'd in the same second in the same basedir this caused a conflict --- CHANGELOG.md | 4 ++++ lib/vagrant-lxc/action/create.rb | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67030d3..8fedc1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ FEATURES: - Support for naming containers from Vagrantfiles [#132](https://github.com/fgrehm/vagrant-lxc/issues/132) +IMPROVEMENTS: + + - Use a safer random name for containers [#152](https://github.com/fgrehm/vagrant-lxc/issues/152) + BUG FIXES: - Properly detect if lxc is installed on hosts that do not have `lxc-version` on their paths [#186](https://github.com/fgrehm/vagrant-lxc/issues/186) diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index dc519bb..1676e21 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -17,7 +17,9 @@ module Vagrant else container_name = "#{env[:root_path].basename}_#{env[:machine].name}" container_name.gsub!(/[^-a-z0-9_]/i, "") - container_name << "-#{Time.now.to_i}" + # milliseconds + random number suffix to allow for simultaneous + # `vagrant up` of the same box in different dirs + container_name << "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}" end env[:machine].provider.driver.create( From 13e7ffedeaff5cc7b1226c9ce32af04937b069cb Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 2 Feb 2014 19:53:03 -0200 Subject: [PATCH 12/19] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fedc1c..2e35c40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ FEATURES: IMPROVEMENTS: - Use a safer random name for containers [#152](https://github.com/fgrehm/vagrant-lxc/issues/152) + - Improve Ubuntu 13.10 compatibility [#190](https://github.com/fgrehm/vagrant-lxc/pull/190) / [#197](https://github.com/fgrehm/vagrant-lxc/pull/197) BUG FIXES: From 005140099c07d75dd29d5c25662d4f9bbc9084da Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 12 Feb 2014 01:41:24 -0200 Subject: [PATCH 13/19] Check for whether lxc is installed using `lxc-create` Closes GH-214 and GH-211 --- lib/vagrant-lxc/provider.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb index abde513..0709b10 100644 --- a/lib/vagrant-lxc/provider.rb +++ b/lib/vagrant-lxc/provider.rb @@ -27,7 +27,7 @@ module Vagrant def ensure_lxc_installed! begin - sudo_wrapper.run("which", "lxc-version") + sudo_wrapper.run("which", "lxc-create") rescue Vagrant::LXC::Errors::ExecuteError raise Errors::LxcNotInstalled end From 44f00bd7ed97634cc22526fa0125138ed9655ea0 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 12 Feb 2014 01:47:12 -0200 Subject: [PATCH 14/19] Add spec to check if container state detection is case insentive [GH-217] --- spec/unit/driver/cli_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/unit/driver/cli_spec.rb b/spec/unit/driver/cli_spec.rb index 5e8dd23..9e78353 100644 --- a/spec/unit/driver/cli_spec.rb +++ b/spec/unit/driver/cli_spec.rb @@ -141,6 +141,11 @@ describe Vagrant::LXC::Driver::CLI do it 'maps the output of lxc-info status out to a symbol' do subject.state.should == :stopped end + + it 'is not case sensitive' do + subject.stub(:run).and_return("StatE: STarTED\npid: 2") + subject.state.should == :started + end end describe 'attach' do From 186b01e1920a03bd1373f4684d11d3379f6f7ed9 Mon Sep 17 00:00:00 2001 From: Cam Cope Date: Tue, 18 Feb 2014 03:05:14 -0500 Subject: [PATCH 15/19] remove naming cruft, clarify comment Removed confusing leftover "use_machine_name" variable Made comment about :container_name more clear --- lib/vagrant-lxc/config.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-lxc/config.rb b/lib/vagrant-lxc/config.rb index a780a81..1a47058 100644 --- a/lib/vagrant-lxc/config.rb +++ b/lib/vagrant-lxc/config.rb @@ -12,14 +12,13 @@ module Vagrant # on /etc/sudoers attr_accessor :sudo_wrapper - # A string to explicitly set the container name (use :machine) to set it - # to the corresponding machine name. + # A string to explicitly set the container name. To use the vagrant + # machine name, set this to :machine attr_accessor :container_name def initialize @customizations = [] @sudo_wrapper = UNSET_VALUE - @use_machine_name = UNSET_VALUE @container_name = UNSET_VALUE end @@ -40,7 +39,6 @@ module Vagrant def finalize! @sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE - @use_machine_name = false if @use_machine_name == UNSET_VALUE @container_name = nil if @container_name == UNSET_VALUE end From b5c7a50a7422b8dab2c06d7f1bd9f8d1294636d6 Mon Sep 17 00:00:00 2001 From: Cam Cope Date: Wed, 19 Feb 2014 18:25:45 -0500 Subject: [PATCH 16/19] match hwaddr lines with varying spaces --- lib/vagrant-lxc/driver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index dbedcfb..3c14554 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -40,7 +40,7 @@ module Vagrant end def mac_address - @mac_address ||= config_string.match(/^lxc\.network\.hwaddr\s+=\s+(.+)$/)[1] + @mac_address ||= config_string.match(/^lxc\.network\.hwaddr\s*+=\s*+(.+)$/)[1] end def config_string From 46e77bf9e52f3c9ac3789b32efc20895eddd102d Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 19 Feb 2014 23:27:53 -0300 Subject: [PATCH 17/19] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e35c40..1fc958d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ IMPROVEMENTS: - Use a safer random name for containers [#152](https://github.com/fgrehm/vagrant-lxc/issues/152) - Improve Ubuntu 13.10 compatibility [#190](https://github.com/fgrehm/vagrant-lxc/pull/190) / [#197](https://github.com/fgrehm/vagrant-lxc/pull/197) + - Improved mac address detection from lxc configs [#226](https://github.com/fgrehm/vagrant-lxc/pull/226) BUG FIXES: From 6704cd9869d98c40c10c10cd9a26b23bea1dfa79 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 21 Feb 2014 19:35:14 -0300 Subject: [PATCH 18/19] Updated readme --- README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index 07f5b10..6a595a3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # vagrant-lxc -[![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) +[![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) [![Gittip](http://img.shields.io/gittip/fgrehm.svg)](https://www.gittip.com/fgrehm/) [LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.1+ @@ -142,14 +142,6 @@ list if you have a problem and feel free to use the [issue tracker](https://gith propose new functionality and / or report bugs. -## Support - -Support this project and [others by fgrehm](https://github.com/fgrehm) -via [gittip](https://www.gittip.com/fgrehm/). - -[![Support via Gittip](https://rawgithub.com/twolfson/gittip-badge/0.1.0/dist/gittip.png)](https://www.gittip.com/fgrehm/) - - ## Contributing 1. Fork it @@ -157,5 +149,3 @@ via [gittip](https://www.gittip.com/fgrehm/). 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/fgrehm/vagrant-lxc/trend.png)](https://bitdeli.com/free "Bitdeli Badge") From 39a59463997d9d5184bc4a190b5a07b62ce3d1b5 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 25 Feb 2014 23:59:13 -0300 Subject: [PATCH 19/19] v0.8.0 --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/vagrant-lxc/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc958d..8e46d7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [0.8.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.7.0...master) (unreleased) +## [0.8.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.7.0...v0.8.0) (Feb 26, 2014) FEATURES: diff --git a/Gemfile.lock b/Gemfile.lock index b9edf35..e1a5d71 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,7 +25,7 @@ GIT PATH remote: . specs: - vagrant-lxc (0.8.0.dev) + vagrant-lxc (0.8.0) GEM remote: https://rubygems.org/ diff --git a/lib/vagrant-lxc/version.rb b/lib/vagrant-lxc/version.rb index 0f61018..cbecb7a 100644 --- a/lib/vagrant-lxc/version.rb +++ b/lib/vagrant-lxc/version.rb @@ -1,5 +1,5 @@ module Vagrant module LXC - VERSION = "0.8.0.dev" + VERSION = "0.8.0" end end