
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1201904890 28800 # Node ID 3b1671a993401889101969b3f5e3a25e45d13400 # Parent 19bd4c5ede1512bcd411a98b3c09acebc506b38e Set additional attribute values in Virt_ComputerSystem.c OtherIdentifyingInfo property and IdentifyingDescriptions. Modify instance_from_dom() to take a prefix parameter. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 19bd4c5ede15 -r 3b1671a99340 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Feb 01 10:55:58 2008 -0800 +++ b/src/Virt_ComputerSystem.c Fri Feb 01 14:28:10 2008 -0800 @@ -71,7 +71,9 @@ static int set_name_from_dom(virDomainPt } /* Set the "UUID" property of an instance from a domain */ -static int set_uuid_from_dom(virDomainPtr dom, CMPIInstance *instance) +static int set_uuid_from_dom(virDomainPtr dom, + CMPIInstance *instance, + char **out_uuid) { char uuid[VIR_UUID_STRING_BUFLEN]; int ret; @@ -82,6 +84,8 @@ static int set_uuid_from_dom(virDomainPt CMSetProperty(instance, "UUID", (CMPIValue *)uuid, CMPI_chars); + + *out_uuid = strdup(uuid); return 1; } @@ -239,17 +243,91 @@ static int set_creation_class(CMPIInstan return 1; } +static int set_other_id_info(const CMPIBroker *broker, + char *uuid, + const char *prefix, + CMPIInstance *instance) +{ + CMPIStatus s; + CMPIArray *id_info; + char *info[3]; + int count = 3; + char *type = "Virtual System"; + char *model; + int i; + + id_info = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + if (asprintf(&model, "%s%s", prefix, type) == 1) + return 0; + + info[0] = uuid; + info[1] = model; + info[2] = type; + + for (i = 0; i < count; i++) { + CMPIString *tmp = CMNewString(broker, info[i], NULL); + CMSetArrayElementAt(id_info, i, + &tmp, + CMPI_string); + } + + CMSetProperty(instance, "OtherIdentifyingInfo", + &id_info, CMPI_stringA); + + return 1; +} + +static int set_id_desc(const CMPIBroker *broker, + CMPIInstance *instance) +{ + CMPIStatus s; + CMPIArray *id_desc; + char *desc[3] = {"Type", "Model", "UUID"}; + int count = 3; + int i; + + id_desc = CMNewArray(broker, + count, + CMPI_string, + &s); + + if (s.rc != CMPI_RC_OK) + return 0; + + for (i = 0; i < count; i++) { + CMPIString *tmp = CMNewString(broker, desc[i], NULL); + CMSetArrayElementAt(id_desc, i, + &tmp, + CMPI_string); + } + + CMSetProperty(instance, "IdentifyingDescriptions", + (CMPIValue *)&id_desc, CMPI_stringA); + + return 1; +} + /* Populate an instance with information from a domain */ static int instance_from_dom(const CMPIBroker *broker, virDomainPtr dom, + const char *prefix, CMPIInstance *instance) { + char *uuid; + if (!set_name_from_dom(dom, instance)) { /* Print trace error */ return 0; } - if (!set_uuid_from_dom(dom, instance)) { + if (!set_uuid_from_dom(dom, instance, &uuid)) { /* Print trace error */ return 0; } @@ -269,7 +347,20 @@ static int instance_from_dom(const CMPIB return 0; } + if (!set_other_id_info(broker, uuid, prefix, instance)) { + /* Print trace error */ + free(uuid); + return 0; + } + + if (!set_id_desc(broker, instance)) { + /* Print trace error */ + return 0; + } + /* More attributes here, of course */ + + free(uuid); return 1; } @@ -294,7 +385,10 @@ CMPIInstance *instance_from_name(const C if (instance == NULL) goto out; - if (!instance_from_dom(broker, dom, instance)) + if (!instance_from_dom(broker, + dom, + pfx_from_conn(conn), + instance)) instance = NULL; out: @@ -327,7 +421,10 @@ int enum_domains(const CMPIBroker *broke if (inst == NULL) goto end; - if (instance_from_dom(broker, list[i], inst)) + if (instance_from_dom(broker, + list[i], + pfx_from_conn(conn), + inst)) inst_list_add(instlist, inst); end: