diff options
author | Peter Schiffer <pschiffe@redhat.com> | 2014-01-08 15:46:53 +0100 |
---|---|---|
committer | Peter Schiffer <pschiffe@redhat.com> | 2014-01-09 13:42:51 +0100 |
commit | bc16e11fb41146aee30f851bd41de9d645ad68bb (patch) | |
tree | 261d3256a1608009cd404ce729d1525eaf6d8a00 /src/hardware | |
parent | ac94d901a2a1b9fc8683b44adeec2d3d6f9fa5bb (diff) | |
download | openlmi-providers-bc16e11fb41146aee30f851bd41de9d645ad68bb.tar.gz openlmi-providers-bc16e11fb41146aee30f851bd41de9d645ad68bb.tar.xz openlmi-providers-bc16e11fb41146aee30f851bd41de9d645ad68bb.zip |
Hardware: added ATAProtocolEndpointProvider
New Provider:
* LMI_ATAProtocolEndpoint
Diffstat (limited to 'src/hardware')
-rw-r--r-- | src/hardware/LMI_ATAProtocolEndpointProvider.c | 244 | ||||
-rw-r--r-- | src/hardware/LMI_Hardware.h | 1 |
2 files changed, 245 insertions, 0 deletions
diff --git a/src/hardware/LMI_ATAProtocolEndpointProvider.c b/src/hardware/LMI_ATAProtocolEndpointProvider.c new file mode 100644 index 0000000..c994874 --- /dev/null +++ b/src/hardware/LMI_ATAProtocolEndpointProvider.c @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2013 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_ATAProtocolEndpoint.h" +#include "LMI_Hardware.h" +#include "globals.h" +#include "lsblk.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_ATAProtocolEndpointInitialize(const CMPIContext *ctx) +{ + lmi_init(provider_name, _cb, ctx, provider_config_defaults); +} + +static CMPIStatus LMI_ATAProtocolEndpointCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ATAProtocolEndpointEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_ATAProtocolEndpointEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_ATAProtocolEndpoint lmi_hdd_endpoint; + const char *ns = KNameSpace(cop); + unsigned i; + char instance_id[INSTANCE_ID_LEN], name[ELEMENT_NAME_LEN]; + 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_ATAProtocolEndpoint_Init(&lmi_hdd_endpoint, _cb, ns); + + LMI_ATAProtocolEndpoint_Set_SystemCreationClassName(&lmi_hdd_endpoint, + get_system_creation_class_name()); + LMI_ATAProtocolEndpoint_Set_SystemName(&lmi_hdd_endpoint, + get_system_name()); + LMI_ATAProtocolEndpoint_Set_CreationClassName(&lmi_hdd_endpoint, + ORGID "_" DISK_DRIVE_ATA_PROTO_ENDPOINT_CLASS_NAME); + LMI_ATAProtocolEndpoint_Set_Caption(&lmi_hdd_endpoint, + "ATA Protocol Endpoint"); + LMI_ATAProtocolEndpoint_Set_Description(&lmi_hdd_endpoint, + "This object represents ATA Protocol Endpoint of disk drive in system."); + + LMI_ATAProtocolEndpoint_Set_Role(&lmi_hdd_endpoint, + LMI_ATAProtocolEndpoint_Role_Target); + LMI_ATAProtocolEndpoint_Set_ProtocolIFType(&lmi_hdd_endpoint, + LMI_ATAProtocolEndpoint_ProtocolIFType_Unknown); + + snprintf(name, ELEMENT_NAME_LEN, + "%s " DISK_DRIVE_ATA_PROTO_ENDPOINT_CLASS_NAME, + lsblk_hdds[i].name); + snprintf(instance_id, INSTANCE_ID_LEN, + ORGID ":" ORGID "_" DISK_DRIVE_ATA_PROTO_ENDPOINT_CLASS_NAME ":%s", + name); + + LMI_ATAProtocolEndpoint_Set_Name(&lmi_hdd_endpoint, name); + LMI_ATAProtocolEndpoint_Set_ElementName(&lmi_hdd_endpoint, name); + LMI_ATAProtocolEndpoint_Set_InstanceID(&lmi_hdd_endpoint, instance_id); + + if (lsblk_hdds[i].basename[0] == 'h') { + LMI_ATAProtocolEndpoint_Set_ConnectionType(&lmi_hdd_endpoint, + LMI_ATAProtocolEndpoint_ConnectionType_ATA); + } else if (lsblk_hdds[i].basename[0] == 's') { + /* TODO: What about SAS? */ + LMI_ATAProtocolEndpoint_Set_ConnectionType(&lmi_hdd_endpoint, + LMI_ATAProtocolEndpoint_ConnectionType_SATA); + } else { + LMI_ATAProtocolEndpoint_Set_ConnectionType(&lmi_hdd_endpoint, + LMI_ATAProtocolEndpoint_ConnectionType_Other); + } + + KReturnInstance(cr, lmi_hdd_endpoint); + } + +done: + lsblk_free_hdds(&lsblk_hdds, &lsblk_hdds_nb); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ATAProtocolEndpointGetInstance( + 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_ATAProtocolEndpointCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_ATAProtocolEndpointModifyInstance( + 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_ATAProtocolEndpointDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_ATAProtocolEndpointExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_ATAProtocolEndpoint, + LMI_ATAProtocolEndpoint, + _cb, + LMI_ATAProtocolEndpointInitialize(ctx)) + +static CMPIStatus LMI_ATAProtocolEndpointMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_ATAProtocolEndpointInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_ATAProtocolEndpoint_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_ATAProtocolEndpoint, + LMI_ATAProtocolEndpoint, + _cb, + LMI_ATAProtocolEndpointInitialize(ctx)) + +KUint32 LMI_ATAProtocolEndpoint_RequestStateChange( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_ATAProtocolEndpointRef* self, + const KUint16* RequestedState, + KRef* Job, + const KDateTime* TimeoutPeriod, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_ATAProtocolEndpoint_BroadcastReset( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_ATAProtocolEndpointRef* self, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_ATAProtocolEndpoint", + "LMI_ATAProtocolEndpoint", + "instance method") diff --git a/src/hardware/LMI_Hardware.h b/src/hardware/LMI_Hardware.h index aca9b70..e9873f1 100644 --- a/src/hardware/LMI_Hardware.h +++ b/src/hardware/LMI_Hardware.h @@ -49,5 +49,6 @@ const char *provider_name; #define DISK_PHYS_PKG_CLASS_NAME "DiskPhysicalPackage" #define DISK_DRIVE_CLASS_NAME "DiskDrive" #define DISK_DRIVE_SW_IDENTITY_CLASS_NAME "DiskDriveSoftwareIdentity" +#define DISK_DRIVE_ATA_PROTO_ENDPOINT_CLASS_NAME "ATAProtocolEndpoint" #endif /* LMI_HARDWARE_H_ */ |