diff options
| author | Justin Santa Barbara <justin@fathomdb.com> | 2012-02-24 00:48:13 -0800 |
|---|---|---|
| committer | Justin Santa Barbara <justin@fathomdb.com> | 2012-02-24 02:57:09 -0800 |
| commit | f4bf828775db8bed77df12a5947de64427ddad3b (patch) | |
| tree | aa41c16f897b4dad0974ecb53269a36f6a4bd982 /nova | |
| parent | 8924ad8d6d57810d4de6ce4ce61efdccc759b066 (diff) | |
Example config_drive init script, label the config drive
Configuration with DHCP & cloud-init can be painful. The config_drive is great,
and it avoids disk injection, but there's no example of how to use it.
So here's a little example init.d script for contrib, and a code patch to make
sure the config drive gets a nice volume label.
Change-Id: I22a1d6a824856ca9651b435d0fe54e348ab107fe
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/virt/libvirt/connection.py | 8 | ||||
| -rw-r--r-- | nova/virt/libvirt/utils.py | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index fe2df8012..556607666 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -954,7 +954,8 @@ class LibvirtConnection(driver.ComputeDriver): disk.extend(target, size) @staticmethod - def _create_local(target, local_size, unit='G', fs_format=None): + def _create_local(target, local_size, unit='G', + fs_format=None, label=None): """Create a blank image of specified size""" if not fs_format: @@ -963,7 +964,7 @@ class LibvirtConnection(driver.ComputeDriver): libvirt_utils.create_image('raw', target, '%d%c' % (local_size, unit)) if fs_format: - libvirt_utils.mkfs(fs_format, target) + libvirt_utils.mkfs(fs_format, target, label) def _create_ephemeral(self, target, ephemeral_size, fs_label, os_type): self._create_local(target, ephemeral_size) @@ -1109,8 +1110,9 @@ class LibvirtConnection(driver.ComputeDriver): user_id=instance['user_id'], project_id=instance['project_id'],) elif config_drive: + label = 'config' self._create_local(basepath('disk.config'), 64, unit='M', - fs_format='msdos') # 64MB + fs_format='msdos', label=label) # 64MB if instance['key_data']: key = str(instance['key_data']) diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index da3f95d4f..329f76eb1 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -118,17 +118,22 @@ def copy_image(src, dest): execute('cp', src, dest) -def mkfs(fs, path): +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: - execute('mkfs', '-t', fs, path) + args = ['mkfs', '-t', fs] + if label: + args.extend(['-n', label]) + args.append(path) + execute(*args) def ensure_tree(path): |
