16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/vm_shepherd/vsphere_manager.rb', line 16
def deploy(ova_path, vm_config, vsphere_config)
raise ArgumentError unless folder_name_is_valid?(vsphere_config[:folder])
ova_path = File.expand_path(ova_path.strip)
ensure_no_running_vm(vm_config)
tmp_dir = untar_vbox_ova(ova_path)
ovf_file_path = ovf_file_path_from_dir(tmp_dir)
template = deploy_ovf_template(ovf_file_path, vsphere_config)
vm = create_vm_from_template(template, vsphere_config)
reconfigure_vm(vm, vm_config)
power_on_vm(vm)
ensure
FileUtils.remove_entry_secure(ovf_file_path, force: true) unless ovf_file_path.nil?
end
|