Class: Veewee::Definition
- Inherits:
-
Object
- Object
- Veewee::Definition
- Includes:
- Provider::Core::Helper::Iso
- Defined in:
- lib/veewee/definition.rb
Instance Attribute Summary collapse
-
#add_shares ⇒ Object
Returns the value of attribute add_shares.
-
#boot_cmd_sequence ⇒ Object
Returns the value of attribute boot_cmd_sequence.
-
#boot_wait ⇒ Object
Returns the value of attribute boot_wait.
-
#cpu_count ⇒ Object
Returns the value of attribute cpu_count.
-
#disk_format ⇒ Object
Returns the value of attribute disk_format.
-
#disk_size ⇒ Object
Returns the value of attribute disk_size.
-
#disk_variant ⇒ Object
Returns the value of attribute disk_variant.
-
#env ⇒ Object
Returns the value of attribute env.
-
#floppy_files ⇒ Object
Returns the value of attribute floppy_files.
-
#hostiocache ⇒ Object
Returns the value of attribute hostiocache.
-
#iso_dowload_timeout ⇒ Object
Returns the value of attribute iso_dowload_timeout.
-
#iso_download_instructions ⇒ Object
Returns the value of attribute iso_download_instructions.
-
#iso_file ⇒ Object
Returns the value of attribute iso_file.
-
#iso_md5 ⇒ Object
Returns the value of attribute iso_md5.
-
#iso_src ⇒ Object
Returns the value of attribute iso_src.
-
#kickstart_file ⇒ Object
Returns the value of attribute kickstart_file.
-
#kickstart_ip ⇒ Object
Returns the value of attribute kickstart_ip.
-
#kickstart_port ⇒ Object
Returns the value of attribute kickstart_port.
-
#kickstart_timeout ⇒ Object
Returns the value of attribute kickstart_timeout.
-
#kvm ⇒ Object
Returns the value of attribute kvm.
-
#memory_size ⇒ Object
Returns the value of attribute memory_size.
-
#name ⇒ Object
Returns the value of attribute name.
-
#os_type_id ⇒ Object
Returns the value of attribute os_type_id.
-
#path ⇒ Object
Returns the value of attribute path.
-
#postinstall_files ⇒ Object
Returns the value of attribute postinstall_files.
-
#postinstall_timeout ⇒ Object
Returns the value of attribute postinstall_timeout.
-
#pre_postinstall_file ⇒ Object
Returns the value of attribute pre_postinstall_file.
-
#shutdown_cmd ⇒ Object
Returns the value of attribute shutdown_cmd.
-
#ssh_guest_port ⇒ Object
Returns the value of attribute ssh_guest_port.
-
#ssh_host_port ⇒ Object
Returns the value of attribute ssh_host_port.
-
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
-
#ssh_login_timeout ⇒ Object
Returns the value of attribute ssh_login_timeout.
-
#ssh_password ⇒ Object
Returns the value of attribute ssh_password.
-
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
-
#sudo_cmd ⇒ Object
Returns the value of attribute sudo_cmd.
-
#use_hw_virt_ext ⇒ Object
Returns the value of attribute use_hw_virt_ext.
-
#use_pae ⇒ Object
Returns the value of attribute use_pae.
-
#use_sata ⇒ Object
Returns the value of attribute use_sata.
-
#virtualbox ⇒ Object
Returns the value of attribute virtualbox.
-
#vmdk_file ⇒ Object
Returns the value of attribute vmdk_file.
-
#vmfusion ⇒ Object
Returns the value of attribute vmfusion.
-
#winrm_guest_port ⇒ Object
Returns the value of attribute winrm_guest_port.
-
#winrm_host_port ⇒ Object
Returns the value of attribute winrm_host_port.
-
#winrm_login_timeout ⇒ Object
Returns the value of attribute winrm_login_timeout.
-
#winrm_password ⇒ Object
Returns the value of attribute winrm_password.
-
#winrm_user ⇒ Object
Returns the value of attribute winrm_user.
Class Method Summary collapse
-
.load(name, env) ⇒ Object
Class method to loading a definition.
Instance Method Summary collapse
-
#declare(options) ⇒ Object
This function takes a hash of options and injects them into the definition.
- #exists? ⇒ Boolean
-
#initialize(name, path, env) ⇒ Definition
constructor
A new instance of Definition.
- #ui ⇒ Object
- #valid? ⇒ Boolean
Methods included from Provider::Core::Helper::Iso
#download_iso, #download_progress, #hashsum, #verify_iso, #verify_md5sum
Constructor Details
#initialize(name, path, env) ⇒ Definition
Returns a new instance of Definition.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/veewee/definition.rb', line 53 def initialize(name,path,env) @name=name @env=env if path.nil? @path=File.join(env.definition_dir,name) else @path=path end # Default is 1 CPU + 256 Mem of memory @cpu_count='1' ; @memory_size='256'; # Default there is no ISO file mounted @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; @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", :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_login_timeout = "10000" @boot_cmd_sequence = [] # Empty list by default @virtualbox={:vm_options => {}} @vmfusion={:vm_options => {}} @kvm={:vm_options => {}} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object (private)
202 203 204 |
# File 'lib/veewee/definition.rb', line 202 def method_missing(m, *args, &block) env.logger.info "There's no attribute #{m} defined for definition #{@name}-- ignoring it" end |
Instance Attribute Details
#add_shares ⇒ Object
Returns the value of attribute add_shares.
43 44 45 |
# File 'lib/veewee/definition.rb', line 43 def add_shares @add_shares end |
#boot_cmd_sequence ⇒ Object
Returns the value of attribute boot_cmd_sequence.
18 19 20 |
# File 'lib/veewee/definition.rb', line 18 def boot_cmd_sequence @boot_cmd_sequence end |
#boot_wait ⇒ Object
Returns the value of attribute boot_wait.
18 19 20 |
# File 'lib/veewee/definition.rb', line 18 def boot_wait @boot_wait end |
#cpu_count ⇒ Object
Returns the value of attribute cpu_count.
13 14 15 |
# File 'lib/veewee/definition.rb', line 13 def cpu_count @cpu_count end |
#disk_format ⇒ Object
Returns the value of attribute disk_format.
14 15 16 |
# File 'lib/veewee/definition.rb', line 14 def disk_format @disk_format end |
#disk_size ⇒ Object
Returns the value of attribute disk_size.
14 15 16 |
# File 'lib/veewee/definition.rb', line 14 def disk_size @disk_size end |
#disk_variant ⇒ Object
Returns the value of attribute disk_variant.
14 15 16 |
# File 'lib/veewee/definition.rb', line 14 def disk_variant @disk_variant end |
#env ⇒ Object
Returns the value of attribute env.
10 11 12 |
# File 'lib/veewee/definition.rb', line 10 def env @env end |
#floppy_files ⇒ Object
Returns the value of attribute floppy_files.
33 34 35 |
# File 'lib/veewee/definition.rb', line 33 def floppy_files @floppy_files end |
#hostiocache ⇒ Object
Returns the value of attribute hostiocache.
36 37 38 |
# File 'lib/veewee/definition.rb', line 36 def hostiocache @hostiocache end |
#iso_dowload_timeout ⇒ Object
Returns the value of attribute iso_dowload_timeout.
38 39 40 |
# File 'lib/veewee/definition.rb', line 38 def iso_dowload_timeout @iso_dowload_timeout end |
#iso_download_instructions ⇒ Object
Returns the value of attribute iso_download_instructions.
38 39 40 |
# File 'lib/veewee/definition.rb', line 38 def iso_download_instructions @iso_download_instructions end |
#iso_file ⇒ Object
Returns the value of attribute iso_file.
13 14 15 |
# File 'lib/veewee/definition.rb', line 13 def iso_file @iso_file end |
#iso_md5 ⇒ Object
Returns the value of attribute iso_md5.
38 39 40 |
# File 'lib/veewee/definition.rb', line 38 def iso_md5 @iso_md5 end |
#iso_src ⇒ Object
Returns the value of attribute iso_src.
38 39 40 |
# File 'lib/veewee/definition.rb', line 38 def iso_src @iso_src end |
#kickstart_file ⇒ Object
Returns the value of attribute kickstart_file.
20 21 22 |
# File 'lib/veewee/definition.rb', line 20 def kickstart_file @kickstart_file end |
#kickstart_ip ⇒ Object
Returns the value of attribute kickstart_ip.
20 21 22 |
# File 'lib/veewee/definition.rb', line 20 def kickstart_ip @kickstart_ip end |
#kickstart_port ⇒ Object
Returns the value of attribute kickstart_port.
20 21 22 |
# File 'lib/veewee/definition.rb', line 20 def kickstart_port @kickstart_port end |
#kickstart_timeout ⇒ Object
Returns the value of attribute kickstart_timeout.
20 21 22 |
# File 'lib/veewee/definition.rb', line 20 def kickstart_timeout @kickstart_timeout end |
#kvm ⇒ Object
Returns the value of attribute kvm.
42 43 44 |
# File 'lib/veewee/definition.rb', line 42 def kvm @kvm end |
#memory_size ⇒ Object
Returns the value of attribute memory_size.
13 14 15 |
# File 'lib/veewee/definition.rb', line 13 def memory_size @memory_size end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/veewee/definition.rb', line 9 def name @name end |
#os_type_id ⇒ Object
Returns the value of attribute os_type_id.
16 17 18 |
# File 'lib/veewee/definition.rb', line 16 def os_type_id @os_type_id end |
#path ⇒ Object
Returns the value of attribute path.
11 12 13 |
# File 'lib/veewee/definition.rb', line 11 def path @path end |
#postinstall_files ⇒ Object
Returns the value of attribute postinstall_files.
31 32 33 |
# File 'lib/veewee/definition.rb', line 31 def postinstall_files @postinstall_files end |
#postinstall_timeout ⇒ Object
Returns the value of attribute postinstall_timeout.
31 32 33 |
# File 'lib/veewee/definition.rb', line 31 def postinstall_timeout @postinstall_timeout end |
#pre_postinstall_file ⇒ Object
Returns the value of attribute pre_postinstall_file.
29 30 31 |
# File 'lib/veewee/definition.rb', line 29 def pre_postinstall_file @pre_postinstall_file end |
#shutdown_cmd ⇒ Object
Returns the value of attribute shutdown_cmd.
27 28 29 |
# File 'lib/veewee/definition.rb', line 27 def shutdown_cmd @shutdown_cmd end |
#ssh_guest_port ⇒ Object
Returns the value of attribute ssh_guest_port.
22 23 24 |
# File 'lib/veewee/definition.rb', line 22 def ssh_guest_port @ssh_guest_port end |
#ssh_host_port ⇒ Object
Returns the value of attribute ssh_host_port.
22 23 24 |
# File 'lib/veewee/definition.rb', line 22 def ssh_host_port @ssh_host_port end |
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
22 23 24 |
# File 'lib/veewee/definition.rb', line 22 def ssh_key @ssh_key end |
#ssh_login_timeout ⇒ Object
Returns the value of attribute ssh_login_timeout.
22 23 24 |
# File 'lib/veewee/definition.rb', line 22 def ssh_login_timeout @ssh_login_timeout end |
#ssh_password ⇒ Object
Returns the value of attribute ssh_password.
22 23 24 |
# File 'lib/veewee/definition.rb', line 22 def ssh_password @ssh_password end |
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
22 23 24 |
# File 'lib/veewee/definition.rb', line 22 def ssh_user @ssh_user end |
#sudo_cmd ⇒ Object
Returns the value of attribute sudo_cmd.
26 27 28 |
# File 'lib/veewee/definition.rb', line 26 def sudo_cmd @sudo_cmd end |
#use_hw_virt_ext ⇒ Object
Returns the value of attribute use_hw_virt_ext.
36 37 38 |
# File 'lib/veewee/definition.rb', line 36 def use_hw_virt_ext @use_hw_virt_ext end |
#use_pae ⇒ Object
Returns the value of attribute use_pae.
36 37 38 |
# File 'lib/veewee/definition.rb', line 36 def use_pae @use_pae end |
#use_sata ⇒ Object
Returns the value of attribute use_sata.
36 37 38 |
# File 'lib/veewee/definition.rb', line 36 def use_sata @use_sata end |
#virtualbox ⇒ Object
Returns the value of attribute virtualbox.
40 41 42 |
# File 'lib/veewee/definition.rb', line 40 def virtualbox @virtualbox end |
#vmdk_file ⇒ Object
Returns the value of attribute vmdk_file.
44 45 46 |
# File 'lib/veewee/definition.rb', line 44 def vmdk_file @vmdk_file end |
#vmfusion ⇒ Object
Returns the value of attribute vmfusion.
41 42 43 |
# File 'lib/veewee/definition.rb', line 41 def vmfusion @vmfusion end |
#winrm_guest_port ⇒ Object
Returns the value of attribute winrm_guest_port.
24 25 26 |
# File 'lib/veewee/definition.rb', line 24 def winrm_guest_port @winrm_guest_port end |
#winrm_host_port ⇒ Object
Returns the value of attribute winrm_host_port.
24 25 26 |
# File 'lib/veewee/definition.rb', line 24 def winrm_host_port @winrm_host_port end |
#winrm_login_timeout ⇒ Object
Returns the value of attribute winrm_login_timeout.
24 25 26 |
# File 'lib/veewee/definition.rb', line 24 def winrm_login_timeout @winrm_login_timeout end |
#winrm_password ⇒ Object
Returns the value of attribute winrm_password.
24 25 26 |
# File 'lib/veewee/definition.rb', line 24 def winrm_password @winrm_password end |
#winrm_user ⇒ Object
Returns the value of attribute winrm_user.
24 25 26 |
# File 'lib/veewee/definition.rb', line 24 def winrm_user @winrm_user end |
Class Method Details
.load(name, env) ⇒ Object
Class method to loading a definition
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/veewee/definition.rb', line 114 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) env.logger.info "Loading definition directory #{definition.path}" unless definition.exists? raise Veewee::DefinitionNotExist,"Error: Definition #{name} does not seem to exist" end # We create this longer name to avoid clashes veewee_definition=definition if definition.exists? 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") env.logger.info(content) begin 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}") FileUtils.cd(cwd) rescue NameError => 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}" end else env.logger.fatal("#{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" end end |
Instance Method Details
#declare(options) ⇒ Object
This function takes a hash of options and injects them into the definition
105 106 107 108 109 110 111 |
# File 'lib/veewee/definition.rb', line 105 def declare() .each do |key, value| instance_variable_set("@#{key}".to_sym, [key]) env.logger.info("definition") { " - #{key} : #{[key]}" } end end |
#exists? ⇒ Boolean
162 163 164 165 166 167 168 169 |
# File 'lib/veewee/definition.rb', line 162 def exists? filename=File.join(path,"definition.rb") unless File.exists?(filename) return false end return true end |
#ui ⇒ Object
46 47 48 49 50 51 |
# File 'lib/veewee/definition.rb', line 46 def ui return @_ui if defined?(@_ui) @_ui = @env.ui.dup @_ui.resource = @name @_ui end |
#valid? ⇒ Boolean
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/veewee/definition.rb', line 171 def valid? # Check if the definition exists? unless exists? return false end # Check ostype to be valid unless ostype_valid? return false end # Postinstall files require a valid user and password unless self.postinstall_files.nil? if (self.ssh_user.nil? || self.ssh_password.nil?) && (self.winrm_user.nil? || self.winrm_password.nil?) return false end end return true end |