Failures in disk.py Filesystem.create()

Bug #574751 reported by Bernie Bernstein
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
VMBuilder
New
Undecided
Unassigned

Bug Description

When building a vm as a xen image (for EC2 deployment), building fails when trying to create the root filesystem:

  File "/usr/bin/vmbuilder", line 24, in <module>
    cli.main()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/contrib/cli.py", line 116, in main
    hypervisor.install_os()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/hypervisor.py", line 64, in install_os
    self.call_hooks('mount_partitions', self.chroot_dir)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/distro.py", line 66, in call_hooks
    call_hooks(self, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/util.py", line 165, in call_hooks
    getattr(context, func, log_no_such_method)(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/hypervisor.py", line 82, in mount_partitions
    fs.create()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/disk.py", line 332, in create
    if not os.path.exists(self.filename):
  File "/usr/lib/python2.6/genericpath.py", line 18, in exists
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

This seems to occur whenever a Filesystem instance is created with None as the filename (the default).

After fixing this issue with an additional check, the following exception occurs:

  File "/usr/bin/vmbuilder", line 24, in <module>
    cli.main()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/contrib/cli.py", line 116, in main
    hypervisor.install_os()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/hypervisor.py", line 64, in install_os
    self.call_hooks('mount_partitions', self.chroot_dir)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/distro.py", line 66, in call_hooks
    call_hooks(self, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/util.py", line 165, in call_hooks
    getattr(context, func, log_no_such_method)(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/VMBuilder/hypervisor.py", line 82, in mount_partitions
    fs.create()
  File "/usr/lib/python2.6/dist-packages/VMBuilder/disk.py", line 345, in create
    self.filename = '%s/%s' % (self.vm.workdir, self.filename)
AttributeError: 'Xen' object has no attribute 'workdir'

Revision history for this message
Bernie Bernstein (bernie9998) wrote :
Revision history for this message
Bernie Bernstein (bernie9998) wrote :

I have investigated further and came to the real cause of the problem. Apparently the CLI class will provide a filename when creating disks and filesystems with util.tmpfile. However, it fails to do so when allocating filesystems when preferred_storage is set to STORAGE_FS_IMAGE and when a partitiions file is provided.

As a result, when using a plugin (such as XEN) which uses STORAGE_FS_IMAGE and filesystems are specified with a partitions file rather than specifying them in the arguments, the result is a failure due to the Filesystem object being unable to create its own filename.

I have fixed this issue by creating temp files for this case in the same manner as is done for all other cases.

I would also suggest changing the Filesystem class to make filename a required parameter similar that of Disk and removing the the logic that attempts to create one if not provided, since such logic relies on a workdir attribute that does not appear to ever be set.

Revision history for this message
Bernie Bernstein (bernie9998) wrote :

As per suggestion, including a patch to remove generating filename from Filesystem and instead raise a VMBuilderException if it is not provided (similar behavior as Disk).

This patch assumes the first patch, 'Patch to prevent calling os.path.exists if the filename is None' is not applied.

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.