diff options
author | jichenjc <jichenjc@cn.ibm.com> | 2014-06-19 18:07:52 +0800 |
---|---|---|
committer | jichenjc <jichenjc@cn.ibm.com> | 2014-07-07 03:00:57 +0000 |
commit | 5856c3e585891103767eda87035dee8ecaee32ab (patch) | |
tree | 4d17212de40af4ccda7704840b984d3a248de22d /nova/virt | |
parent | b1cde33175bc555e1af822894e8c3f981fbb8ef6 (diff) | |
download | nova-5856c3e585891103767eda87035dee8ecaee32ab.tar.gz |
Format eph disk with specified format in libvirt
novaclient has following command parameters:
--ephemeral size=<size>[,format=<format>]
Create and attach a local ephemeral block device of
<size> GB and format it to <format>.
so mkfs should use the specified format instead of using
default format.
Change-Id: I7a8753284d7b1da1a1203e85b430bd0c5012937a
Closes-Bug: #1280132
Diffstat (limited to 'nova/virt')
-rw-r--r-- | nova/virt/disk/api.py | 16 | ||||
-rw-r--r-- | nova/virt/libvirt/driver.py | 8 |
2 files changed, 14 insertions, 10 deletions
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py index 8b921912ce..7bb4b23fbd 100644 --- a/nova/virt/disk/api.py +++ b/nova/virt/disk/api.py @@ -88,8 +88,8 @@ FS_FORMAT_XFS = "xfs" FS_FORMAT_NTFS = "ntfs" FS_FORMAT_VFAT = "vfat" -_DEFAULT_FS_BY_OSTYPE = {'linux': 'ext3', - 'windows': 'ntfs'} +_DEFAULT_FS_BY_OSTYPE = {'linux': FS_FORMAT_EXT3, + 'windows': FS_FORMAT_NTFS} for s in CONF.virt_mkfs: # NOTE(yamahata): mkfs command may includes '=' for its options. @@ -105,7 +105,7 @@ def get_fs_type_for_os_type(os_type): return os_type if _MKFS_COMMAND.get(os_type) else 'default' -def mkfs(os_type, fs_label, target, run_as_root=True): +def mkfs(os_type, fs_label, target, run_as_root=True, specified_fs=None): """Format a file or block device using a user provided command for each os type. If user has not provided any configuration, @@ -119,10 +119,12 @@ def mkfs(os_type, fs_label, target, run_as_root=True): if mkfs_command: utils.execute(*mkfs_command.split(), run_as_root=run_as_root) else: - default_fs = CONF.default_ephemeral_format - if not default_fs: - default_fs = _DEFAULT_FS_BY_OSTYPE.get(os_type, 'ext3') - utils.mkfs(default_fs, target, fs_label, run_as_root=run_as_root) + if not specified_fs: + specified_fs = CONF.default_ephemeral_format + if not specified_fs: + specified_fs = _DEFAULT_FS_BY_OSTYPE.get(os_type, 'ext3') + + utils.mkfs(specified_fs, target, fs_label, run_as_root=run_as_root) def resize2fs(image, check_exit_code=False, run_as_root=False): diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 425b2efa69..6351feb728 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2459,12 +2459,13 @@ class LibvirtDriver(driver.ComputeDriver): def _create_ephemeral(self, target, ephemeral_size, fs_label, os_type, is_block_dev=False, - max_size=None): + max_size=None, specified_fs=None): if not is_block_dev: self._create_local(target, ephemeral_size) # Run as root only for block devices. - disk.mkfs(os_type, fs_label, target, run_as_root=is_block_dev) + disk.mkfs(os_type, fs_label, target, run_as_root=is_block_dev, + specified_fs=specified_fs) @staticmethod def _create_swap(target, swap_mb, max_size=None): @@ -2678,7 +2679,8 @@ class LibvirtDriver(driver.ComputeDriver): fetch_func=fn, filename=fname, size=size, - ephemeral_size=eph['size']) + ephemeral_size=eph['size'], + specified_fs=specified_fs) if 'disk.swap' in disk_mapping: mapping = disk_mapping['disk.swap'] |