diff options
author | Peter Schiffer <pschiffe@redhat.com> | 2013-12-10 19:23:37 +0100 |
---|---|---|
committer | Peter Schiffer <pschiffe@redhat.com> | 2013-12-10 19:23:37 +0100 |
commit | e99df5fdba9bb16dfec1e1a80f001fe97622e71b (patch) | |
tree | 2482189e6d504ee20fb6e957aa3303164ee5aa91 /src/hardware/LMI_DiskDriveSystemDeviceProvider.c | |
parent | 4d3e9d9f3bda71faf6b46286e1ad78fb0e3696cf (diff) | |
download | openlmi-providers-e99df5fdba9bb16dfec1e1a80f001fe97622e71b.tar.gz openlmi-providers-e99df5fdba9bb16dfec1e1a80f001fe97622e71b.tar.xz openlmi-providers-e99df5fdba9bb16dfec1e1a80f001fe97622e71b.zip |
Hardware: use lsblk as primary source for disks
This patch makes lsblk primary source for information about disks instead of
smartctl. This change was needed because in virtual environment some disks might
be recognized by smartctl while others not, and in this case, some disks would
be missing in LMI classes. With lsblk, all disks are always listed. Smartctl
is used as source of additional information if avaiable.
Diffstat (limited to 'src/hardware/LMI_DiskDriveSystemDeviceProvider.c')
-rw-r--r-- | src/hardware/LMI_DiskDriveSystemDeviceProvider.c | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/hardware/LMI_DiskDriveSystemDeviceProvider.c b/src/hardware/LMI_DiskDriveSystemDeviceProvider.c index 981de58..00ab2fa 100644 --- a/src/hardware/LMI_DiskDriveSystemDeviceProvider.c +++ b/src/hardware/LMI_DiskDriveSystemDeviceProvider.c @@ -22,7 +22,6 @@ #include "LMI_DiskDriveSystemDevice.h" #include "LMI_Hardware.h" #include "globals.h" -#include "smartctl.h" #include "lsblk.h" static const CMPIBroker* _cb; @@ -60,38 +59,18 @@ static CMPIStatus LMI_DiskDriveSystemDeviceEnumInstances( LMI_DiskDriveSystemDevice lmi_hdd_sys; LMI_DiskDriveRef lmi_hdd; const char *ns = KNameSpace(cop); - unsigned i, hdds_nb = 0; - char *id; - SmartctlHdd *smtcl_hdds = NULL; - unsigned smtcl_hdds_nb = 0; + unsigned i; LsblkHdd *lsblk_hdds = NULL; unsigned lsblk_hdds_nb = 0; - if (smartctl_get_hdds(&smtcl_hdds, &smtcl_hdds_nb) != 0 || smtcl_hdds_nb < 1) { - smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb); - if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) { - goto done; - } - } - - if (smtcl_hdds_nb > 0) { - hdds_nb = smtcl_hdds_nb; - } else { - hdds_nb = lsblk_hdds_nb; + if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) { + goto done; } - for (i = 0; i < hdds_nb; i++) { - /* in fallback mode, use only disk devices from lsblk */ - if (smtcl_hdds_nb < 1) { - if (strcmp(lsblk_hdds[i].type, "disk") != 0) { - continue; - } - } - - if (smtcl_hdds_nb > 0) { - id = smtcl_hdds[i].serial_number; - } else { - id = lsblk_hdds[i].name; + for (i = 0; i < lsblk_hdds_nb; i++) { + /* use only disk devices from lsblk */ + if (strcmp(lsblk_hdds[i].type, "disk") != 0) { + continue; } LMI_DiskDriveSystemDevice_Init(&lmi_hdd_sys, _cb, ns); @@ -102,7 +81,7 @@ static CMPIStatus LMI_DiskDriveSystemDeviceEnumInstances( LMI_DiskDriveRef_Set_SystemName(&lmi_hdd, get_system_name()); LMI_DiskDriveRef_Set_CreationClassName(&lmi_hdd, ORGID "_" DISK_DRIVE_CLASS_NAME); - LMI_DiskDriveRef_Set_DeviceID(&lmi_hdd, id); + LMI_DiskDriveRef_Set_DeviceID(&lmi_hdd, lsblk_hdds[i].name); LMI_DiskDriveSystemDevice_SetObjectPath_GroupComponent( &lmi_hdd_sys, lmi_get_computer_system()); @@ -113,7 +92,6 @@ static CMPIStatus LMI_DiskDriveSystemDeviceEnumInstances( } done: - smartctl_free_hdds(&smtcl_hdds, &smtcl_hdds_nb); lsblk_free_hdds(&lsblk_hdds, &lsblk_hdds_nb); CMReturn(CMPI_RC_OK); |