diff options
| author | Mate Lakat <mate.lakat@citrix.com> | 2012-10-23 16:00:31 +0100 |
|---|---|---|
| committer | Mate Lakat <mate.lakat@citrix.com> | 2012-10-23 16:09:37 +0100 |
| commit | 20b349337eccaa7e1f49742a70f90488af7993fa (patch) | |
| tree | 1baac5a4bfd2a9ae79d97ab1cb40fbf813b3204d /nova/virt | |
| parent | a0fcd1248071ad66b610eac4903adf36b314390b (diff) | |
Move mkfs from libvirt.utils to utils
Related to blueprint xenapi-config-drive
Move mkfs function to nova.utils, so configdrive module does not depend
on the libvirt module. This way, the configdrive module could be used
by other virt modules.
Change-Id: Ibda2aacfa0b66bc087e397df1474b5dfbe86d923
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/configdrive.py | 3 | ||||
| -rw-r--r-- | nova/virt/libvirt/driver.py | 4 | ||||
| -rw-r--r-- | nova/virt/libvirt/utils.py | 21 |
3 files changed, 3 insertions, 25 deletions
diff --git a/nova/virt/configdrive.py b/nova/virt/configdrive.py index bc9ef55c4..7ae97f2ec 100644 --- a/nova/virt/configdrive.py +++ b/nova/virt/configdrive.py @@ -27,7 +27,6 @@ from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova import utils from nova import version -from nova.virt.libvirt import utils as virtutils LOG = logging.getLogger(__name__) @@ -95,7 +94,7 @@ class ConfigDriveBuilder(object): with open(path, 'w') as f: f.truncate(64 * 1024 * 1024) - virtutils.mkfs('vfat', path, label='config-2') + utils.mkfs('vfat', path, label='config-2') mounted = False try: diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 2d3b1d954..1dda6893e 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1213,7 +1213,7 @@ class LibvirtDriver(driver.ComputeDriver): libvirt_utils.create_image('raw', target, '%d%c' % (local_size, unit)) if fs_format: - libvirt_utils.mkfs(fs_format, target, label) + utils.mkfs(fs_format, target, label) def _create_ephemeral(self, target, ephemeral_size, fs_label, os_type): self._create_local(target, ephemeral_size) @@ -1223,7 +1223,7 @@ class LibvirtDriver(driver.ComputeDriver): def _create_swap(target, swap_mb): """Create a swap file of specified size""" libvirt_utils.create_image('raw', target, '%dM' % swap_mb) - libvirt_utils.mkfs('swap', target) + utils.mkfs('swap', target) @staticmethod def _get_console_log_path(instance_name): diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index 17c9efdda..a9b951b7f 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -279,27 +279,6 @@ def copy_image(src, dest, host=None): execute('rsync', '--sparse', '--compress', src, dest) -def mkfs(fs, path, label=None): - """Format a file or block device - - :param fs: Filesystem type (examples include 'swap', 'ext3', 'ext4' - 'btrfs', etc.) - :param path: Path to file or block device to format - :param label: Volume label to use - """ - if fs == 'swap': - execute('mkswap', path) - else: - args = ['mkfs', '-t', fs] - #add -F to force no interactive excute on non-block device. - if fs in ['ext3', 'ext4']: - args.extend(['-F']) - if label: - args.extend(['-n', label]) - args.append(path) - execute(*args) - - def write_to_file(path, contents, umask=None): """Write the given contents to a file |
