class Fission::Action::VM::Cloner
def rename_vm_files(from, to)
@cloner.rename_vm_files 'foo', 'bar'
Examples
to - The name of the newly cloned VM.
from - The VM name that was used as the source of the clone.
Internal: Renames the files of a newly cloned VM.
def rename_vm_files(from, to) files_to_rename(from, to).each do |file| text_to_replace = File.basename(file, File.extname(file)) if File.extname(file) == '.vmdk' if file.match /\-s\d+\.vmdk/ text_to_replace = file.partition(/\-s\d+.vmdk/).first end end unless File.exists?(File.join(@target_vm.path, file.gsub(text_to_replace, to))) FileUtils.mv File.join(@target_vm.path, file), File.join(@target_vm.path, file.gsub(text_to_replace, to)) end end end