summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2015-07-21 13:06:11 +0100
committerDaniel Watkins <daniel.watkins@canonical.com>2015-07-21 13:06:11 +0100
commitedc46ee7192376af65640a81c39335ebdfd196b6 (patch)
treeceeeff30704dbc3f07f0b2a072e22a3825e0c33f /cloudinit
parent55487d9eb52343bd72271b072734740b52b25c1d (diff)
downloadvyos-cloud-init-edc46ee7192376af65640a81c39335ebdfd196b6.tar.gz
vyos-cloud-init-edc46ee7192376af65640a81c39335ebdfd196b6.zip
Extend disk_setup and mounts to handle /dev/disk symlinks.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_disk_setup.py5
-rw-r--r--cloudinit/config/cc_mounts.py8
2 files changed, 10 insertions, 3 deletions
diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
index e2ce6db4..92fa7a94 100644
--- a/cloudinit/config/cc_disk_setup.py
+++ b/cloudinit/config/cc_disk_setup.py
@@ -648,6 +648,8 @@ def mkpart(device, definition):
table_type: Which partition table to use, defaults to MBR
device: the device to work on.
"""
+ LOG.debug('Ensuring that we have a real device, not a symbolic link')
+ device = os.path.realpath(device)
LOG.debug("Checking values for %s definition" % device)
overwrite = definition.get('overwrite', False)
@@ -745,6 +747,9 @@ def mkfs(fs_cfg):
fs_replace = fs_cfg.get('replace_fs', False)
overwrite = fs_cfg.get('overwrite', False)
+ LOG.debug('Ensuring that we have a real device, not a symbolic link')
+ device = os.path.realpath(device)
+
# This allows you to define the default ephemeral or swap
LOG.debug("Checking %s against default devices", device)
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
index f970c2ca..73b42f91 100644
--- a/cloudinit/config/cc_mounts.py
+++ b/cloudinit/config/cc_mounts.py
@@ -49,7 +49,8 @@ def is_meta_device_name(name):
def _get_nth_partition_for_device(device_path, partition_number):
- potential_suffixes = [str(partition_number), 'p%s' % (partition_number,)]
+ potential_suffixes = [str(partition_number), 'p%s' % (partition_number,),
+ '-part%s' % (partition_number,)]
for suffix in potential_suffixes:
potential_partition_device = '%s%s' % (device_path, suffix)
if os.path.exists(potential_partition_device):
@@ -58,10 +59,11 @@ def _get_nth_partition_for_device(device_path, partition_number):
def _is_block_device(device_path, partition_path=None):
- device_name = device_path.split('/')[-1]
+ device_name = os.path.realpath(device_path).split('/')[-1]
sys_path = os.path.join('/sys/block/', device_name)
if partition_path is not None:
- sys_path = os.path.join(sys_path, partition_path.split('/')[-1])
+ sys_path = os.path.join(
+ sys_path, os.path.realpath(partition_path).split('/')[-1])
return os.path.exists(sys_path)