vagrant-lxc-2.1-patch 1.4.0

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +31 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +10 -0
  5. data/.vimrc +1 -0
  6. data/BOXES.md +47 -0
  7. data/CHANGELOG.md +510 -0
  8. data/CONTRIBUTING.md +24 -0
  9. data/Gemfile +24 -0
  10. data/Guardfile +7 -0
  11. data/LICENSE.txt +22 -0
  12. data/README.md +187 -0
  13. data/Rakefile +3 -0
  14. data/lib/vagrant-lxc.rb +10 -0
  15. data/lib/vagrant-lxc/action.rb +234 -0
  16. data/lib/vagrant-lxc/action/boot.rb +42 -0
  17. data/lib/vagrant-lxc/action/clear_forwarded_ports.rb +56 -0
  18. data/lib/vagrant-lxc/action/compress_rootfs.rb +30 -0
  19. data/lib/vagrant-lxc/action/create.rb +57 -0
  20. data/lib/vagrant-lxc/action/destroy.rb +18 -0
  21. data/lib/vagrant-lxc/action/destroy_confirm.rb +17 -0
  22. data/lib/vagrant-lxc/action/fetch_ip_with_lxc_info.rb +43 -0
  23. data/lib/vagrant-lxc/action/forced_halt.rb +20 -0
  24. data/lib/vagrant-lxc/action/forward_ports.rb +121 -0
  25. data/lib/vagrant-lxc/action/gc_private_network_bridges.rb +47 -0
  26. data/lib/vagrant-lxc/action/handle_box_metadata.rb +94 -0
  27. data/lib/vagrant-lxc/action/prepare_nfs_settings.rb +64 -0
  28. data/lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb +19 -0
  29. data/lib/vagrant-lxc/action/private_networks.rb +46 -0
  30. data/lib/vagrant-lxc/action/setup_package_files.rb +60 -0
  31. data/lib/vagrant-lxc/action/warn_networks.rb +25 -0
  32. data/lib/vagrant-lxc/command/root.rb +58 -0
  33. data/lib/vagrant-lxc/command/sudoers.rb +97 -0
  34. data/lib/vagrant-lxc/config.rb +73 -0
  35. data/lib/vagrant-lxc/driver.rb +288 -0
  36. data/lib/vagrant-lxc/driver/cli.rb +166 -0
  37. data/lib/vagrant-lxc/errors.rb +62 -0
  38. data/lib/vagrant-lxc/plugin.rb +51 -0
  39. data/lib/vagrant-lxc/provider.rb +101 -0
  40. data/lib/vagrant-lxc/provider/cap/public_address.rb +17 -0
  41. data/lib/vagrant-lxc/sudo_wrapper.rb +104 -0
  42. data/lib/vagrant-lxc/synced_folder.rb +72 -0
  43. data/lib/vagrant-lxc/version.rb +5 -0
  44. data/locales/en.yml +82 -0
  45. data/scripts/lxc-template +171 -0
  46. data/scripts/pipework +422 -0
  47. data/spec/Vagrantfile +26 -0
  48. data/spec/fixtures/sample-ip-addr-output +2 -0
  49. data/spec/spec_helper.rb +35 -0
  50. data/spec/support/.gitkeep +0 -0
  51. data/spec/unit/action/clear_forwarded_ports_spec.rb +43 -0
  52. data/spec/unit/action/compress_rootfs_spec.rb +29 -0
  53. data/spec/unit/action/forward_ports_spec.rb +117 -0
  54. data/spec/unit/action/handle_box_metadata_spec.rb +126 -0
  55. data/spec/unit/action/setup_package_files_spec.rb +83 -0
  56. data/spec/unit/driver/cli_spec.rb +263 -0
  57. data/spec/unit/driver_spec.rb +268 -0
  58. data/spec/unit/support/unit_example_group.rb +38 -0
  59. data/spec/unit_helper.rb +17 -0
  60. data/tasks/spec.rake +40 -0
  61. data/templates/sudoers.rb.erb +129 -0
  62. data/vagrant-lxc.gemspec +20 -0
  63. data/vagrant-spec.config.rb +24 -0
  64. metadata +119 -0
