~bgh/nova/qmanager-trunk

« back to all changes in this revision

Viewing changes to nova/virt/libvirt/connection.py

  • Committer: Tarmac
  • Author(s): Isaku Yamahata
  • Date: 2011-09-13 21:04:13 UTC
  • mfrom: (1548.1.3 my-metadata-fix-2)
  • Revision ID: tarmac-20110913210413-cs8zyl7xdwk16mhg
This patch teaches virt/libvirt how to format filesystem on ephemeral device depending on os_type so that the behaviour matches with EC2's.
Such behaviour isn't explicitly described in the documentation, but it is confirmed by checking realy EC2 instances.  This patch introduces options virt_mkfs as multistring.
Its format is --virt_mkfs=<os_type>=<mkfs command> When creating ephemeral device, format it according to the option depending on os_type.  This addresses the bugs,
https://bugs.launchpad.net/nova/+bug/827598
https://bugs.launchpad.net/nova/+bug/828357

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
"""
39
39
 
40
40
import hashlib
 
41
import functools
41
42
import multiprocessing
42
43
import netaddr
43
44
import os
778
779
        if fs_format:
779
780
            utils.execute('mkfs', '-t', fs_format, target)
780
781
 
 
782
    def _create_ephemeral(self, target, local_size, fs_label, os_type):
 
783
        self._create_local(target, local_size)
 
784
        disk.mkfs(os_type, fs_label, target)
 
785
 
781
786
    def _create_swap(self, target, swap_gb):
782
787
        """Create a swap file of specified size"""
783
788
        self._create_local(target, swap_gb)
866
871
                              local_size=local_gb)
867
872
 
868
873
        for eph in driver.block_device_info_get_ephemerals(block_device_info):
869
 
            self._cache_image(fn=self._create_local,
 
874
            fn = functools.partial(self._create_ephemeral,
 
875
                                   fs_label='ephemeral%d' % eph['num'],
 
876
                                   os_type=inst.os_type)
 
877
            self._cache_image(fn=fn,
870
878
                              target=basepath(_get_eph_disk(eph)),
871
 
                              fname="local_%s" % eph['size'],
 
879
                              fname="ephemeral_%s_%s_%s" %
 
880
                              (eph['num'], eph['size'], inst.os_type),
872
881
                              cow=FLAGS.use_cow_images,
873
882
                              local_size=eph['size'])
874
883
 
1102
1111
                nova_context.get_admin_context(), instance['id'],
1103
1112
                {'root_device_name': '/dev/' + self.default_root_device})
1104
1113
 
 
1114
        if local_device:
 
1115
            db.instance_update(
 
1116
                nova_context.get_admin_context(), instance['id'],
 
1117
                {'default_local_device': '/dev/' + self.default_local_device})
 
1118
 
1105
1119
        swap = driver.block_device_info_get_swap(block_device_info)
1106
1120
        if driver.swap_is_usable(swap):
1107
1121
            xml_info['swap_device'] = block_device.strip_dev(
1110
1124
              not self._volume_in_mapping(self.default_swap_device,
1111
1125
                                          block_device_info)):
1112
1126
            xml_info['swap_device'] = self.default_swap_device
 
1127
            db.instance_update(
 
1128
                nova_context.get_admin_context(), instance['id'],
 
1129
                {'default_swap_device': '/dev/' + self.default_swap_device})
1113
1130
 
1114
1131
        config_drive = False
1115
1132
        if instance.get('config_drive') or instance.get('config_drive_id'):