lib/veewee/definition.rb in veewee-0.3.6 vs lib/veewee/definition.rb in veewee-0.3.7
- old
+ new
@@ -8,37 +8,36 @@
attr_accessor :name
attr_accessor :env
attr_accessor :path
- attr_accessor :cpu_count,:memory_size,:iso_file
+ attr_accessor :cpu_count, :memory_size, :video_memory_size, :iso_file
attr_accessor :disk_size, :disk_format, :disk_variant
attr_accessor :os_type_id
- attr_accessor :boot_wait,:boot_cmd_sequence
+ attr_accessor :boot_wait, :boot_cmd_sequence
- attr_accessor :kickstart_port,:kickstart_ip,:kickstart_timeout, :kickstart_file
+ attr_accessor :kickstart_port, :kickstart_ip, :kickstart_timeout, :kickstart_file
- attr_accessor :ssh_login_timeout, :ssh_user , :ssh_password, :ssh_key, :ssh_host_port, :ssh_guest_port
+ attr_accessor :ssh_login_timeout, :ssh_user, :ssh_password, :ssh_key, :ssh_host_port, :ssh_guest_port
- attr_accessor :winrm_login_timeout, :winrm_user , :winrm_password, :winrm_host_port, :winrm_guest_port
+ attr_accessor :winrm_login_timeout, :winrm_user, :winrm_password, :winrm_host_port, :winrm_guest_port
attr_accessor :sudo_cmd
attr_accessor :shutdown_cmd
attr_accessor :pre_postinstall_file
attr_accessor :postinstall_files, :postinstall_timeout
attr_accessor :floppy_files
+ attr_accessor :use_hw_virt_ext, :use_pae, :hostiocache, :use_sata
- attr_accessor :use_hw_virt_ext,:use_pae,:hostiocache, :use_sata
+ attr_accessor :iso_dowload_timeout, :iso_src, :iso_md5, :iso_download_instructions
- attr_accessor :iso_dowload_timeout, :iso_src,:iso_md5 ,:iso_download_instructions
-
attr_accessor :virtualbox
attr_accessor :vmfusion
attr_accessor :kvm
attr_accessor :add_shares
attr_accessor :vmdk_file
@@ -48,57 +47,57 @@
@_ui = @env.ui.dup
@_ui.resource = @name
@_ui
end
- def initialize(name,path,env)
+ def initialize(name, path, env)
- @name=name
- @env=env
+ @name = name
+ @env = env
- if path.nil?
- @path=File.join(env.definition_dir,name)
+ if path.nil?
+ @path = File.join(env.definition_dir, name)
else
- @path=path
+ @path = path
end
- # Default is 1 CPU + 256 Mem of memory
- @cpu_count='1' ; @memory_size='256';
+ # Default is 1 CPU + 256 Mem of memory + 8 Mem of video memory
+ @cpu_count = '1' ; @memory_size = '256'; @video_memory_size = '8'
# Default there is no ISO file mounted
- @iso_file = nil, @iso_src = nil ; @iso_md5 = nil ; @iso_download_timeout=1000 ; @iso_download_instructions = nil
+ @iso_file = nil, @iso_src = nil ; @iso_md5 = nil ; @iso_download_timeout = 1000 ; @iso_download_instructions = nil
# Shares to add
@add_shares = []
# Default is no floppy mounted
@floppy_files = nil
# Default there are no post install files
@pre_postinstall_file = nil
- @postinstall_files=[]; @postinstall_timeout = 10000;
+ @postinstall_files = [] ; @postinstall_timeout = 10000 ;
- @iso_file=""
- @disk_size = '10240'; @disk_format = 'VDI'; @disk_variant = 'Standard'
+ @iso_file = ""
+ @disk_size = '10240' ; @disk_format = 'VDI' ; @disk_variant = 'Standard'
@use_sata = true
# :hostiocache => 'off' ,
# :os_type_id => 'Ubuntu',
# :boot_wait => "10", :boot_cmd_sequence => [ "boot"],
# :kickstart_port => "7122", :kickstart_ip => "127.0.0.1", :kickstart_timeout => 10000,#
# :ssh_login_timeout => "10000", :ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- @ssh_host_port = "2222"; @ssh_guest_port = "22"
+ @ssh_host_port = "2222" ; @ssh_guest_port = "22"
# :ssh_host_port => "2222", :ssh_guest_port => "22", :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
# :shutdown_cmd => "shutdown -h now",
# :kickstart_file => nil,
- @winrm_host_port = "5985"; @winrm_guest_port = "5985"
+ @winrm_host_port = "5985" ; @winrm_guest_port = "5985"
@winrm_login_timeout = "10000"
@boot_cmd_sequence = [] # Empty list by default
- @virtualbox={:vm_options => {}}
- @vmfusion={:vm_options => {}}
- @kvm={:vm_options => {}}
+ @virtualbox = { :vm_options => {} }
+ @vmfusion = { :vm_options => {} }
+ @kvm = { :vm_options => {} }
end
# This function takes a hash of options and injects them into the definition
@@ -109,60 +108,60 @@
end
end
# Class method to loading a definition
- def self.load(name,env)
+ def self.load(name, env)
# Construct the path to the definition
- path=File.join(env.definition_dir,name)
- definition=Veewee::Definition.new(name,path,env)
+ path = File.join(env.definition_dir, name)
+ definition = Veewee::Definition.new(name, path, env)
env.logger.info "Loading definition directory #{definition.path}"
unless definition.exists?
- raise Veewee::DefinitionNotExist,"Error: Definition #{name} does not seem to exist"
+ raise Veewee::DefinitionNotExist, "Error: Definition #{name} does not seem to exist"
end
# We create this longer name to avoid clashes
- veewee_definition=definition
+ veewee_definition = definition
if definition.exists?
- definition_file=File.join(definition.path,"definition.rb")
- content=File.read(definition_file)
+ definition_file = File.join(definition.path, "definition.rb")
+ content = File.read(definition_file)
- content.gsub!("Veewee::Session.declare","veewee_definition.declare")
- content.gsub!("Veewee::Definition.declare","veewee_definition.declare")
+ content.gsub!("Veewee::Session.declare", "veewee_definition.declare")
+ content.gsub!("Veewee::Definition.declare", "veewee_definition.declare")
env.logger.info(content)
begin
- cwd=FileUtils.pwd
+ cwd = FileUtils.pwd
env.logger.info("Entering path #{definition.path}")
FileUtils.cd(definition.path)
self.instance_eval(content)
- env.logger.info("Returning to path #{cwd}")
+ env.logger.info("Returning to path #{cwd}")
FileUtils.cd(cwd)
rescue NameError => ex
- raise Veewee::DefinitionError,"NameError reading definition from file #{definition_file} #{ex}"
+ raise Veewee::DefinitionError, "NameError reading definition from file #{definition_file} #{ex}"
rescue Exception => ex
- raise Veewee::DefinitionError,"Error in the definition from file #{definition_file}\n#{ex}"
+ raise Veewee::DefinitionError, "Error in the definition from file #{definition_file}\n#{ex}"
end
else
env.logger.fatal("#{definition_file} not found")
- raise Veewee::DefinitionNotExist,"#{definition_file} not found"
+ raise Veewee::DefinitionNotExist, "#{definition_file} not found"
end
if definition.valid?
return definition
else
env.logger.fatal("Invalid Definition")
- raise Veewee::DefinitionError,"Invalid Definition"
+ raise Veewee::DefinitionError, "Invalid Definition"
end
end
def exists?
- filename=File.join(path,"definition.rb")
+ filename = File.join(path, "definition.rb")
unless File.exists?(filename)
return false
end
return true
@@ -188,9 +187,10 @@
return true
end
private
+
def ostype_valid?
unless env.ostypes.has_key?(@os_type_id)
env.ui.info("The ostype: #{@os_type_id} is not available")
return false
else