class Kitchen::Driver::Vmm
Driver
for VMM
Public Instance Methods
create(state)
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 30 def create(state) @state = state validate_vm_settings create_virtual_machine info("VM instance #{instance.to_str} created.") end
destroy(state)
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 37 def destroy(state) @state = state instance.transport.connection(state).close remove_virtual_machine info("The VM instance #{instance.to_str} has been removed.") state.delete(:id) end
Private Instance Methods
create_virtual_machine()
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 72 def create_virtual_machine return if vm_exists info("Creating virtual machine for #{instance.name}.") options = { vmm_server_address: config[:vmm_server_address], proxy_server_address: config[:proxy_server_address], vm_hardware_profile: config[:vm_hardware_profile], vm_name: "#{config[:vm_name_prefix]}#{config[:vm_name] || instance.name}", vm_template_name: config[:vm_template_name], vm_host_group_name: config[:vm_host_group_name], ad_server: config[:ad_server], ad_source_path: config[:ad_source_path], ad_target_path: config[:ad_target_path] } # info("Creating and registering VM in the VMM (#{options[:vmm_server_address]})...") if options[:proxy_server_address] info("Using proxy: #{options[:proxy_server_address]}") end if options[:ad_server] && options[:ad_source_path] && options[:ad_target_path] info(" ..and moving it under #{options[:ad_target_path]} after it's created.") end vm = execute('import_vm.ps1', options) info("Successfully created the VM with name: #{vm['name']}") @state[:id] = vm['id'] @state[:hostname] = vm['hostname'] @state[:vm_name] = vm['name'] info("Created virtual machine for #{instance.name}.") end
kitchen_vm_path()
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 53 def kitchen_vm_path @kitchen_vm_path ||= File.join(config[:kitchen_root], ".kitchen/#{instance.name}") end
remove_virtual_machine()
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 57 def remove_virtual_machine info("Deleting virtual machine for #{instance.name}") options = { vmm_server_address: config[:vmm_server_address], proxy_server_address: config[:proxy_server_address], vm_id: @state[:id] } execute('delete_vm.ps1', options) info("Deleted virtual machine for #{instance.name}") end
validate_vm_settings()
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 49 def validate_vm_settings raise "Missing vmm_server_address" unless config[:vmm_server_address] end
vm_exists()
click to toggle source
# File lib/kitchen/driver/vmm.rb, line 68 def vm_exists false end