# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1197405880 28800
# Node ID daf4ce2d8c17b0c5bbe410a5a0d67bf5544f52ce
# Parent 6c3ca59055416d7bb07716d3a750800e6087878e
GetInstance() does not return an instance that matches the instanceID given.
Add a argument to return_ele_cap() that handles the GetInstance(). If this argument is
set, get the InstanceID from the ref. In the loop that walks through the domains on the
system, check to see if this id matches one of the names returned. If there is a match,
create the instance and then exit from the loop.
If no match is found, an error is returned.
Failing query:
wbemcli gi
http://localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.Ins...
localhost:5988/root/virt:Xen_EnabledLogicalElementCapabilities.InstanceID="kaitlin_test"
Caption,Description,InstanceID="hd_domain",ElementName,ElementNameEditSupported=FALSE,MaxElementNameLen,RequestedStatesSupported=2,3,9,10,11,ElementNameMask,StateAwareness,CreationClassName="Xen_EnabledLogicalElementCapabilities"
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 6c3ca5905541 -r daf4ce2d8c17 src/Virt_EnabledLogicalElementCapabilities.c
--- a/src/Virt_EnabledLogicalElementCapabilities.c Tue Dec 11 09:42:24 2007 -0800
+++ b/src/Virt_EnabledLogicalElementCapabilities.c Tue Dec 11 12:44:40 2007 -0800
@@ -21,6 +21,7 @@
*/
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#include <cmpidt.h>
#include <cmpift.h>
@@ -135,7 +136,8 @@ CMPIStatus get_ele_cap(const CMPIBroker
static CMPIStatus return_ele_cap(const CMPIObjectPath *ref,
const CMPIResult *results,
- int names_only)
+ int names_only,
+ int get_instance)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst = NULL;
@@ -144,10 +146,20 @@ static CMPIStatus return_ele_cap(const C
int count;
int i;
const char *name;
+ const char* id;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
goto out;
+
+ if (get_instance) {
+ if (cu_get_str_path(ref, "InstanceID", &id) != CMPI_RC_OK)
{
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "No InstanceID specified");
+ goto out;
+ }
+ }
count = get_domain_list(conn, &list);
if (count <= 0)
@@ -162,6 +174,11 @@ static CMPIStatus return_ele_cap(const C
goto end;
}
+ if (get_instance) {
+ if (!STREQ(name, id))
+ goto end;
+ }
+
s = get_ele_cap(_BROKER, ref, name, &inst);
if (s.rc != CMPI_RC_OK)
goto end;
@@ -174,7 +191,7 @@ static CMPIStatus return_ele_cap(const C
end:
virDomainFree(list[i]);
- if (s.rc != CMPI_RC_OK)
+ if ((s.rc != CMPI_RC_OK) || (STREQ(name, id)))
goto out;
}
@@ -191,7 +208,7 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *reference)
{
- return return_ele_cap(reference, results, 1);
+ return return_ele_cap(reference, results, 1, 0);
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -201,7 +218,7 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- return return_ele_cap(reference, results, 0);
+ return return_ele_cap(reference, results, 0, 0);
}
static CMPIStatus GetInstance(CMPIInstanceMI *self,
@@ -210,7 +227,7 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *reference,
const char **properties)
{
- return return_ele_cap(reference, results, 0);
+ return return_ele_cap(reference, results, 0, 1);
}
DEFAULT_CI();