summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
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)