class PackerFiles::Builder

The Builder class is used as the base for building OS classes that generate all the files required for Packer to work properly for a given OS

Attributes

OutDir[RW]

attr_accessor for output directory

Public Class Methods

versions() click to toggle source

Versions supported by this class

# File lib/PackerFiles/OS/Builder.rb, line 27
def self.versions
   []
end

Public Instance Methods

Generate() click to toggle source

Base class function that needs to be called first to handle parameter validation.

# File lib/PackerFiles/OS/Builder.rb, line 51
def Generate
  if @OutDir.nil?
     raise ArgumentError.new('Need to provide output directory')
  end

  # Track through all the accessors in the ancestry tree and check
  # if non-optional type accessors are missing.
  index     = self.class.ancestors.index(Builder)
  ancestors = self.class.ancestors.slice(0, index + 1 )
  ancestors.each do |klass|
     hash  = klass.type_accessors
     next  if hash.nil?
     hash.each_pair do |func, type_data|
        opt = type_data.last
        obj = self.method(func).call
        raise Utils::MissingAccessor.new(func, self.name) if obj.nil? && !opt
     end
  end

  # Normalize CD Image by calling the cd image hook of the derived class.
  cd_image_hook
  self.CDImage.normalize

  # Call Hook for derived classes to add their functionality.
  generate_hook
    
  # Generate Packer File
  generate_packer_file

end
http_dir() click to toggle source

Name of the http directory

# File lib/PackerFiles/OS/Builder.rb, line 37
def http_dir
  File.join(@OutDir, 'http')
end
name() click to toggle source

Name of this class as exposed to others

# File lib/PackerFiles/OS/Builder.rb, line 32
def name
   self.class.name.gsub('PackerFiles::','')
end
packer_json_file() click to toggle source

Name of the top level JSON file

# File lib/PackerFiles/OS/Builder.rb, line 42
def packer_json_file
  rel  = self.CDImage.release
  arch = self.CDImage.arch
  file = self.name.gsub('::', '-') + "-#{rel}-#{arch}.json"
  File.join(@OutDir, file)
end

Private Instance Methods

boot_command() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 106
def boot_command; end
cd_image_hook() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 102
def cd_image_hook; end
disable_root_for_user() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 113
def disable_root_for_user; end
enable_root_for_user() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 112
def enable_root_for_user; end
generate_hook() click to toggle source

Various hook functions

# File lib/PackerFiles/OS/Builder.rb, line 101
def generate_hook; end
generate_packer_file() click to toggle source

Generate the Various Packer File components

# File lib/PackerFiles/OS/Builder.rb, line 84
def generate_packer_file

  # Manage various packer file components via the generator
  gen = Utils::Generator.new

  # handle hypervisors
  self.Hypervisors.convert(gen, self)

  # handle provisioners
  self.Provision.convert(gen, self) if !self.Provision.nil?

  # Finally generate the JSON for packer
  gen.create_json(packer_json_file)

end
guest_os_type() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 108
def guest_os_type; end
kvm_converter_hook(gen) click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 105
def kvm_converter_hook(gen); end
run_command_as_root() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 111
def run_command_as_root;   end
shutdown_command() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 107
def shutdown_command; end
vbox_converter_hook(gen) click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 103
def vbox_converter_hook(gen); end
vmware_converter_hook(gen) click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 104
def vmware_converter_hook(gen); end
vmware_guest_os_flavor() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 110
def vmware_guest_os_flavor; end
vmware_guest_os_type() click to toggle source
# File lib/PackerFiles/OS/Builder.rb, line 109
def vmware_guest_os_type; end