
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1232562000 28800 # Node ID a7074d59e1e34398b8785bf218bbdbea56db0945 # Parent 62dbae6f50a56ee2d603503a704b8cd083788131 Replace CBGetInstance() with CBEnumInstances() in Virt_HostSystem This is a work around to deal with the way the SBLIM provider determines the FQDN of a host system. The value the SBLIM provider returns can depend on how the /etc/hosts file is formatted, as well as other factors (running dnsdomainname caused the provider to print two different values on my system). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 62dbae6f50a5 -r a7074d59e1e3 src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Tue Jan 20 22:27:01 2009 -0800 +++ b/src/Virt_HostSystem.c Wed Jan 21 10:20:00 2009 -0800 @@ -144,16 +144,10 @@ CMPIInstance **inst) { CMPIObjectPath *path; + CMPIEnumeration *en = NULL; + CMPIData data; CMPIStatus s; const char *cn = "Linux_ComputerSystem"; - char name[256]; - - if (get_fqdn(name, sizeof(name)) != 0) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Unable to get hostname: %m"); - return s; - } path = CMNewObjectPath(broker, "root/cimv2", cn, &s); if ((path == NULL) || (s.rc != CMPI_RC_OK)) { @@ -163,11 +157,33 @@ return s; } - CMAddKey(path, "CreationClassName", cn, CMPI_chars); - CMAddKey(path, "Name", name, CMPI_chars); + /* FIXME: This approach may return the wrong instance if more than + one SBLIM Linux_ComputerSystem instance exists on the system. + This isn't likely to happen in most cases, but a better approach + should be used here. + */ + en = CBEnumInstances(broker, context, path, NULL, &s); + if (en == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Upcall EnumInstances of %s class failed", + cn); + goto out; + } - *inst = CBGetInstance(broker, context, path, NULL, &s); + if (CMHasNext(en, &s)) { + data = CMGetNext(en, &s); + if (CMIsNullObject(data.value.inst)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Failed to retrieve enumeration entry"); + goto out; + } + *inst = data.value.inst; + } + + out: if (s.rc != CMPI_RC_OK) { CU_DEBUG("SBLIM: %i %s", s.rc, CMGetCharPtr(s.msg)); } else {