James Penick has proposed merging ~penick/cloud-init:handle_uppercase_labels 
into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)
Related bugs:
  Bug #1598783 in cloud-init: "Config drives created on RHEL/CentOS 7.1 can't 
be found"
  https://bugs.launchpad.net/cloud-init/+bug/1598783

For more details, see:
https://code.launchpad.net/~penick/cloud-init/+git/cloud-init/+merge/335286

Recognize uppercase vfat disk labels

New mkfs.vfat and fatlabel tools included in the dosfsutils package no longer 
support creating vfat disks with lowercase labels. They silently default to an 
all uppercase label eg CONFIG-2 instead of config-2. This change makes 
cloud-init handle either upper or lower case. 

LP: #1598783
-- 
Your team cloud-init commiters is requested to review the proposed merge of 
~penick/cloud-init:handle_uppercase_labels into cloud-init:master.
diff --git a/cloudinit/sources/DataSourceConfigDrive.py b/cloudinit/sources/DataSourceConfigDrive.py
index 870b368..b8db626 100644
--- a/cloudinit/sources/DataSourceConfigDrive.py
+++ b/cloudinit/sources/DataSourceConfigDrive.py
@@ -25,7 +25,7 @@ DEFAULT_METADATA = {
     "instance-id": DEFAULT_IID,
 }
 FS_TYPES = ('vfat', 'iso9660')
-LABEL_TYPES = ('config-2',)
+LABEL_TYPES = ('config-2', 'CONFIG-2')
 POSSIBLE_MOUNTS = ('sr', 'cd')
 OPTICAL_DEVICES = tuple(('/dev/%s%s' % (z, i) for z in POSSIBLE_MOUNTS
                         for i in range(0, 2)))
@@ -224,7 +224,7 @@ def find_candidate_devs(probe_optical=True):
     config drive v2:
        Disk should be:
         * either vfat or iso9660 formated
-        * labeled with 'config-2'
+        * labeled with 'config-2' or 'CONFIG-2'
     """
     # query optical drive to get it in blkid cache for 2.6 kernels
     if probe_optical:
diff --git a/tests/unittests/test_datasource/test_configdrive.py b/tests/unittests/test_datasource/test_configdrive.py
index 6ef5a35..68400f2 100644
--- a/tests/unittests/test_datasource/test_configdrive.py
+++ b/tests/unittests/test_datasource/test_configdrive.py
@@ -458,6 +458,12 @@ class TestConfigDriveDataSource(CiTestCase):
             self.assertEqual(["/dev/vdb3"],
                              ds.find_candidate_devs())
 
+            # Verify that uppercase labels are also found.
+            devs_with_answers = {"TYPE=vfat": [],
+                                 "TYPE=iso9660": ["/dev/vdb"],
+                                 "LABEL=CONFIG-2": ["/dev/vdb"]}
+            self.assertEqual(["/dev/vdb"], ds.find_candidate_devs())
+
         finally:
             util.find_devs_with = orig_find_devs_with
             util.is_partition = orig_is_partition
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
index c9234ed..ad6c5cf 100644
--- a/tests/unittests/test_ds_identify.py
+++ b/tests/unittests/test_ds_identify.py
@@ -232,6 +232,11 @@ class TestDsIdentify(CiTestCase):
         self._test_ds_found('ConfigDrive')
         return
 
+    def test_config_drive_upper(self):
+        """ConfigDrive datasource has a disk with LABEL=CONFIG-2."""
+        self._test_ds_found('ConfigDriveUpper')
+        return
+
     def test_policy_disabled(self):
         """A Builtin policy of 'disabled' should return not found.
 
@@ -503,6 +508,18 @@ VALID_CFG = {
              },
         ],
     },
+    'ConfigDriveUpper': {
+        'ds': 'ConfigDrive',
+        'mocks': [
+            {'name': 'blkid', 'ret': 0,
+             'out': blkid_out(
+                 [{'DEVNAME': 'vda1', 'TYPE': 'vfat', 'PARTUUID': uuid4()},
+                  {'DEVNAME': 'vda2', 'TYPE': 'ext4',
+                   'LABEL': 'cloudimg-rootfs', 'PARTUUID': uuid4()},
+                  {'DEVNAME': 'vdb', 'TYPE': 'vfat', 'LABEL': 'CONFIG-2'}])
+             },
+        ],
+    },
 }
 
 # vi: ts=4 expandtab
diff --git a/tools/ds-identify b/tools/ds-identify
index 5893a76..374c3ad 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -579,6 +579,8 @@ dscheck_NoCloud() {
 check_configdrive_v2() {
     if has_fs_with_label "config-2"; then
         return ${DS_FOUND}
+    elif has_fs_with_label "CONFIG-2"; then
+        return ${DS_FOUND}
     fi
     # look in /config-drive <vlc>/seed/config_drive for a directory
     # openstack/YYYY-MM-DD format with a file meta_data.json
@@ -666,7 +668,7 @@ is_cdrom_ovf() {
 
     # explicitly skip known labels of other types. rd_rdfe is azure.
     case "$label" in
-        config-2|rd_rdfe_stable*|cidata) return 1;;
+        config-2|CONFIG-2|rd_rdfe_stable*|cidata) return 1;;
     esac
 
     local idstr="http://schemas.dmtf.org/ovf/environment/1";
_______________________________________________
Mailing list: https://launchpad.net/~cloud-init-dev
Post to     : cloud-init-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to