Merge "remove auto fsck feature from file injection. Bug 826794"

This commit is contained in:
Jenkins 2012-02-02 22:58:23 +00:00 committed by Gerrit Code Review
commit 4982ea11d8
3 changed files with 7 additions and 28 deletions

View File

@ -109,12 +109,10 @@ def extend(image, size):
class _DiskImage(object):
"""Provide operations on a disk image file."""
def __init__(self, image, partition=None, use_cow=False,
disable_auto_fsck=False, mount_dir=None):
def __init__(self, image, partition=None, use_cow=False, mount_dir=None):
# These passed to each mounter
self.image = image
self.partition = partition
self.disable_auto_fsck = disable_auto_fsck
self.mount_dir = mount_dir
# Internal
@ -164,7 +162,6 @@ class _DiskImage(object):
mounter_cls = self._handler_class(h)
mounter = mounter_cls(image=self.image,
partition=self.partition,
disable_auto_fsck=self.disable_auto_fsck,
mount_dir=self.mount_dir)
if mounter.do_mount():
self._mounter = mounter
@ -191,7 +188,7 @@ class _DiskImage(object):
# Public module functions
def inject_data(image, key=None, net=None, metadata=None,
partition=None, use_cow=False, disable_auto_fsck=True):
partition=None, use_cow=False):
"""Injects a ssh key and optionally net data into a disk image.
it will mount the image as a fully partitioned disk and attempt to inject
@ -200,8 +197,7 @@ def inject_data(image, key=None, net=None, metadata=None,
If partition is not specified it mounts the image as a single partition.
"""
img = _DiskImage(image=image, partition=partition, use_cow=use_cow,
disable_auto_fsck=disable_auto_fsck)
img = _DiskImage(image=image, partition=partition, use_cow=use_cow)
if img.mount():
try:
inject_data_into_fs(img.mount_dir, key, net, metadata,
@ -212,11 +208,9 @@ def inject_data(image, key=None, net=None, metadata=None,
raise exception.Error(img.errors)
def inject_files(image, files, partition=None, use_cow=False,
disable_auto_fsck=True):
def inject_files(image, files, partition=None, use_cow=False):
"""Injects arbitrary files into a disk image"""
img = _DiskImage(image=image, partition=partition, use_cow=use_cow,
disable_auto_fsck=disable_auto_fsck)
img = _DiskImage(image=image, partition=partition, use_cow=use_cow)
if img.mount():
try:
for (path, contents) in files:

View File

@ -30,13 +30,11 @@ class Mount(object):
to be called in that order.
"""
def __init__(self, image, mount_dir, partition=None,
disable_auto_fsck=False):
def __init__(self, image, mount_dir, partition=None):
# Input
self.image = image
self.partition = partition
self.disable_auto_fsck = disable_auto_fsck
self.mount_dir = mount_dir
# Output
@ -84,16 +82,6 @@ class Mount(object):
self.mapped_device = self.device
self.mapped = True
# This is an orthogonal operation
# which only needs to be done once
if self.disable_auto_fsck and self.mapped:
self.disable_auto_fsck = False
# attempt to set ext[234] so that it doesn't auto-fsck
_out, err = utils.trycmd('tune2fs', '-c', 0, '-i', 0,
self.mapped_device, run_as_root=True)
if err:
LOG.info(_('Failed to disable fs check: %s') % err)
return self.mapped
def unmap_dev(self):

View File

@ -1076,11 +1076,9 @@ class LibvirtConnection(driver.ComputeDriver):
if config_drive: # Should be True or None by now.
injection_path = basepath('disk.config')
img_id = 'config-drive'
disable_auto_fsck = False
else:
injection_path = basepath('disk')
img_id = inst.image_ref
disable_auto_fsck = True
for injection in ('metadata', 'key', 'net'):
if locals()[injection]:
@ -1090,8 +1088,7 @@ class LibvirtConnection(driver.ComputeDriver):
try:
disk.inject_data(injection_path, key, net, metadata,
partition=target_partition,
use_cow=FLAGS.use_cow_images,
disable_auto_fsck=disable_auto_fsck)
use_cow=FLAGS.use_cow_images)
except Exception as e:
# This could be a windows image, or a vmdk format disk