optparser attribute missing in cli.py (warning-message-printing fail when --part is given a nonexistent file)

Bug #612082 reported by Ben Davidson
30
This bug affects 5 people
Affects Status Importance Assigned to Milestone
VMBuilder
New
Undecided
Unassigned
vm-builder (Ubuntu)
Fix Released
Medium
Daniel Holbert

Bug Description

Running vmbuilder (python-vm-builder v0.12.3-0ubuntu1) in Lucid I get the following output resulting in an Attribute error

administrator@server-base:/vm/server$ sudo vmbuilder kvm ubuntu --arch=i386 --suite=lucid --flavour=virtual --libvirt=qemu:///system ip=192.168.2.101 --part=vmbuilder.partition --templates=mytemplates --user=administrator --name=Administrator pass=password --addpkg openssh-server --mem=512 hostname=server --bridge=br0
2010-07-31 16:49:28,283 INFO : Calling hook: preflight_check
2010-07-31 16:49:28,286 INFO : Calling hook: set_defaults
2010-07-31 16:49:28,287 INFO : Calling hook: bootstrap
2010-07-31 16:54:13,482 INFO : Calling hook: configure_os
2010-07-31 16:54:34,376 INFO : update-alternatives: error: no alternatives for rsh.
2010-07-31 16:54:34,461 INFO : update-alternatives: error: no alternatives for rlogin.
2010-07-31 16:54:34,547 INFO : update-alternatives: error: no alternatives for rcp.
2010-07-31 16:54:35,324 INFO : Creating SSH2 RSA key; this may take some time ...
2010-07-31 16:54:36,286 INFO : Creating SSH2 DSA key; this may take some time ...
2010-07-31 16:54:36,403 INFO :
2010-07-31 16:54:36,403 INFO : Warning: Fake initctl called, doing nothing
2010-07-31 16:54:36,404 INFO :
2010-07-31 16:54:36,405 INFO : Warning: Fake initctl called, doing nothing
2010-07-31 16:54:37,808 INFO :
2010-07-31 16:54:37,808 INFO : Current default time zone: 'Etc/UTC'
2010-07-31 16:54:37,811 INFO : Local time is now: Sat Jul 31 15:54:37 UTC 2010.
2010-07-31 16:54:37,812 INFO : Universal Time is now: Sat Jul 31 15:54:37 UTC 2010.
2010-07-31 16:54:37,812 INFO :
2010-07-31 16:55:07,479 INFO :
2010-07-31 16:55:07,479 INFO : Current default time zone: 'Etc/UTC'
2010-07-31 16:55:07,482 INFO : Local time is now: Sat Jul 31 15:55:07 UTC 2010.
2010-07-31 16:55:07,482 INFO : Universal Time is now: Sat Jul 31 15:55:07 UTC 2010.
2010-07-31 16:55:07,482 INFO : Run 'dpkg-reconfigure tzdata' if you wish to change it.
2010-07-31 16:55:07,483 INFO :
2010-07-31 16:55:12,919 INFO : Calling hook: post_install
Traceback (most recent call last):
  File "/usr/bin/vmbuilder", line 24, in <module>
    cli.main()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/contrib/cli.py", line 115, in main
    self.set_disk_layout(hypervisor)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/contrib/cli.py", line 250, in set_disk_layout
    hypervisor.optparser.error("%s parsing --part option: %s" % (errno, strerror))
AttributeError: 'KVM' object has no attribute 'optparser'

Tags: patch

Related branches

Mathias Gug (mathiaz)
Changed in vm-builder (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Daniel Holbert (dholbert) wrote :

I had this exact problem, and I just figured out what was going wrong.

It turned out to be that I'd passed a nonexistent file to "--part" in my vmbuilder command. (In the bug-reporter's case -- I'm not sure whether --part accepts relative paths or not, but if you're sure that vmbuilder.partition exists, you might try specifying the *full path* to that file.)

