vagrant-mutate 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.2.3 (2014-01-20)
2
+ * Warn when qemu version cannot read vmdk3 files (#29)
3
+ * Fix errors in how box name and provider were parsed (#35)
4
+ * Load box from file based on existence not name (#36)
5
+ * Warn when image is not the expected type for the provider (#38)
6
+
1
7
  # 0.2.2 (2014-01-05)
2
8
  * Determine virtualbox disk filename from ovf (#30)
3
9
  * Move Qemu checks to own class
data/README.md CHANGED
@@ -21,7 +21,7 @@ Vagrant-mutate has been tested against the following versions. It may work with
21
21
 
22
22
  ### qemu-img
23
23
 
24
- First, you must install [qemu-img](http://wiki.qemu.org/Main_Page). Support for the disk image format most commonly used in vagrant boxes for virtualbox was added in [version 1.2.0](http://wiki.qemu.org/ChangeLog/1.2#VMDK); if you have an older version vagrant-mutate will warn you and most likely won't work.
24
+ First, you must install [qemu-img](http://wiki.qemu.org/Main_Page). Information on supported versions is listed at [QEMU Version Compatibility](https://github.com/sciurus/vagrant-mutate/wiki/QEMU-Version-Compatibility).
25
25
 
26
26
  #### Debian and derivatives
27
27
 
@@ -12,13 +12,25 @@ module VagrantMutate
12
12
  end
13
13
 
14
14
  def virtual_size
15
+ extract_from_qemu_info( /(\d+) bytes/ )
16
+ end
17
+
18
+ def verify_format
19
+ format_found = extract_from_qemu_info( /file format: (\w+)/ )
20
+ unless format_found == @image_format
21
+ @env.ui.warn "Expected input image format to be #{@image_format} but "\
22
+ "it is #{format_found}. Attempting conversion anyway."
23
+ end
24
+ end
25
+
26
+ def extract_from_qemu_info(expression)
15
27
  input_file = File.join( @dir, image_name )
16
28
  info = `qemu-img info #{input_file}`
17
29
  @logger.debug "qemu-img info output\n#{info}"
18
- if info =~ /(\d+) bytes/
30
+ if info =~ expression
19
31
  return $1
20
32
  else
21
- raise Errors::DetermineImageSizeFailed
33
+ raise Errors::QemuInfoFailed
22
34
  end
23
35
  end
24
36
 
@@ -28,7 +28,7 @@ module VagrantMutate
28
28
  def load(box_arg)
29
29
  if box_arg =~ /:\/\//
30
30
  box = load_from_url(box_arg)
31
- elsif box_arg =~ /\.box$/
31
+ elsif File.file?(box_arg)
32
32
  box = load_from_file(box_arg)
33
33
  else
34
34
  box = load_from_boxes_path(box_arg)
@@ -173,12 +173,16 @@ module VagrantMutate
173
173
  end
174
174
 
175
175
  def parse_identifier(identifier)
176
- if identifier =~ /^([\w-]+)#{File::SEPARATOR}([\w-]+)$/
177
- @logger.info "Parsed provider name as #{$1} and box name as #{$2}"
178
- return $1, $2
179
- else
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
180
182
  @logger.info "Parsed provider name as not given and box name as #{identifier}"
181
183
  return nil, identifier
184
+ else
185
+ raise Errors::ParseIdentifierFailed, :identifier => identifier
182
186
  end
183
187
  end
184
188
 
@@ -32,6 +32,7 @@ module VagrantMutate
32
32
  @env.ui.info "Converting #{@input_box.name} from #{@input_box.provider_name} "\
33
33
  "to #{@output_box.provider_name}."
34
34
 
35
+ @input_box.verify_format
35
36
  write_metadata
36
37
  copy_vagrantfile
37
38
  write_specific_files
@@ -95,7 +96,7 @@ module VagrantMutate
95
96
  # S for sparse file
96
97
  qemu_options = '-p -S 16k'
97
98
 
98
- command = "qemu-img convert #{qemu_options} -f #{input_format} -O #{output_format} #{input_file} #{output_file}"
99
+ command = "qemu-img convert #{qemu_options} -O #{output_format} #{input_file} #{output_file}"
99
100
  @logger.info "Running #{command}"
100
101
  unless system(command)
101
102
  raise Errors::WriteDiskFailed, :error_message => "qemu-img exited with status #{$?.exitstatus}"
@@ -30,6 +30,10 @@ module VagrantMutate
30
30
  error_key(:extract_box_failed)
31
31
  end
32
32
 
33
+ class ParseIdentifierFailed < VagrantMutateError
34
+ error_key(:parse_identifier_failed)
35
+ end
36
+
33
37
  class DetermineProviderFailed < VagrantMutateError
34
38
  error_key(:determine_provider_failed)
35
39
  end
@@ -54,8 +58,8 @@ module VagrantMutate
54
58
  error_key(:parse_qemu_version_failed)
55
59
  end
56
60
 
57
- class DetermineImageSizeFailed < VagrantMutateError
58
- error_key(:determine_image_size_failed)
61
+ class QemuInfoFailed < VagrantMutateError
62
+ error_key(:qemu_info_failed)
59
63
  end
60
64
 
61
65
  class BoxAttributeError < VagrantMutateError
@@ -21,12 +21,16 @@ module VagrantMutate
21
21
  def self.verify_qemu_version(env)
22
22
  usage = `qemu-img`
23
23
  if usage =~ /(\d+\.\d+\.\d+)/
24
- recommended_version = Gem::Version.new('1.2.0')
25
24
  installed_version = Gem::Version.new($1)
26
- if installed_version < recommended_version
25
+ # will need to change test once a version > 1.6 has a fix
26
+ if installed_version < Gem::Version.new('1.2.0') or
27
+ installed_version >= Gem::Version.new('1.6.0')
28
+
27
29
  env.ui.warn "You have qemu #{installed_version} installed. "\
28
- "This version is too old to read some virtualbox boxes. "\
29
- "If conversion fails, try upgrading to qemu 1.2.0 or newer."
30
+ "This version cannot read some virtualbox boxes. "\
31
+ "If conversion fails, see below for recommendations. "\
32
+ "https://github.com/sciurus/vagrant-mutate/wiki/QEMU-Version-Compatibility"
33
+
30
34
  end
31
35
  else
32
36
  raise Errors::ParseQemuVersionFailed
@@ -1,3 +1,3 @@
1
1
  module VagrantMutate
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
data/locales/en.yml CHANGED
@@ -14,6 +14,9 @@ en:
14
14
  extract_box_failed: |-
15
15
  Extracting box failed with error:
16
16
  %{error_message}
17
+ parse_identifier_failed: |-
18
+ Expected name or provider/name but you gave %{identifier}.
19
+ If you meant to specify a box by name fix this. If you meant to specify a box by path make sure the file exists.
17
20
  determine_provider_failed: |-
18
21
  Determining provider for box failed with error:
19
22
  %{error_message}
@@ -31,8 +34,8 @@ en:
31
34
  %{error_message}
32
35
  parse_qemu_version_failed: |-
33
36
  Determining the version of qemu-img installed failed
34
- determine_image_size_failed: |-
35
- Determining the virtual size of the disk image failed
37
+ qemu_info_failed: |-
38
+ Getting information about the disk image via qemu-info failed
36
39
  box_attribute_error: |-
37
40
  Error determining information about the input box:
38
41
  %{error_message}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-mutate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-05 00:00:00.000000000 Z
12
+ date: 2014-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler