[PATCH 0 of 4] #2 Fix NULL attributes returned by VSMigrationService.

Updates: Add function to Virt_HostSystem that gets the values for the Name and CreationClassName attributes of the host instance. Modify VSMgmtService so that it uses this function. Get the values for the SystemName and SystemCreationClassName from the host instance and set accordingly.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1197915789 28800 # Node ID e147f8dd86aa3422d81610b5d9e659f7f5aada70 # Parent 72b93a4339e1c13080d6a6d80a580a7742c0b851 Add function to HostSystem that returns the host instance attribute values. Add get_host_system_properties(const char *name, const char *ccname) which gets the Name and the CreationClassName attributes from the host instance. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 72b93a4339e1 -r e147f8dd86aa src/Virt_HostSystem.c --- a/src/Virt_HostSystem.c Fri Dec 14 10:37:01 2007 +0100 +++ b/src/Virt_HostSystem.c Mon Dec 17 10:23:09 2007 -0800 @@ -110,6 +110,36 @@ static CMPIStatus return_host_cs(const C return s; } +CMPIStatus get_host_system_properties(const char **name, + const char **ccname, + const CMPIObjectPath *ref, + const CMPIBroker *broker) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *host = NULL; + + s = get_host_cs(broker, ref, &host); + if (s.rc != CMPI_RC_OK) + goto out; + + if (cu_get_str_prop(host, "Name", name) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get name of HostSystem"); + goto out; + } + + if (cu_get_str_prop(host, "CreationClassName", ccname) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get creation class of HostSystem"); + goto out; + } + + out: + return s; +} + static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, diff -r 72b93a4339e1 -r e147f8dd86aa src/Virt_HostSystem.h --- a/src/Virt_HostSystem.h Fri Dec 14 10:37:01 2007 +0100 +++ b/src/Virt_HostSystem.h Mon Dec 17 10:23:09 2007 -0800 @@ -25,4 +25,8 @@ CMPIStatus get_host_cs(const CMPIBroker const CMPIObjectPath *reference, CMPIInstance **instance); +CMPIStatus get_host_system_properties(const char **name, + const char **ccname, + const CMPIObjectPath *ref, + const CMPIBroker *broker); #endif

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1197915794 28800 # Node ID 77463a23a25e77b2dafc4f0a6723366ebd6961e1 # Parent e147f8dd86aa3422d81610b5d9e659f7f5aada70 Fix VSMigrationService NULL key attributes. The SystemCreationClassName and SystemName keys are NULL, these should be set. These values can be retrieved using get_host_system_properties(). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r e147f8dd86aa -r 77463a23a25e src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Dec 17 10:23:09 2007 -0800 +++ b/src/Virt_VSMigrationService.c Mon Dec 17 10:23:14 2007 -0800 @@ -36,6 +36,7 @@ #include <libcmpiutil/std_invokemethod.h> #include "Virt_VSMigrationService.h" +#include "Virt_HostSystem.h" #define CIM_JOBSTATE_STARTING 3 #define CIM_JOBSTATE_RUNNING 4 @@ -639,6 +640,8 @@ CMPIStatus get_migration_service(const C { CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *name = NULL; + const char *ccname = NULL; inst = get_typed_instance(broker, CLASSNAME(ref), @@ -648,14 +651,34 @@ CMPIStatus get_migration_service(const C cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unable to get instance for %s", CLASSNAME(ref)); - return s; + goto out; + } + + s = get_host_system_properties(&name, + &ccname, + ref, + broker); + if (s.rc != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; } CMSetProperty(inst, "Name", (CMPIValue *)"MigrationService", CMPI_chars); + CMSetProperty(inst, "SystemName", + (CMPIValue *)name, CMPI_chars); + + CMSetProperty(inst, "SystemCreationClassName", + (CMPIValue *)ccname, CMPI_chars); + + CMSetStatus(&s, CMPI_RC_OK); + *_inst = inst; + out: return s; }

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1197681910 28800 # Node ID cec8c353e72fe13f9485afcd73afa7f4c4e76776 # Parent 77463a23a25e77b2dafc4f0a6723366ebd6961e1 Add libVirt_HostSystem to VSMigrationService build. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 77463a23a25e -r cec8c353e72f src/Makefile.am --- a/src/Makefile.am Mon Dec 17 10:23:14 2007 -0800 +++ b/src/Makefile.am Fri Dec 14 17:25:10 2007 -0800 @@ -146,4 +146,7 @@ libVirt_ElementSettingData_la_LIBADD = - libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c -libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c \ No newline at end of file +libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la +libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c +libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1197915820 28800 # Node ID d6cf74b64c720d65da17bdac2604f7d0f1d31f7e # Parent cec8c353e72fe13f9485afcd73afa7f4c4e76776 Use get_host_system_properties() in VSMgmtService to get attributes. Use get_host_system_properties() to get the host attributes. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r cec8c353e72f -r d6cf74b64c72 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Fri Dec 14 17:25:10 2007 -0800 +++ b/src/Virt_VirtualSystemManagementService.c Mon Dec 17 10:23:40 2007 -0800 @@ -1125,8 +1125,8 @@ CMPIStatus get_vsms(const CMPIObjectPath { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - CMPIInstance *host = NULL; - const char *val = NULL; + const char *name = NULL; + const char *ccname = NULL; virConnectPtr conn = NULL; *_inst = NULL; @@ -1134,10 +1134,6 @@ CMPIStatus get_vsms(const CMPIObjectPath if (conn == NULL) return s; - s = get_host_cs(broker, reference, &host); - if (s.rc != CMPI_RC_OK) - goto out; - inst = get_typed_instance(broker, pfx_from_conn(conn), "VirtualSystemManagementService", @@ -1151,28 +1147,25 @@ CMPIStatus get_vsms(const CMPIObjectPath goto out; } + s = get_host_system_properties(&name, + &ccname, + reference, + broker); + if (s.rc != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get host attributes"); + goto out; + } + CMSetProperty(inst, "Name", (CMPIValue *)"Management Service", CMPI_chars); - if (cu_get_str_prop(host, "Name", &val) != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Unable to get name of HostSystem"); - goto out; - } - CMSetProperty(inst, "SystemName", - (CMPIValue *)val, CMPI_chars); - - if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Unable to get creation class of HostSystem"); - goto out; - } + (CMPIValue *)name, CMPI_chars); CMSetProperty(inst, "SystemCreationClassName", - (CMPIValue *)val, CMPI_chars); + (CMPIValue *)ccname, CMPI_chars); CMSetStatus(&s, CMPI_RC_OK);
participants (1)
-
Kaitlin Rupert