]> 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)
committerSage Weil <sage@redhat.com>
Fri, 7 Dec 2018 15:50:13 +0000 (09:50 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph-volume/ceph_volume/util/device.py

index fd48f10b482778c12e02d344cdbaaa70665a130b..9b1ae6a5ab553b0e3af9c77f069d79fa83eed225 100644 (file)
@@ -184,17 +184,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