
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204286653 -3600 # Node ID b0bc7c2f51e4585b3b0f3d2548ccee6e625aa670 # Parent 2fe6a1864de83ecfabf7eaae8c9a912af39b8ecc HostSystem: adopt interface of single instance providers During the last updates to single instance providers, a common interface look and feel has established. This patch adopts these changes to HostSystem. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 2fe6a1864de8 -r b0bc7c2f51e4 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Thu Feb 28 14:43:44 2008 -0800 +++ b/src/Virt_HostSystem.c Fri Feb 29 13:04:13 2008 +0100 @@ -36,19 +36,6 @@ const static CMPIBroker *_BROKER; -CMPIStatus validate_host_ref(const CMPIBroker *broker, - const CMPIObjectPath *ref) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *inst; - - s = get_host_cs(broker, ref, &inst); - if (inst != NULL) - s = cu_validate_ref(broker, ref, inst); - - return s; -} - static int set_host_system_properties(CMPIInstance *instance) { CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -70,18 +57,23 @@ static int set_host_system_properties(CM return 1; } -CMPIStatus get_host_cs(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance) +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; virConnectPtr conn = NULL; - *instance = NULL; conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) - return s; + if (conn == NULL) { + if (is_get_inst) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance"); + goto out; + } inst = get_typed_instance(broker, pfx_from_conn(conn), @@ -97,43 +89,36 @@ CMPIStatus get_host_cs(const CMPIBroker set_host_system_properties(inst); - out: - virConnectClose(conn); - *instance = inst; - - return s; -} - -static CMPIStatus return_host_cs(const CMPIObjectPath *reference, - const CMPIResult *results, - bool name_only, - bool is_get_inst) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *instance; - - s = get_host_cs(_BROKER, reference, &instance); - if (s.rc != CMPI_RC_OK) - goto out; - - if (instance == NULL) { - if (is_get_inst) - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); - goto out; - } - if (is_get_inst) { - s = cu_validate_ref(_BROKER, reference, instance); + s = cu_validate_ref(broker, reference, inst); if (s.rc != CMPI_RC_OK) goto out; } + *_inst = inst; + + out: + virConnectClose(conn); + + return s; +} + +static CMPIStatus return_host(const CMPIObjectPath *reference, + const CMPIResult *results, + bool name_only, + bool is_get_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + + s = get_host(_BROKER, reference, &inst, is_get_inst); + if (s.rc != CMPI_RC_OK || inst == NULL) + goto out; + if (name_only) - cu_return_instance_name(results, instance); + cu_return_instance_name(results, inst); else - CMReturnInstance(results, instance); + CMReturnInstance(results, inst); out: return s; @@ -147,8 +132,8 @@ CMPIStatus get_host_system_properties(co CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *host = NULL; - s = get_host_cs(broker, ref, &host); - if (s.rc != CMPI_RC_OK) + s = get_host(broker, ref, &host, false); + if (s.rc != CMPI_RC_OK || host == NULL) goto out; if (cu_get_str_prop(host, "Name", name) != CMPI_RC_OK) { @@ -174,10 +159,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_host_cs(reference, - results, - true, - false); + return return_host(reference, results, true, false); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -187,10 +169,7 @@ static CMPIStatus EnumInstances(CMPIInst const char **properties) { - return return_host_cs(reference, - results, - false, - false); + return return_host(reference, results, false, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -199,10 +178,7 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - return return_host_cs(reference, - results, - false, - true); + return return_host(reference, results, false, true); } DEFAULT_CI(); diff -r 2fe6a1864de8 -r b0bc7c2f51e4 src/Virt_HostSystem.h --- a/src/Virt_HostSystem.h Thu Feb 28 14:43:44 2008 -0800 +++ b/src/Virt_HostSystem.h Fri Feb 29 13:04:13 2008 +0100 @@ -21,16 +21,14 @@ #ifndef __VIRT_HOSTSYSTEM_H #define __VIRT_HOSTSYSTEM_H -CMPIStatus get_host_cs(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance); +CMPIStatus get_host(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **_inst, + bool is_get_inst); CMPIStatus get_host_system_properties(const char **name, const char **ccname, const CMPIObjectPath *ref, const CMPIBroker *broker); -CMPIStatus validate_host_ref(const CMPIBroker *broker, - const CMPIObjectPath *ref); - #endif