So as I understand it, this problem arises from user error in specifying the "--part" argument. HOWEVER -- there is still a bug here -- the vmbuilder script tries to be helpful with a warning message, but it ends up falling over and dying because it tries to print the message via a nonexistent attribute. So instead of a warning message, the user gets a cryptic exception backtrace.

summary: - optparser attribute missing in cli.py
+ optparser attribute missing in cli.py (warning-message-printing fail
+ when --part is given a nonexistent file)
Revision history for this message
Daniel Holbert (dholbert) wrote :

> hypervisor.optparser.error("%s parsing --part option: %s" % (errno, strerror))

My python-fu is not strong, but from looking at the rest of the cli.py file, I think we want "self.optparser", not "hypervisor.optparser".

Testing that to see if that fixes it locally...

Revision history for this message
Daniel Holbert (dholbert) wrote :

self.optparser didn't work -- tried that because there was one other usage of that in the file, but it gives me
>AttributeError: 'CLI' object has no attribute 'optparser
So the existing "self.optparser" line is probably just as busted as this bug's "hypervisor.optparser" line. :)

Trying just plain "optparser" now, since that's used many more times elsewhere in the file...

Revision history for this message
Daniel Holbert (dholbert) wrote :

that didn't work -- reading the file slightly more intelligently, I see that "optparser" is a local variable initialized in "main" and passed to its helper functions. It's not passed to set_disk_layout, though (but it should be).

Revision history for this message
Daniel Holbert (dholbert) wrote :

Here's the patch as described above. Just passes the "optparser" variable to set_disk_layout, and uses it to print the error instead of using the nonexistent "self.optparser" & "hypervisor.optparser".

I've confirmed that this works locally (i.e. it makes vmbuilder print the warning message instead of throwing an exception).

Changed in vm-builder (Ubuntu):
assignee: nobody → Daniel Holbert (dholbert)
Revision history for this message
Daniel Holbert (dholbert) wrote :

Assigning bug to me, since I've attached a fix.

I'm not sure who to ask for code-review from (if needed) or how to get the patch committed, though -- Soren, could you perhaps help with either of those?

tags: added: patch
Dave Walker (davewalker)
Changed in vm-builder (Ubuntu):
status: New → Triaged
Revision history for this message
Barry Warsaw (barry) wrote :

Daniel, thanks very much for your contribution to Ubuntu.

I am unable to reproduce this bug because for some reason vm-builder just hangs for me on both Lucid and Precise. However, from visual inspection, I think your patch is spot on. Note however that it does not apply cleanly to Precise.

See lp:~barry/ubuntu/precise/vm-builder/bug-612082 for a branch that resolves the conflicts, and which I propose to upload to Precise. Once the patch lands there, we can prepare an SRU for Lucid, and I am happy to help with that if you'd like. I will also link a bug task with upstream so that they can apply the fix there too.

Revision history for this message
Barry Warsaw (barry) wrote :

I've also uploaded the Precise package to my PPA, which you can enable with:

$ sudo add-apt-repostory ppa:barry/python

Revision history for this message
Barry Warsaw (barry) wrote :
Revision history for this message
Barry Warsaw (barry) wrote :

On further reflection, I think the patch is safe to upload to Precise, and I will do this. I'm not entirely convinced the bug meets the SRU guidelines for Lucid

https://wiki.ubuntu.com/StableReleaseUpdates

so I won't prepare an SRU for it. I have however uploaded vm-builder_0.12.4-0ubuntu0.3~ppa0 to my PPA so you should be able to grab it from there and at least test it to make sure it fixes your problem. If you think an SRU is warranted, please review the guidelines above and file a separate bug for that.

Thanks again for your contribution to Ubuntu!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package vm-builder - 0.12.4+bzr471-0ubuntu2

---------------
vm-builder (0.12.4+bzr471-0ubuntu2) precise; urgency=low

  [ Daniel Holbert ]
  * Fix warning messages when --part is given a nonexistent file.
    (LP: #612082)
 -- Barry Warsaw <email address hidden> Thu, 27 Oct 2011 15:52:56 -0400

Changed in vm-builder (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Daniel Holbert (dholbert) wrote :

Thanks!

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.