]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: update get_device_id to match in-tree implementation
authorSage Weil <sage@redhat.com>
Thu, 6 Dec 2018 15:43:36 +0000 (09:43 -0600)
committerAlfredo Deza <adeza@redhat.com>
Wed, 2 Jan 2019 20:25:09 +0000 (15:25 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit c967dbf81f85602d2cd044ee5a91ba38cd76bdb9)

src/ceph-volume/ceph_volume/util/device.py

index b94628cf86434ffa4ab2e2fb3ec9e9a41e5425fa..470237532ac4bf723a23399653e64a78182167c2 100644 (file)
@@ -174,17 +174,27 @@ class Device(object):
         return output
 
     def _get_device_id(self):
-        props = ['ID_MODEL','ID_SERIAL_SHORT']
-        dev_id = disk.udevadm_property(self.abspath, props)
-        if all([prop in dev_id and dev_id[prop] for prop in props]):
-            values = [dev_id[prop].replace(' ', '_') for prop in props]
-            return '_'.join(values)
+        """
+        Please keep this implementation in sync with get_device_id() in
+        src/common/blkdev.cc
+        """
+        props = ['ID_VENDOR','ID_MODEL','ID_SERIAL_SHORT', 'ID_SERIAL',
+                 'ID_SCSI_SERIAL']
+        p = disk.udevadm_property(self.abspath, props)
+        if 'ID_VENDOR' in p and 'ID_MODEL' in p and 'ID_SCSI_SERIAL' in p:
+            dev_id = '_'.join(p['ID_VENDOR'], p['ID_MODEL'],
+                              p['ID_SCSI_SERIAL'])
+        elif 'ID_MODEL' in p and 'ID_SERIAL_SHORT' in p:
+            dev_id = '_'.join(p['ID_MODEL'], p['ID_SERIAL_SHORT'])
+        elif 'ID_SERIAL' in p:
+            dev_id = p['ID_SERIAL']
         else:
             # the else branch should fallback to using sysfs and ioctl to
             # retrieve device_id on FreeBSD. Still figuring out if/how the
             # python ioctl implementation does that on FreeBSD
-            return ''
-        return ''
+            dev_id = ''
+        dev_id.replace(' ', '_')
+        return dev_id