vagrant-mutate 0.2.6 → 0.3.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.
- data/CHANGELOG.md +6 -0
- data/README.md +7 -5
- data/lib/vagrant-mutate/box_loader.rb +15 -25
- data/lib/vagrant-mutate/converter/kvm.rb +1 -1
- data/lib/vagrant-mutate/errors.rb +4 -0
- data/lib/vagrant-mutate/mutate.rb +12 -4
- data/lib/vagrant-mutate/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/test/test.rb +15 -14
- metadata +18 -12
- checksums.yaml +0 -7
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 0.3.0 (2014-05-04)
|
2
|
+
* Support Vagrant 1.5 with unversioned boxes (#47)
|
3
|
+
* Drop support for Vagrant < 1.5
|
4
|
+
* Move input provider specifier into own option
|
5
|
+
* Warn if user provided identifier for Vagrant Cloud
|
6
|
+
|
1
7
|
# 0.2.6 (2014-05-04)
|
2
8
|
* Include CentOS 6.5/RHEL 6.5-friendly Qemu paths (#50)
|
3
9
|
|
data/README.md
CHANGED
@@ -11,14 +11,16 @@ Vagrant-mutate is a vagrant plugin to convert vagrant boxes to work with differe
|
|
11
11
|
|
12
12
|
## Compatibility
|
13
13
|
|
14
|
-
Vagrant-mutate
|
14
|
+
Vagrant-mutate 0.3 and later requires Vagrant 1.5. If you are using an older vagrant, install vagrant-mutate version 0.2.6.
|
15
15
|
|
16
|
-
|
16
|
+
Throughout its development vagrant-mutate has been tested against the following versions. It may work with other versions too.
|
17
17
|
|
18
|
-
* [vagrant](http://www.vagrantup.com) 1.3.5 and 1.4
|
18
|
+
* [vagrant](http://www.vagrantup.com) 1.3.5, 1.4.3, and 1.5.4
|
19
19
|
* [vagrant-kvm](https://github.com/adrahon/vagrant-kvm) 0.1.4
|
20
20
|
* [vagrant-libvirt](https://github.com/pradels/vagrant-libvirt) 0.0.11
|
21
21
|
|
22
|
+
Vagrant-mutate does not yet fully support [versioned boxes](http://docs.vagrantup.com/v2/boxes/versioning.html). It always assumes a box has the version *0*.
|
23
|
+
|
22
24
|
## Installation
|
23
25
|
|
24
26
|
### qemu-img
|
@@ -67,12 +69,12 @@ Or if you had already added the box to vagrant and now want to use it with libvi
|
|
67
69
|
|
68
70
|
vagrant mutate precise32 libvirt
|
69
71
|
|
70
|
-
If you have a box for multiple providers, you must specify the provider to use for input
|
72
|
+
If you have a box for multiple providers, you must specify the provider to use for input using the *--input_provider* option, e.g.
|
71
73
|
|
72
74
|
$ vagrant box list
|
73
75
|
precise32 (kvm)
|
74
76
|
precise32 (virtualbox)
|
75
|
-
$ vagrant mutate virtualbox
|
77
|
+
$ vagrant mutate --input_provider=virtualbox precise32 libvirt
|
76
78
|
|
77
79
|
To export a box you created with vagrant mutate, just repackage it, e.g.
|
78
80
|
|
@@ -25,13 +25,15 @@ module VagrantMutate
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def load(box_arg)
|
28
|
+
def load(box_arg, provider_name)
|
29
29
|
if box_arg =~ /:\/\//
|
30
30
|
box = load_from_url(box_arg)
|
31
31
|
elsif File.file?(box_arg)
|
32
32
|
box = load_from_file(box_arg)
|
33
|
+
elsif box_arg =~ /\//
|
34
|
+
raise Errors::CloudNotSupported
|
33
35
|
else
|
34
|
-
box = load_from_boxes_path(box_arg)
|
36
|
+
box = load_from_boxes_path(box_arg, provider_name)
|
35
37
|
end
|
36
38
|
|
37
39
|
if box.supported_input
|
@@ -88,9 +90,8 @@ module VagrantMutate
|
|
88
90
|
box = create_box(provider_name, name, dir)
|
89
91
|
end
|
90
92
|
|
91
|
-
def load_from_boxes_path(
|
92
|
-
@logger.info "Loading box #{
|
93
|
-
provider_name, name = parse_identifier(identifier)
|
93
|
+
def load_from_boxes_path(name, provider_name)
|
94
|
+
@logger.info "Loading box #{name} from vagrants box path"
|
94
95
|
if provider_name
|
95
96
|
dir = verify_input_dir(provider_name, name)
|
96
97
|
else
|
@@ -129,8 +130,9 @@ module VagrantMutate
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def create_output_dir(name, provider_name)
|
132
|
-
# e.g. $HOME/.vagrant.d/boxes/fedora-19/libvirt
|
133
|
-
|
133
|
+
# e.g. $HOME/.vagrant.d/boxes/fedora-19/0/libvirt
|
134
|
+
# TODO support versioned boxes
|
135
|
+
out_dir = File.join( @env.boxes_path, name, '0', provider_name )
|
134
136
|
begin
|
135
137
|
FileUtils.mkdir_p(out_dir)
|
136
138
|
rescue => e
|
@@ -142,7 +144,7 @@ module VagrantMutate
|
|
142
144
|
|
143
145
|
def unpack(file)
|
144
146
|
@env.ui.info "Extracting box file to a temporary directory."
|
145
|
-
unless File.
|
147
|
+
unless File.exist? file
|
146
148
|
raise Errors::BoxNotFound, :box => file
|
147
149
|
end
|
148
150
|
tmp_dir = Dir.mktmpdir(nil, @env.tmp_path)
|
@@ -158,7 +160,7 @@ module VagrantMutate
|
|
158
160
|
|
159
161
|
def determine_provider(dir)
|
160
162
|
metadata_file = File.join(dir, 'metadata.json')
|
161
|
-
if File.
|
163
|
+
if File.exist? metadata_file
|
162
164
|
begin
|
163
165
|
metadata = JSON.load( File.new( metadata_file, 'r') )
|
164
166
|
rescue => e
|
@@ -172,22 +174,9 @@ module VagrantMutate
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
175
|
-
def parse_identifier(identifier)
|
176
|
-
split_id = identifier.split('/')
|
177
|
-
case split_id.length
|
178
|
-
when 2
|
179
|
-
@logger.info "Parsed provider name as #{split_id[0]} and box name as #{split_id[1]}"
|
180
|
-
return split_id[0], split_id[1]
|
181
|
-
when 1
|
182
|
-
@logger.info "Parsed provider name as not given and box name as #{identifier}"
|
183
|
-
return nil, identifier
|
184
|
-
else
|
185
|
-
raise Errors::ParseIdentifierFailed, :identifier => identifier
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
177
|
def verify_input_dir(provider_name, name)
|
190
|
-
|
178
|
+
# TODO support versioned boxes
|
179
|
+
input_dir = File.join( @env.boxes_path, name, '0', provider_name)
|
191
180
|
if File.directory?(input_dir)
|
192
181
|
@logger.info "Found input directory #{input_dir}"
|
193
182
|
return input_dir
|
@@ -197,7 +186,8 @@ module VagrantMutate
|
|
197
186
|
end
|
198
187
|
|
199
188
|
def find_input_dir(name)
|
200
|
-
|
189
|
+
# TODO support versioned boxes
|
190
|
+
box_parent_dir = File.join( @env.boxes_path, name, '0')
|
201
191
|
|
202
192
|
if Dir.exist?(box_parent_dir)
|
203
193
|
providers = Dir.entries(box_parent_dir).reject { |entry| entry =~ /^\./ }
|
@@ -46,7 +46,7 @@ module VagrantMutate
|
|
46
46
|
'/usr/bin/qemu-kvm',
|
47
47
|
'/usr/libexec/qemu-kvm',
|
48
48
|
'/usr/bin/kvm' ]
|
49
|
-
qemu_bin = qemu_bin_list.detect { |binary| File.
|
49
|
+
qemu_bin = qemu_bin_list.detect { |binary| File.exist? binary }
|
50
50
|
unless qemu_bin
|
51
51
|
raise Errors::QemuNotFound
|
52
52
|
end
|
@@ -7,9 +7,17 @@ module VagrantMutate
|
|
7
7
|
class Mutate < Vagrant.plugin(2, :command)
|
8
8
|
|
9
9
|
def execute
|
10
|
+
options = {}
|
11
|
+
options[:input_provider] = nil
|
12
|
+
|
10
13
|
opts = OptionParser.new do |o|
|
11
14
|
o.banner = 'Usage: vagrant mutate <box-name-or-file> <provider>'
|
15
|
+
o.on("--input_provider PROVIDER",
|
16
|
+
"Specify provider for input box") do |p|
|
17
|
+
options[:input_provider] = p
|
18
|
+
end
|
12
19
|
end
|
20
|
+
|
13
21
|
argv = parse_options(opts)
|
14
22
|
return if !argv
|
15
23
|
|
@@ -18,17 +26,17 @@ module VagrantMutate
|
|
18
26
|
return
|
19
27
|
end
|
20
28
|
|
21
|
-
box_arg = argv[0]
|
22
|
-
|
29
|
+
options[:box_arg] = argv[0]
|
30
|
+
options[:output_provider] = argv[1]
|
23
31
|
|
24
32
|
Qemu.verify_qemu_installed
|
25
33
|
Qemu.verify_qemu_version(@env)
|
26
34
|
|
27
35
|
input_loader = BoxLoader.new(@env)
|
28
|
-
input_box = input_loader.load(box_arg)
|
36
|
+
input_box = input_loader.load( options[:box_arg], options[:input_provider] )
|
29
37
|
|
30
38
|
output_loader = BoxLoader.new(@env)
|
31
|
-
output_box = output_loader.prepare_for_output( input_box.name,
|
39
|
+
output_box = output_loader.prepare_for_output( input_box.name, options[:output_provider])
|
32
40
|
|
33
41
|
converter = Converter::Converter.create(@env, input_box, output_box)
|
34
42
|
converter.convert
|
data/locales/en.yml
CHANGED
data/test/test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
def cleanup
|
6
6
|
puts "\nCLEANING UP"
|
7
|
-
base_output_dir = File.expand_path('../actual_output', __FILE__)
|
7
|
+
base_output_dir = File.expand_path('../actual_output', __FILE__)
|
8
8
|
if File.directory? base_output_dir
|
9
9
|
FileUtils.rm_rf base_output_dir
|
10
10
|
end
|
@@ -12,8 +12,8 @@ end
|
|
12
12
|
|
13
13
|
def build_plugin
|
14
14
|
puts "\nBUILDING PLUGIN"
|
15
|
-
pkg_dir = File.expand_path('../../pkg', __FILE__)
|
16
|
-
working_dir = Dir.pwd
|
15
|
+
pkg_dir = File.expand_path('../../pkg', __FILE__)
|
16
|
+
working_dir = Dir.pwd
|
17
17
|
Dir.chdir pkg_dir
|
18
18
|
FileUtils.rm( Dir.glob('*.gem') )
|
19
19
|
system('rake build')
|
@@ -22,8 +22,8 @@ end
|
|
22
22
|
|
23
23
|
def install_plugin
|
24
24
|
puts "\nINSTALLING PLUGIN"
|
25
|
-
pkg_dir = File.expand_path('../../pkg', __FILE__)
|
26
|
-
working_dir = Dir.pwd
|
25
|
+
pkg_dir = File.expand_path('../../pkg', __FILE__)
|
26
|
+
working_dir = Dir.pwd
|
27
27
|
Dir.chdir pkg_dir
|
28
28
|
system('vagrant plugin install *.gem')
|
29
29
|
Dir.chdir working_dir
|
@@ -39,8 +39,8 @@ def derandomize_output(input, output_dir)
|
|
39
39
|
contents = File.read(path)
|
40
40
|
contents.gsub!(/52:54:00:[0-9a-f:]+/, '52:54:00:cb:b2:80')
|
41
41
|
contents.gsub!(/525400[0-9a-f]+/, '525400cbb280')
|
42
|
-
File.open(path, 'w') do |
|
43
|
-
|
42
|
+
File.open(path, 'w') do |o|
|
43
|
+
o.write(contents)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -49,11 +49,11 @@ end
|
|
49
49
|
|
50
50
|
def test(input, outputs)
|
51
51
|
failures = []
|
52
|
-
test_dir = File.expand_path( File.dirname(__FILE__) )
|
52
|
+
test_dir = File.expand_path( File.dirname(__FILE__) )
|
53
53
|
|
54
|
-
input_box = File.join(test_dir, 'input', input, 'mutate-test.box')
|
54
|
+
input_box = File.join(test_dir, 'input', input, 'mutate-test.box')
|
55
55
|
|
56
|
-
vagrant_dir = File.join(test_dir, 'actual_output', input)
|
56
|
+
vagrant_dir = File.join(test_dir, 'actual_output', input)
|
57
57
|
FileUtils.mkdir_p vagrant_dir
|
58
58
|
ENV['VAGRANT_HOME'] = vagrant_dir
|
59
59
|
install_plugin
|
@@ -61,7 +61,8 @@ def test(input, outputs)
|
|
61
61
|
outputs.each do |output|
|
62
62
|
puts "\nTESTING #{input} to #{output}"
|
63
63
|
system("vagrant mutate #{input_box} #{output}")
|
64
|
-
|
64
|
+
# 0 because input boxes are unversioned
|
65
|
+
output_dir = File.join(vagrant_dir, 'boxes', 'mutate-test', '0', output)
|
65
66
|
expected_output_dir = File.join(test_dir, 'expected_output', input, output)
|
66
67
|
derandomize_output(input, output_dir)
|
67
68
|
Dir.foreach(expected_output_dir) do |f|
|
@@ -84,9 +85,9 @@ failures = test( 'virtualbox', ['kvm', 'libvirt'] )
|
|
84
85
|
failures += test( 'libvirt', ['kvm'] )
|
85
86
|
failures += test( 'kvm', ['libvirt'] )
|
86
87
|
|
87
|
-
|
88
|
+
if failures.empty?
|
89
|
+
puts "\nALL TESTS PASSED"
|
90
|
+
else
|
88
91
|
puts "\nTESTS FAILED"
|
89
92
|
failures.each {|f| puts f}
|
90
|
-
else
|
91
|
-
puts "\nALL TESTS PASSED"
|
92
93
|
end
|
metadata
CHANGED
@@ -1,41 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-mutate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Brian Pitts
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-18 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.3'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.3'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
description: Convert vagrant boxes to work with different providers
|
@@ -45,7 +50,7 @@ executables: []
|
|
45
50
|
extensions: []
|
46
51
|
extra_rdoc_files: []
|
47
52
|
files:
|
48
|
-
-
|
53
|
+
- .gitignore
|
49
54
|
- CHANGELOG.md
|
50
55
|
- Gemfile
|
51
56
|
- LICENSE.txt
|
@@ -88,26 +93,27 @@ files:
|
|
88
93
|
homepage: ''
|
89
94
|
licenses:
|
90
95
|
- MIT
|
91
|
-
metadata: {}
|
92
96
|
post_install_message:
|
93
97
|
rdoc_options: []
|
94
98
|
require_paths:
|
95
99
|
- lib
|
96
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
97
102
|
requirements:
|
98
|
-
- -
|
103
|
+
- - ! '>='
|
99
104
|
- !ruby/object:Gem::Version
|
100
105
|
version: '0'
|
101
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
102
108
|
requirements:
|
103
|
-
- -
|
109
|
+
- - ! '>='
|
104
110
|
- !ruby/object:Gem::Version
|
105
111
|
version: '0'
|
106
112
|
requirements: []
|
107
113
|
rubyforge_project:
|
108
|
-
rubygems_version:
|
114
|
+
rubygems_version: 1.8.23
|
109
115
|
signing_key:
|
110
|
-
specification_version:
|
116
|
+
specification_version: 3
|
111
117
|
summary: Convert vagrant boxes to work with different providers
|
112
118
|
test_files:
|
113
119
|
- test/expected_output/kvm/libvirt/Vagrantfile
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 4782f5d4cba1aea0370134ebe65d9bfe5466b158
|
4
|
-
data.tar.gz: 973ab07ff59bd8e8c8159156fe4473ac7de07f66
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 6e741a3605d4c9d855554169a187fbdc6d0578c585809c8b77cf37c1093839411a1c9bb3fad6278b17472fd9affdb4c24edff2da45d199d92386b18982e4bff2
|
7
|
-
data.tar.gz: f2dfe11947e128475622c9b1cff97b1c2fe49ce313d77f39b410dfe2ba8f93e73c14ce025c07565c47e4715fde9a2aab08a2ff15fa1b3cfb846c1fee208296be
|