diff options
| author | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-10-20 02:49:28 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-10-20 02:49:28 +0000 |
| commit | 9145feeed99b02a2798fde909a2abe8d900b522c (patch) | |
| tree | 0de90bf3de670dc5c84ee13beb663fb2e17a872e /nova/compute | |
| parent | 38dd6ffabaaf6130b7f810f4cbf45d1cd5202205 (diff) | |
| parent | 03a74592ed2dba8d82432fb7eaa76c9dce2351c8 (diff) | |
Makes disk.partition resize root drive to 10G, unless it is m1.tiny which just leaves it as is. Larger images are just used as is.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/disk.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/nova/compute/disk.py b/nova/compute/disk.py index c340c5a79..447a29004 100644 --- a/nova/compute/disk.py +++ b/nova/compute/disk.py @@ -28,10 +28,17 @@ import tempfile from twisted.internet import defer from nova import exception +from nova import flags + + +FLAGS = flags.FLAGS +flags.DEFINE_integer('minimum_root_size', 1024 * 1024 * 1024 * 10, + 'minimum size in bytes of root partition') @defer.inlineCallbacks -def partition(infile, outfile, local_bytes=0, local_type='ext2', execute=None): +def partition(infile, outfile, local_bytes=0, resize=True, + local_type='ext2', execute=None): """Takes a single partition represented by infile and writes a bootable drive image into outfile. @@ -49,7 +56,14 @@ def partition(infile, outfile, local_bytes=0, local_type='ext2', execute=None): """ sector_size = 512 file_size = os.path.getsize(infile) - if file_size % sector_size != 0: + if resize and file_size < FLAGS.minimum_root_size: + last_sector = FLAGS.minimum_root_size / sector_size - 1 + yield execute('dd if=/dev/zero of=%s count=1 seek=%d bs=%d' + % (infile, last_sector, sector_size)) + yield execute('e2fsck -fp %s' % infile, check_exit_code=False) + yield execute('resize2fs %s' % infile) + file_size = FLAGS.minimum_root_size + elif file_size % sector_size != 0: logging.warn("Input partition size not evenly divisible by" " sector size: %d / %d", file_size, sector_size) primary_sectors = file_size / sector_size |
