So I stepped through the code where you have --use-template NAME option
option :use_template,
:long => "--use-template NAME",
:description => "Try to use an existing template instead of importing disk",
:default => nil
if config[:use_template]
ui.info "Using template #{config[:use_template]}"
if connection.template_exist?(config[:use_template])
puts "#{ui.color("Cloning template...",:magenta)}"
connection.copy_from_template config[:use_template], destination_path + "/#{vm_name}.vmdk"
else
ui.error "Template #{config[:use_template]} not found"
exit 1
end
else
puts "#{ui.color("Importing VM disk... ", :magenta)}"
connection.import_disk vm_disk, destination_path + "/#{vm_name}.vmdk"
end
is the Name supposed to be the name of the template or template name with .vmdk
for example my template name is server1 - but unless I put server1.vmdk the following code below from the ESX gem will always evaluate to false. Just wanted to confirm with this. Maybe when you specify --use-template you should provide some instructions since it's misleading to use just the name when it should really be --use-template VMDKFile
This code is from the esx gem
def template_exist?(vmdk_file)
template_file = File.join(@templates_dir, File.basename(vmdk_file))
Log.debug "Checking if template #{template_file} exists"
Net::SSH.start(@address, @user, :password => @password) do |ssh|
return false if (ssh.exec! "ls -la #{@templates_dir} 2>/dev/null").nil?
return false if (ssh.exec! "ls #{template_file} 2>/dev/null").nil?
end
Log.debug "Template #{template_file} found"
true
end
So I stepped through the code where you have --use-template NAME option
option :use_template, :long => "--use-template NAME", :description => "Try to use an existing template instead of importing disk", :default => nil
if config[:use_template] ui.info "Using template #{config[:use_template]}" if connection.template_exist?(config[:use_template]) puts "#{ui.color("Cloning template...",:magenta)}" connection.copy_from_template config[:use_template], destination_path + "/#{vm_name}.vmdk" else ui.error "Template #{config[:use_template]} not found" exit 1 end else puts "#{ui.color("Importing VM disk... ", :magenta)}" connection.import_disk vm_disk, destination_path + "/#{vm_name}.vmdk" end
is the Name supposed to be the name of the template or template name with .vmdk
for example my template name is server1 - but unless I put server1.vmdk the following code below from the ESX gem will always evaluate to false. Just wanted to confirm with this. Maybe when you specify --use-template you should provide some instructions since it's misleading to use just the name when it should really be --use-template VMDKFile
This code is from the esx gem
def template_exist?(vmdk_file) template_file = File.join(@templates_dir, File.basename(vmdk_file)) Log.debug "Checking if template #{template_file} exists" Net::SSH.start(@address, @user, :password => @password) do |ssh| return false if (ssh.exec! "ls -la #{@templates_dir} 2>/dev/null").nil? return false if (ssh.exec! "ls #{template_file} 2>/dev/null").nil? end Log.debug "Template #{template_file} found" true end