diff options
author | Peter Schiffer <pschiffe@redhat.com> | 2014-01-14 16:03:07 +0100 |
---|---|---|
committer | Peter Schiffer <pschiffe@redhat.com> | 2014-01-14 16:03:07 +0100 |
commit | 06fabf29d5691223cf91a1c369b30b4f024a1f68 (patch) | |
tree | bded1b0baf075b6c346f10fca7a621f8937eeb73 /src/hardware | |
parent | 00d6546132d71931951c60c7572f27799893527e (diff) | |
download | openlmi-providers-06fabf29d5691223cf91a1c369b30b4f024a1f68.tar.gz openlmi-providers-06fabf29d5691223cf91a1c369b30b4f024a1f68.tar.xz openlmi-providers-06fabf29d5691223cf91a1c369b30b4f024a1f68.zip |
Hardware: added LMI_DiskDriveDeviceSAPImplementationProvider
New provider:
* LMI_DiskDriveDeviceSAPImplementationProvider
Diffstat (limited to 'src/hardware')
-rw-r--r-- | src/hardware/LMI_DiskDriveDeviceSAPImplementationProvider.c | 284 |
1 files changed, 284 insertions, 0 deletions
diff --git a/src/hardware/LMI_DiskDriveDeviceSAPImplementationProvider.c b/src/hardware/LMI_DiskDriveDeviceSAPImplementationProvider.c new file mode 100644 index 0000000..6745804 --- /dev/null +++ b/src/hardware/LMI_DiskDriveDeviceSAPImplementationProvider.c @@ -0,0 +1,284 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Peter Schiffer <pschiffe@redhat.com> + */ + +#include <konkret/konkret.h> +#include "LMI_DiskDriveDeviceSAPImplementation.h" +#include "LMI_Hardware.h" +#include "globals.h" +#include "lsblk.h" + +static const CMPIBroker* _cb; + +static void LMI_DiskDriveDeviceSAPImplementationInitialize(const CMPIContext *ctx) +{ + lmi_init(provider_name, _cb, ctx, provider_config_defaults); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_DiskDriveDeviceSAPImplementation lmi_hdd_sap_impl; + LMI_ATAProtocolEndpointRef lmi_hdd_ata_endp; + LMI_DiskDriveATAPortRef lmi_hdd_ata_port; + const char *ns = KNameSpace(cop); + char name[ELEMENT_NAME_LEN]; + unsigned i; + LsblkHdd *lsblk_hdds = NULL; + unsigned lsblk_hdds_nb = 0; + + if (lsblk_get_hdds(&lsblk_hdds, &lsblk_hdds_nb) != 0 || lsblk_hdds_nb < 1) { + goto done; + } + + for (i = 0; i < lsblk_hdds_nb; i++) { + /* use only disk devices from lsblk */ + if (strcmp(lsblk_hdds[i].type, "disk") != 0) { + continue; + } + + LMI_DiskDriveDeviceSAPImplementation_Init(&lmi_hdd_sap_impl, _cb, ns); + + snprintf(name, ELEMENT_NAME_LEN, + "%s " DISK_DRIVE_ATA_PORT_CLASS_NAME, + lsblk_hdds[i].name); + + LMI_DiskDriveATAPortRef_Init(&lmi_hdd_ata_port, _cb, ns); + LMI_DiskDriveATAPortRef_Set_SystemCreationClassName(&lmi_hdd_ata_port, + get_system_creation_class_name()); + LMI_DiskDriveATAPortRef_Set_SystemName(&lmi_hdd_ata_port, + get_system_name()); + LMI_DiskDriveATAPortRef_Set_CreationClassName(&lmi_hdd_ata_port, + ORGID "_" DISK_DRIVE_ATA_PORT_CLASS_NAME); + LMI_DiskDriveATAPortRef_Set_DeviceID(&lmi_hdd_ata_port, name); + + snprintf(name, ELEMENT_NAME_LEN, + "%s " DISK_DRIVE_ATA_PROTO_ENDPOINT_CLASS_NAME, + lsblk_hdds[i].name); + + LMI_ATAProtocolEndpointRef_Init(&lmi_hdd_ata_endp, _cb, ns); + LMI_ATAProtocolEndpointRef_Set_SystemCreationClassName(&lmi_hdd_ata_endp, + get_system_creation_class_name()); + LMI_ATAProtocolEndpointRef_Set_SystemName(&lmi_hdd_ata_endp, + get_system_name()); + LMI_ATAProtocolEndpointRef_Set_CreationClassName(&lmi_hdd_ata_endp, + ORGID "_" DISK_DRIVE_ATA_PROTO_ENDPOINT_CLASS_NAME); + LMI_ATAProtocolEndpointRef_Set_Name(&lmi_hdd_ata_endp, name); + + LMI_DiskDriveDeviceSAPImplementation_Set_Antecedent(&lmi_hdd_sap_impl, + &lmi_hdd_ata_port); + LMI_DiskDriveDeviceSAPImplementation_Set_Dependent(&lmi_hdd_sap_impl, + &lmi_hdd_ata_endp); + + KReturnInstance(cr, lmi_hdd_sap_impl); + } + +done: + lsblk_free_hdds(&lsblk_hdds, &lsblk_hdds_nb); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_DiskDriveDeviceSAPImplementation_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_DiskDriveDeviceSAPImplementation_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_DiskDriveDeviceSAPImplementation_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_DiskDriveDeviceSAPImplementationReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_DiskDriveDeviceSAPImplementation_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_DiskDriveDeviceSAPImplementation, + LMI_DiskDriveDeviceSAPImplementation, + _cb, + LMI_DiskDriveDeviceSAPImplementationInitialize(ctx)) + +CMAssociationMIStub( + LMI_DiskDriveDeviceSAPImplementation, + LMI_DiskDriveDeviceSAPImplementation, + _cb, + LMI_DiskDriveDeviceSAPImplementationInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_DiskDriveDeviceSAPImplementation", + "LMI_DiskDriveDeviceSAPImplementation", + "instance association") |