class PackerFiles::Virtual::VMWareConverter
Attributes
value[R]
Hash Value
Public Class Methods
new(os, gen)
click to toggle source
Constructor
# File lib/PackerFiles/Virtual/VMWareConverter.rb, line 14 def initialize(os, gen) @value = convert(os, gen).to_hash end
Public Instance Methods
convert(os, gen)
click to toggle source
Convert OS object into a hash
# File lib/PackerFiles/Virtual/VMWareConverter.rb, line 19 def convert(os, gen) VMWare.new do |vmware| # Fill in output directory and builder name rel = os.CDImage.release arch = os.CDImage.arch name = os.name.gsub('::', '-') vmware.output_directory = "output-#{name}-#{rel}-#{arch}-#{vmware.type}" vmware.name = "#{name}-#{rel}-#{arch}-#{vmware.type}" # Fill in image details, Some amount of url handling # is really required to handle various corner cases. # thus making the code a bit harder to understand vmware.iso_checksum_type = os.CDImage.check_sum_type vmware.iso_checksum = os.CDImage.check_sum # The code below creates a user variable called mirror # whose base value is the URL fragment w/o the file-name. url = URI::parse(os.CDImage.iso_url) file = File.basename(url.path) url.path = File.dirname(url.path) gen.variables['mirror'] = url.to_s vmware.iso_url = "{{user `mirror`}}/#{file}" # Fill in SSH specifics vmware.ssh_username = os.User.login vmware.ssh_password = os.User.password vmware.ssh_wait_timeout = '10000s' # Fill in other specifics vmware.disk_size = os.Disk.size vmware.http_directory = File.basename(os.http_dir) vmware.guest_os_type = os.vmware_guest_os_type # Fill in boot command and boot_wait timeout gen.variables['host'] = '' gen.variables['port'] = '' user_var_name = name + "-#{vmware.type}-boot-wait" gen.variables[user_var_name] = "10s" vmware.boot_command = os.boot_command vmware.boot_wait = "{{user `#{user_var_name}`}}" # Fill in shutdown command vmware.shutdown_command = os.shutdown_command # Generate vmx commands vmware.Hypervisor(os.Hypervisors.VMWare) # Tools flavor vmware.tools_upload_flavor = os.vmware_guest_os_flavor # Merge with Custom values vmware.merge_hs(os.Hypervisors.VMWare.custom) end end