summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-12-14 23:34:08 +0100
committerSoren Hansen <soren.hansen@rackspace.com>2010-12-14 23:34:08 +0100
commitaab6a89ba1e9ace73dcb4fa68a67957e29c47f84 (patch)
tree068d1e20a7e5207c613e3ad923edab012000acaa
parent31c1407f7fe39b5a366e75b3131769efbfb50b57 (diff)
Don't attempt to fiddle with partitions for whole-disk-images.
-rw-r--r--nova/compute/disk.py7
-rw-r--r--nova/virt/libvirt_conn.py21
2 files changed, 20 insertions, 8 deletions
diff --git a/nova/compute/disk.py b/nova/compute/disk.py
index 9ba827519..a77c30a19 100644
--- a/nova/compute/disk.py
+++ b/nova/compute/disk.py
@@ -108,6 +108,13 @@ def partition(infile, outfile, local_bytes=0, resize=True,
yield execute('parted --script %s mkpartfs primary %s %ds %ds'
% (outfile, local_type, local_first, local_last))
+@defer.inlineCallbacks
+def extend(image, size, execute):
+ file_size = os.path.getsize(image)
+ if file_size >= size:
+ return
+ yield execute('truncate -s size %s' % (image,))
+
@defer.inlineCallbacks
def inject_data(image, key=None, net=None, partition=None, execute=None):
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 5dcb05b1f..3529be333 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -421,13 +421,13 @@ class LibvirtConnection(object):
yield images.fetch(inst.image_id, basepath('disk-raw'), user,
project)
- if inst.kernel_id:
+ if inst['kernel_id']:
if not os.path.exists(basepath('kernel')):
- yield images.fetch(inst.kernel_id, basepath('kernel'),
+ yield images.fetch(inst['kernel_id'], basepath('kernel'),
user, project)
- if inst.ramdisk_id:
+ if inst['ramdisk_id']:
if not os.path.exists(basepath('ramdisk')):
- yield images.fetch(inst.ramdisk_id, basepath('ramdisk'),
+ yield images.fetch(inst['ramdisk_id'], basepath('ramdisk'),
user, project)
execute = lambda cmd, process_input = None, check_exit_code = True: \
@@ -439,7 +439,7 @@ class LibvirtConnection(object):
# partitioned disk image where the target partition is the first
# partition
target_partition = None
- if not inst.kernel_id:
+ if not inst['kernel_id']:
target_partition = "1"
key = str(inst['key_data'])
@@ -472,7 +472,7 @@ class LibvirtConnection(object):
' into image %s (%s)',
inst['name'], inst.image_id, e)
- if inst.kernel_id:
+ if inst['kernel_id']:
if os.path.exists(basepath('disk')):
yield process.simple_execute('rm -f %s' % basepath('disk'))
@@ -483,8 +483,13 @@ class LibvirtConnection(object):
resize = True
if inst['instance_type'] == 'm1.tiny' or prefix == 'rescue-':
resize = False
- yield disk.partition(basepath('disk-raw'), basepath('disk'),
- local_bytes, resize, execute=execute)
+
+ if inst['kernel_id']:
+ yield disk.partition(basepath('disk-raw'), basepath('disk'),
+ local_bytes, resize, execute=execute)
+ else:
+ os.rename(basepath('disk-raw'), basepath('disk'))
+ yield disk.extend(basepath('disk'), local_bytes, execute=execute)
if FLAGS.libvirt_type == 'uml':
yield process.simple_execute('sudo chown root %s' %