@@ -0,0 +1,38 @@
1
+ module UnitExampleGroup
2
+ def self.included(base)
3
+ base.metadata[:type] = :unit
4
+ base.before do
5
+ allow_any_instance_of(Object).to receive(:system) { |instance, *args, &block|
6
+ UnitExampleGroup.prevent_system_calls(*args, &block)
7
+ }
8
+ allow_any_instance_of(Object).to receive(:`) { |instance, *args, &block|
9
+ UnitExampleGroup.prevent_system_calls(*args, &block)
10
+ }
11
+ allow_any_instance_of(Object).to receive(:exec) { |instance, *args, &block|
12
+ UnitExampleGroup.prevent_system_calls(*args, &block)
13
+ }
14
+ allow_any_instance_of(Object).to receive(:fork) { |instance, *args, &block|
15
+ UnitExampleGroup.prevent_system_calls(*args, &block)
16
+ }
17
+ allow_any_instance_of(Object).to receive(:spawn) { |instance, *args, &block|
18
+ UnitExampleGroup.prevent_system_calls(*args, &block)
19
+ }
20
+ require 'vagrant/util/subprocess'
21
+ allow(Vagrant::Util::Subprocess).to receive(:execute) { |*args, &block|
22
+ UnitExampleGroup.prevent_system_calls(*args, &block)
23
+ }
24
+ end
25
+ end
26
+
27
+ def self.prevent_system_calls(*args, &block)
28
+ args.pop if args.last.is_a?(Hash)
29
+
30
+ raise <<-MSG
31
+ Somehow your code under test is trying to execute a command on your system,
32
+ please stub it out or move your spec code to an acceptance spec.
33
+
34
+ Block: #{block.inspect}
35
+ Command: "#{args.join(' ')}"
36
+ MSG
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ Dir[File.dirname(__FILE__) + "/unit/support/**/*.rb"].each { |f| require f }
4
+
5
+ if defined? SimpleCov
6
+ SimpleCov.command_name 'unit'
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ config.include UnitExampleGroup, :type => :unit, :example_group => {
11
+ :file_path => /\bspec\/unit\//
12
+ }
13
+
14
+ config.mock_with :rspec do |c|
15
+ c.yield_receiver_to_any_instance_implementation_blocks = true
16
+ end
17
+ end
@@ -0,0 +1,40 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+ require 'coveralls/rake/task'
4
+
5
+ desc 'Run all specs'
6
+ task :spec => ['spec:set_coverage', 'spec:unit', 'spec:acceptance']
7
+
8
+ desc 'Default task which runs all specs with code coverage enabled'
9
+ task :default => ['spec:set_coverage', 'spec:unit']
10
+
11
+ Coveralls::RakeTask.new
12
+ task :ci => ['spec:set_coverage', 'spec:unit', 'coveralls:push']
13
+ rescue LoadError; end
14
+
15
+ namespace :spec do
16
+ task :set_coverage do
17
+ ENV['COVERAGE'] = 'true'
18
+ end
19
+
20
+ desc 'Run acceptance specs using vagrant-spec'
21
+ task :acceptance do
22
+ components = %w(
23
+ basic
24
+ network/forwarded_port
25
+ synced_folder
26
+ synced_folder/nfs
27
+ synced_folder/rsync
28
+ provisioner/shell
29
+ provisioner/puppet
30
+ provisioner/chef-solo
31
+ package
32
+ ).map{|s| "provider/lxc/#{s}" }
33
+ sh "export ACCEPTANCE=true && bundle exec vagrant-spec test --components=#{components.join(' ')}"
34
+ end
35
+
36
+ desc "Run unit specs with rspec"
37
+ RSpec::Core::RakeTask.new(:unit) do |t|
38
+ t.pattern = "./unit/**/*_spec.rb"
39
+ end
40
+ end
@@ -0,0 +1,129 @@
1
+ #!<%= cmd_paths['ruby'] %>
2
+ # Automatically created by vagrant-lxc
3
+
4
+ class Whitelist
5
+ class << self
6
+ def add(command, *args)
7
+ list[command] ||= []
8
+ list[command] << args
9
+ end
10
+
11
+ def add_regex(regex, *args)
12
+ regex_list << [regex, [args]]
13
+ end
14
+
15
+ def list
16
+ @list ||= {}
17
+ end
18
+
19
+ def regex_list
20
+ @regex_list ||= []
21
+ end
22
+
23
+ def allowed(command)
24
+ list[command] || allowed_regex(command) || []
25
+ end
26
+
27
+ def allowed_regex(command)
28
+ found = regex_list.find { |r| r[0] =~ command }
29
+ return found[1] if found
30
+ end
31
+
32
+ def run!(argv)
33
+ begin
34
+ command, args = `which #{argv.shift}`.chomp, argv || []
35
+ check!(command, args)
36
+ system "#{command} #{args.join(" ")}"
37
+
38
+ exit_code = $?.to_i
39
+ exit_code = 1 if exit_code == 256
40
+
41
+ exit exit_code
42
+ rescue => e
43
+ STDERR.puts e.message
44
+ exit 1
45
+ end
46
+ end
47
+
48
+ private
49
+ def check!(command, args)
50
+ allowed(command).each do |checks|
51
+ return if valid_args?(args, checks)
52
+ end
53
+ raise_invalid(command, args)
54
+ end
55
+
56
+ def valid_args?(args, checks)
57
+ return false unless valid_length?(args, checks)
58
+ check = nil
59
+ args.each_with_index do |provided, i|
60
+ check = checks[i] unless check == '**'
61
+ return false unless match?(provided, check)
62
+ end
63
+ true
64
+ end
65
+
66
+ def valid_length?(args, checks)
67
+ args.length == checks.length || checks.last == '**'
68
+ end
69
+
70
+ def match?(arg, check)
71
+ check == '**' || check.is_a?(Regexp) && !!check.match(arg) || arg == check
72
+ end
73
+
74
+ def raise_invalid(command, args)
75
+ raise "Invalid arguments for command #{command}, " <<
76
+ "provided args: #{args.inspect}"
77
+ end
78
+ end
79
+ end
80
+
81
+ base = "<%= lxc_base_path %>"
82
+ base_path = %r{\A#{base}/.*\z}
83
+
84
+ ##
85
+ # Commands from provider.rb
86
+ # - Check lxc is installed
87
+ Whitelist.add '<%= cmd_paths['which'] %>', /\Alxc-\w+\z/
88
+
89
+ ##
90
+ # Commands from driver.rb
91
+ # - Container config file
92
+ Whitelist.add '<%= cmd_paths['cat'] %>', base_path
93
+ # - Shared folders
94
+ Whitelist.add '<%= cmd_paths['mkdir'] %>', '-p', base_path
95
+ # - Container config customizations and pruning
96
+ Whitelist.add '<%= cmd_paths['cp'] %>', '-f', %r{/tmp/.*}, base_path
97
+ Whitelist.add '<%= cmd_paths['chown'] %>', 'root:root', base_path
98
+ # - Packaging
99
+ Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/rootfs.tar.gz}, '-C', base_path, './rootfs'
100
+ Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z}
101
+ # - Private network script and commands
102
+ Whitelist.add '<%= cmd_paths['ip'] %>', 'addr', 'add', /(\d+|\.)+\/24/, 'dev', /.+/
103
+ Whitelist.add '<%= cmd_paths['ip'] %>', 'link', 'set', /.+/, /(up|down)/
104
+ Whitelist.add '<%= cmd_paths['brctl'] %>', /(addbr|delbr)/, /.+/
105
+ Whitelist.add_regex %r{<%= pipework_regex %>}, '**'
106
+
107
+ ##
108
+ # Commands from driver/cli.rb
109
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-version'
110
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-ls'
111
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-info', '--name', /.*/
112
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-info', '--name', /.*/, '-iH'
113
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-create', '-B', /.*/, '--template', /.*/, '--name', /.*/, '**'
114
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-create', '--version'
115
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-destroy', '--name', /.*/
116
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-start', '-d', '--name', /.*/, '**'
117
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-stop', '--name', /.*/
118
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-shutdown', '--name', /.*/
119
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-attach', '--name', /.*/, '**'
120
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-attach', '-h'
121
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-config', 'lxc.lxcpath'
122
+ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-update-config', '-c', /.*/
123
+
124
+ ##
125
+ # Commands from driver/action/remove_temporary_files.rb
126
+ Whitelist.add '<%= cmd_paths['rm'] %>', '-rf', %r{\A#{base}/.*/rootfs/tmp/.*}
127
+
128
+ # Watch out for stones
129
+ Whitelist.run!(ARGV)
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-lxc/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "vagrant-lxc-2.1-patch"
8
+ gem.version = Vagrant::LXC::VERSION
9
+ gem.authors = ["Fabio Rehm"]
10
+ gem.email = ["fgrehm@gmail.com"]
11
+ gem.description = %q{Linux Containers provider for Vagrant. Patched for LXC 2.1+}
12
+ gem.summary = gem.description
13
+ gem.license = 'MIT'
14
+ gem.homepage = "https://github.com/kevcenteno/vagrant-lxc"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,24 @@
1
+ # FIXME: Figure out why this doesn't work
2
+ if ENV['COVERAGE'] == 'true'
3
+ require 'simplecov'
4
+ require 'coveralls'
5
+
6
+ SimpleCov.start { add_filter '/spec/' }
7
+ SimpleCov.command_name 'acceptance'
8
+ end
9
+
10
+ if ENV['BOX_PATH'] == nil
11
+ latest = ENV.fetch('LATEST_BOXES','2014-03-21')
12
+ release = ENV.fetch('RELEASE', 'acceptance')
13
+ local_path ="#{File.expand_path("../", __FILE__)}/boxes/output/#{latest}/vagrant-lxc-#{release}-amd64.box"
14
+ if File.exists?(local_path)
15
+ ENV['BOX_PATH'] = local_path
16
+ else
17
+ raise 'Set $BOX_PATH to the latest released boxes'
18
+ end
19
+ end
20
+
21
+ Vagrant::Spec::Acceptance.configure do |c|
22
+ c.component_paths << "spec/acceptance"
23
+ c.provider 'lxc', box: ENV['BOX_PATH'], features: ['!suspend']
24
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-lxc-2.1-patch
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Fabio Rehm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Linux Containers provider for Vagrant. Patched for LXC 2.1+
14
+ email:
15
+ - fgrehm@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - ".vimrc"
24
+ - BOXES.md
25
+ - CHANGELOG.md
26
+ - CONTRIBUTING.md
27
+ - Gemfile
28
+ - Guardfile
29
+ - LICENSE.txt
30
+ - README.md
31
+ - Rakefile
32
+ - lib/vagrant-lxc.rb
33
+ - lib/vagrant-lxc/action.rb
34
+ - lib/vagrant-lxc/action/boot.rb
35
+ - lib/vagrant-lxc/action/clear_forwarded_ports.rb
36
+ - lib/vagrant-lxc/action/compress_rootfs.rb
37
+ - lib/vagrant-lxc/action/create.rb
38
+ - lib/vagrant-lxc/action/destroy.rb
39
+ - lib/vagrant-lxc/action/destroy_confirm.rb
40
+ - lib/vagrant-lxc/action/fetch_ip_with_lxc_info.rb
41
+ - lib/vagrant-lxc/action/forced_halt.rb
42
+ - lib/vagrant-lxc/action/forward_ports.rb
43
+ - lib/vagrant-lxc/action/gc_private_network_bridges.rb
44
+ - lib/vagrant-lxc/action/handle_box_metadata.rb
45
+ - lib/vagrant-lxc/action/prepare_nfs_settings.rb
46
+ - lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb
47
+ - lib/vagrant-lxc/action/private_networks.rb
48
+ - lib/vagrant-lxc/action/setup_package_files.rb
49
+ - lib/vagrant-lxc/action/warn_networks.rb
50
+ - lib/vagrant-lxc/command/root.rb
51
+ - lib/vagrant-lxc/command/sudoers.rb
52
+ - lib/vagrant-lxc/config.rb
53
+ - lib/vagrant-lxc/driver.rb
54
+ - lib/vagrant-lxc/driver/cli.rb
55
+ - lib/vagrant-lxc/errors.rb
56
+ - lib/vagrant-lxc/plugin.rb
57
+ - lib/vagrant-lxc/provider.rb
58
+ - lib/vagrant-lxc/provider/cap/public_address.rb
59
+ - lib/vagrant-lxc/sudo_wrapper.rb
60
+ - lib/vagrant-lxc/synced_folder.rb
61
+ - lib/vagrant-lxc/version.rb
62
+ - locales/en.yml
63
+ - scripts/lxc-template
64
+ - scripts/pipework
65
+ - spec/Vagrantfile
66
+ - spec/fixtures/sample-ip-addr-output
67
+ - spec/spec_helper.rb
68
+ - spec/support/.gitkeep
69
+ - spec/unit/action/clear_forwarded_ports_spec.rb
70
+ - spec/unit/action/compress_rootfs_spec.rb
71
+ - spec/unit/action/forward_ports_spec.rb
72
+ - spec/unit/action/handle_box_metadata_spec.rb
73
+ - spec/unit/action/setup_package_files_spec.rb
74
+ - spec/unit/driver/cli_spec.rb
75
+ - spec/unit/driver_spec.rb
76
+ - spec/unit/support/unit_example_group.rb
77
+ - spec/unit_helper.rb
78
+ - tasks/spec.rake
79
+ - templates/sudoers.rb.erb
80
+ - vagrant-lxc.gemspec
81
+ - vagrant-spec.config.rb
82
+ homepage: https://github.com/kevcenteno/vagrant-lxc
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.6.14
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Linux Containers provider for Vagrant. Patched for LXC 2.1+
106
+ test_files:
107
+ - spec/Vagrantfile
108
+ - spec/fixtures/sample-ip-addr-output
109
+ - spec/spec_helper.rb
110
+ - spec/support/.gitkeep
111
+ - spec/unit/action/clear_forwarded_ports_spec.rb
112
+ - spec/unit/action/compress_rootfs_spec.rb
113
+ - spec/unit/action/forward_ports_spec.rb
114
+ - spec/unit/action/handle_box_metadata_spec.rb
115
+ - spec/unit/action/setup_package_files_spec.rb
116
+ - spec/unit/driver/cli_spec.rb
117
+ - spec/unit/driver_spec.rb
118
+ - spec/unit/support/unit_example_group.rb
119
+ - spec/unit_helper.rb