vmbuilder for vmserver fails with vmxtemplate undefined

Bug #341596 reported by spiceisland
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ubuntu-vm-builder (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: ubuntu-vm-builder

This is under Jaunty alpha 5(ish).

Having followed the instructions on https://help.ubuntu.com/8.10/serverguide/C/jeos-and-vmbuilder.html, I managed to install ubuntu-vm-builder and get apt-proxy installed and running in order to create a kvm-based ubuntu-hardy image thus:

vmbuilder kvm ubuntu --suite hardy --flavour virtual --arch i386 -o --mirror http://localhost:9999/ubuntu --addpkg acpid

The resulting image boots quite happily under kvm.

I then decided to re-run the command to produce a VMWare Server equivalent:

vmbuilder vmserver ubuntu --suite hardy --flavour virtual --arch i386 -o --mirror http://localhost:9999/ubuntu --addpkg acpid

This NEARLY works, but dies at the last moment:

...
2009-03-12 08:43:47,352 INFO Copying to disk images
2009-03-12 08:44:21,273 INFO Installing bootloader
2009-03-12 08:44:24,119 INFO Unmounting target filesystem
2009-03-12 08:44:24,414 INFO Converting /tmp/vmbuilderB4UNWR/disk0.img to vmdk, format ubuntu-vmserver/disk0.vmdk
2009-03-12 08:44:55,874 INFO Cleaning up
Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 29, in <module>
    VMBuilder.run()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/__init__.py", line 66, in run
    frontend.run()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/cli/__init__.py", line 67, in run
    vm.create()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/vm.py", line 463, in create
    self.deploy()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/vm.py", line 184, in deploy
    getattr(self.hypervisor, 'deploy')()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/vmware/vm.py", line 46, in deploy
    vmdesc = VMBuilder.util.render_template('vmware', self.vm, vmxtemplate, { 'disks' : self.disks(), 'vmhwversion' : self.vmhwversion, 'cpu' : self.vm.cpu, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') })
NameError: global name 'vmxtemplate' is not defined

I shall attach the output of re-running the command with the --debug option ...

root@graham-desktop:~# lsb_release -rd
Description: Ubuntu jaunty (development branch)
Release: 9.04

root@graham-desktop:~# apt-cache policy ubuntu-vm-builder
ubuntu-vm-builder:
  Installed: 0.10-0ubuntu1
  Candidate: 0.10-0ubuntu1
  Version table:
 *** 0.10-0ubuntu1 0
        500 http://gb.archive.ubuntu.com jaunty/universe Packages
        100 /var/lib/dpkg/status

Revision history for this message
spiceisland (graham-hudspith) wrote :
description: updated
Revision history for this message
spiceisland (graham-hudspith) wrote :

I've created an apport-generated duplicate of this bug report over at https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/359473.

This problem still occurs with the 0.10-0ubuntu2 release of ubuntu-vm-builder.

Revision history for this message
Mekk (marcin-kasperski) wrote :

Faced the same problem on 9.10:

$ sudo vmbuilder \
        vmserver \
        ubuntu \
        --suite hardy \
        --dest image \
        --components 'main,universe' \
        --arch 'i386' \
        --rootsize '4096' \
        --swapsize '512' \
        # user and network options, which I prefer to skip
        --addpkg openssh-server \
        --addpkg nginx

Effect:

(... long trace of running builder ...)

2009-05-04 18:39:08,752 INFO Copying to disk images
2009-05-04 18:39:35,009 INFO Installing bootloader
2009-05-04 18:39:39,481 INFO Unmounting target filesystem
2009-05-04 18:39:42,657 INFO Converting /home/marcin/tmp/vmbuilderKLpQhq/disk0.img to vmdk, format /home/marcin/image/disk0.vmdk
2009-05-04 18:40:30,012 INFO Cleaning up
Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 29, in <module>
    VMBuilder.run()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/__init__.py", line 66, in run
    frontend.run()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/cli/__init__.py", line 67, in run
    vm.create()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/vm.py", line 463, in create
    self.deploy()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/vm.py", line 184, in deploy
    getattr(self.hypervisor, 'deploy')()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/vmware/vm.py", line 46, in deploy
    vmdesc = VMBuilder.util.render_template('vmware', self.vm, vmxtemplate, { 'disks' : self.disks(), 'vmhwversion' : self.vmhwversion, 'cpu' : self.vm.cpu, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') })
NameError: global name 'vmxtemplate' is not defined

Revision history for this message
Mekk (marcin-kasperski) wrote :

My very strong bet is that one should add

   self.

before vmxtemplate - so it reads:

       vmdesc = VMBuilder.util.render_template('vmware', self.vm, self.vmxtemplate, { 'disks' : self.disks(), 'vmhwversion' : self.vmhwversion, 'cpu' : self.vm.cpu, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') })

PS Obviously the problem is only related to VmWare images (as it is present in class VMWare)

Revision history for this message
Mekk (marcin-kasperski) wrote :

With the fix above builder progresses further and faces the next problem:

  File "/usr/lib/python2.6/dist-packages/VMBuilder/plugins/vmware/vm.py", line 46, in deploy
    vmdesc = VMBuilder.util.render_template('vmware', self.vm, self.vmxtemplate, { 'disks' : self.disks(), 'vmhwversion' : self.vmhwversion, 'cpu' : self.vm.cpu, 'mem' : self.vm.mem, 'hostname' : self.vm.hostname, 'arch' : self.vm.arch, 'guestos' : (self.vm.arch == 'amd64' and 'ubuntu-64' or 'ubuntu') })
AttributeError: 'VM' object has no attribute 'cpu'

I am just to try replacing

    self.vm.cpu

with

    self.vm.cpus

(as is in KVM version)

Revision history for this message
Mekk (marcin-kasperski) wrote :

.. and the latter seems to help.

So, to summarize:

1) There is a bug in ubuntu-vm-builder 0.10-0ubuntu2 (current Jaunty version) which makes it fail during image conversion when vmserver image is generated

2) To fix the bug, two trivial edits in VMBuilder/plugins/vmware/vm.py are needed:

- replace self.vm.cpu with self.vm.cpus
- replace vmxtemplate with self.vmxtemplate

(both fixes in deploy method of VMWare class, line 38 of vm.py)

Revision history for this message
austin (bang-a-rang) wrote :

Thanks Mekk,

Making those 2 changes fixed this issue for me. I am using xubuntu 9.04.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.