Skip to content

Commit

Permalink
fix md5 using ruby native as xapi-project#11 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenull committed Apr 10, 2016
1 parent c48267c commit 816d214
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/vagrant-xenserver/action/upload_vhd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "vagrant-xenserver/util/uploader"
require "rexml/document"
require "json"
require "digest/md5"

module VagrantPlugins
module XenServer
Expand All @@ -21,7 +22,7 @@ def get_vhd_size(box_vhd_file)
disk_info={}
begin
begin
disk_info=JSON.parse(IO.popen(["qemu-img", "info",box_vhd_file,"--output=json"]).read)
disk_info=JSON.parse(IO.popen(["qemu-img", "info",box_vhd_file,"--output=json"]).read)
rescue JSON::ParserError
size=`qemu-img info #{box_vhd_file} | grep "virtual size" | cut "-d(" -f2 | cut "-d " -f1`
disk_info['virtual-size']=size.strip
Expand All @@ -42,7 +43,7 @@ def call(env)
@logger.info("box name=" + env[:machine].box.name.to_s)
@logger.info("box version=" + env[:machine].box.version.to_s)

md5=`dd if=#{box_vhd_file} bs=1M count=1 | md5sum | cut '-d ' -f1`.strip
md5=File.open(box_vhd_file) do |fh| Digest::MD5.hexdigest(fh.read(1024*1024)) end

@logger.info("md5=#{md5}")

Expand Down

0 comments on commit 816d214

Please sign in to comment.