Class: DaptivChefCI::VirtualBoxBaseBoxBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/daptiv-chef-ci/virtualbox_basebox_builder.rb

Overview

This class builds VBox Vagrant boxes

Instance Method Summary collapse

Constructor Details

#initialize(base_dir, shell) ⇒ VirtualBoxBaseBoxBuilder

Creates a new box builder instance

of the box we want to package, i.e. /Users/admin/src/dotnetframework

Parameters:

  • The (String)

    full path to the directory where the Vagrantfile exists

  • A (Shell)

    shell instance



15
16
17
18
19
# File 'lib/daptiv-chef-ci/virtualbox_basebox_builder.rb', line 15

def initialize(base_dir, shell)
  @shell = shell
  @base_dir = base_dir
  @logger = Log4r::Logger.new("daptiv_chef_ci::vmware_base_box_builder")
end

Instance Method Details

#build(box_file) ⇒ Object

Packages a VBox Vagrant box. This can take 15 minutes or so.

Parameters:

  • base (String)

    box file name, i.e. ‘windows-server-2008.box’



24
25
26
27
28
29
30
# File 'lib/daptiv-chef-ci/virtualbox_basebox_builder.rb', line 24

def build(box_file)
  Dir.chdir(@base_dir) {
    @logger.info("Packaging box #{box_file}")
    FileUtils.rm(box_file) if File.exists?(box_file)
    @shell.exec_cmd("vagrant package --output #{box_file}", 3600)
  }
end