Getting error when importing template

Hi all,

Hopefully you can help me out with this issue, because I can’t seem to figure out why this error is occurring. For many months we have been running our infrastructure without issue and recently we needed to import new VM templates to this particular site. When running the import command we get the following error:

 [oneadmin@euopennebula ~]$ onevcenter templates --vcenter euvcenter65 --vuser administrator@vsphere.local --vpass "blah"

 Connecting to vCenter: euvcenter65...done!

 Looking for VM Templates...done!

 Do you want to process datacenter EU (y/[n])? y

   * VM Template found:
       - Name       : testvmtemplate
       - Cluster    : EU1
       - Location   : /
     Import this VM template (y/[n])? y

     For faster deployment operations and lower disk usage, OpenNebula can create new VMs as linked clones.
     Would you like to use Linked Clones with VMs based on this template (y/[n])? 


     Do you want to specify a folder where the deployed VMs based on this template will appear in vSphere's VM and Templates section?
     If no path is set, VMs will be placed in the same location where the template lives.
     Please specify a path using slashes to separate folders e.g /Management/VMs or press Enter to use defaults: 

     The existing disks and networks in the template are being imported, please be patient...
 There was an error trying to import a vcenter template: undefined method `close' for nil:NilClass/
 ["/usr/lib/one/ruby/vcenter_driver/virtual_machine.rb:70:in `unlock'", "/usr/lib/one/ruby/vcenter_driver/virtual_machine.rb:333:in `import_vcenter_disks'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:432:in `block (2 levels) in import_templates'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:299:in `each'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:299:in `block in import_templates'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:287:in `each'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:287:in `import_templates'", "/bin/onevcenter:128:in `block (2 levels) in <main>'", "/usr/lib/one/ruby/cli/command_parser.rb:449:in `call'", "/usr/lib/one/ruby/cli/command_parser.rb:449:in `run'", "/usr/lib/one/ruby/cli/command_parser.rb:76:in `initialize'", "/bin/onevcenter:57:in `new'", "/bin/onevcenter:57:in `<main>'"]
 [oneadmin@euopennebula ~]$

Versions of the related components and OS (frontend, hypervisors, VMs):
We are running
vCenter 6.5
Opennebula 5.4.3
Steps to reproduce:
Log in through the command line. Have a template ready to import from vCenter. Run the command onevcenter templates to try to import templates from vCenter
Select whatever new template you want to import.
Select the default values provided to you on each question.

Current results:
There was an error trying to import a vcenter template: undefined method close' for nil:NilClass/ ["/usr/lib/one/ruby/vcenter_driver/virtual_machine.rb:70:inunlock’", “/usr/lib/one/ruby/vcenter_driver/virtual_machine.rb:333:in import_vcenter_disks'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:432:inblock (2 levels) in import_templates’”, “/usr/lib/one/ruby/vcenter_driver/importer.rb:299:in each'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:299:inblock in import_templates’”, “/usr/lib/one/ruby/vcenter_driver/importer.rb:287:in each'", "/usr/lib/one/ruby/vcenter_driver/importer.rb:287:inimport_templates’”, “/bin/onevcenter:128:in block (2 levels) in <main>'", "/usr/lib/one/ruby/cli/command_parser.rb:449:incall’”, “/usr/lib/one/ruby/cli/command_parser.rb:449:in run'", "/usr/lib/one/ruby/cli/command_parser.rb:76:ininitialize’”, “/bin/onevcenter:57:in new'", "/bin/onevcenter:57:in'”]

Expected results:
Expected results should be that the shouldn’t get an error on import and that the import will complete successfully.

Thanks and appreciate the help in advance.
Jesus

Well came to find out that this issue was created by other admins doing imports into Opennebula so I hope this helps someone when trying to figure out what the hell is going on when they try to import a template into Opennebula and it fails with the error above.

The issue stems from a lock file created by the import process in Opennebula on the /tmp directory with the following name:

/tmp/vcenter-importer-lock

If this file is owned by a different user, other than oneadmin and you try to import a template via the oneadmin user, either via SunStone, or the CLI, you will receive the above error. To fix the issue, log in as root to the Opennebula server and delete this file then try your import again. It should work as expected.

I downloaded and installed a template following the documentation provided, but when it came to import demo data with the provided xml through the Wordpress importer, Wordpress gets stuck loading and doesn’t import anything. The xml then appears in the media library, but no new posts or images appear.