Sha256: 6bf9bdbbc463a27962a04150d9efcbcbde25ebb36bd8d70d3e7e98755b38bb09

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'boxgrinder-build/plugins/base-plugin'

module BoxGrinder

  class MultiDiskPlugin < BasePlugin
    plugin :type => :platform, :name => :multidisk, :full_name  => "Multi Disk"

    def after_init
      register_deliverable(:vmdk_sparse => "#{@appliance_config.name}-sparse.vmdk")
      register_deliverable(:vmdk_stream => "#{@appliance_config.name}-streamoptimized.vmdk")
      register_deliverable(:vhd => "#{@appliance_config.name}.vhd")
      register_deliverable(:qcow_sparse => "#{@appliance_config.name}-sparse.qcow2")
      register_deliverable(:qcow_compressed => "#{@appliance_config.name}-compressed.qcow2")
    end

    def execute
      @log.info "Converting RAW to multiple disk formats"

      @log.info "Converting to VMDK Sparse using qemu-img..."
      @exec_helper.execute "qemu-img convert -O vmdk '#{@previous_deliverables.disk}' '#{@deliverables.vmdk_sparse}'"

      @log.info "Converting to QCow2 Sparse using qemu-img..."
      @exec_helper.execute "qemu-img convert -O qcow2 '#{@previous_deliverables.disk}' '#{@deliverables.qcow_sparse}'"

      @log.info "Converting to QCow2 Compressed Sparse using qemu-img..."
      @exec_helper.execute "qemu-img convert -c -O qcow2 '#{@previous_deliverables.disk}' '#{@deliverables.qcow_compressed}'"

      if `which VBoxManage`.empty?
        @log.error "VBoxManage binary not found in your path, skipping VMDK Stream format."
      else
        @log.info "Using VBoxManage to convert the image..."
        @log.info "Converting to VMDK..."
        @exec_helper.execute "VBoxManage clonehd --format VMDK --variant Stream '#{@deliverables.vmdk_sparse}' '#{@deliverables.vmdk_stream}'"
        @log.info "Converting to VHD..."
        @exec_helper.execute "VBoxManage clonehd --format VHD '#{@deliverables.vmdk_sparse}' '#{@deliverables.vhd}'"
      end

      @log.info "Conversions done."
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multidisk-boxgrinder-plugin-0.1.2 lib/multidisk-boxgrinder-plugin.rb