[Libvirt-cim] [PATCH] Add SystemCreationClassName and CreationClassName for SwitchService

Sharad Mishra snmishra at us.ibm.com
Tue Mar 15 17:20:26 UTC 2011


# HG changeset patch
# User Sharad Mishra <snmishra at us.ibm.com>
# Date 1300209608 25200
# Node ID 5e06c520e09e7bada9b851a46c78bb96b947614c
# Parent  c5239e6e1fef9bfd74e0adca2da5f15e9fe2e734
Add SystemCreationClassName and CreationClassName for SwitchService

Added above two properties to SwitchService provider.

Signed-off-by: Sharad Mishra <snmishra at us.ibm.com>

diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_Device.c
--- a/src/Virt_Device.c	Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_Device.c	Tue Mar 15 10:20:08 2011 -0700
@@ -77,7 +77,7 @@
                 return 0;
 
         str = CMNewString(broker, dev->mac, &s);
-        if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str)))
+        if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str)))
                 return 0;
 
         CMSetArrayElementAt(array, 0, &str, CMPI_string);
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_HostSystem.c
--- a/src/Virt_HostSystem.c	Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_HostSystem.c	Tue Mar 15 10:20:08 2011 -0700
@@ -101,7 +101,7 @@
         char hostname[256] = {0};
 
         op = CMGetObjectPath(instance, &s);
-        if ((s.rc == CMPI_RC_OK) || !CMIsNullObject(op)) {
+        if ((s.rc == CMPI_RC_OK) && !CMIsNullObject(op)) {
                 CMSetProperty(instance, "CreationClassName",
                               (CMPIValue *)CLASSNAME(op), CMPI_chars);
         }
@@ -109,6 +109,7 @@
         if (get_fqdn(hostname, sizeof(hostname)) != 0)
                 strcpy(hostname, "unknown");
 
+        CU_DEBUG("hostname is %s", hostname);
         CMSetProperty(instance, "Name",
                       (CMPIValue *)hostname, CMPI_chars);
         
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c	Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_SettingsDefineCapabilities.c	Tue Mar 15 10:20:08 2011 -0700
@@ -1598,7 +1598,7 @@
                         }
 
                         str = CMNewString(_BROKER, dev_path, &s);
-                        if ((s.rc = CMPI_RC_OK) || (CMIsNullObject(str))) {
+                        if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(str))) {
                                 cu_statusf(_BROKER, &s,
                                            CMPI_RC_ERR_FAILED,
                                            "Unable to create new string");
diff -r c5239e6e1fef -r 5e06c520e09e src/Virt_SwitchService.c
--- a/src/Virt_SwitchService.c	Mon Mar 14 08:04:37 2011 -0700
+++ b/src/Virt_SwitchService.c	Tue Mar 15 10:20:08 2011 -0700
@@ -34,6 +34,7 @@
 
 #include "misc_util.h"
 #include "config.h"
+#include "Virt_HostSystem.h"
 
 #define MAX_LEN 512
 #define CMD "/sbin/ifconfig -a | /bin/grep eth | /bin/awk '{print$1}'"
@@ -149,6 +150,41 @@
         return arr;
 }
 
+static CMPIStatus set_inst_properties(const CMPIBroker *broker,
+                                      const CMPIContext *context,
+                                      const CMPIObjectPath *reference,
+                                      CMPIInstance *inst)
+{
+        CMPIStatus s = {CMPI_RC_OK, NULL};
+        const char *name = NULL;
+        const char *ccname = NULL;
+
+        s = get_host_system_properties(&name,
+                                       &ccname,
+                                       reference,
+                                       broker,
+                                       context);
+        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 *)"Switch Virtualization Capabilities", 
+                      CMPI_chars);
+
+        CMSetProperty(inst, "SystemName",
+                      (CMPIValue *)name, CMPI_chars);
+
+        CMSetProperty(inst, "SystemCreationClassName",
+                      (CMPIValue *)ccname, CMPI_chars);
+
+ out:
+        return s;
+}
+
 static CMPIStatus get_switchservice(const CMPIObjectPath *reference,
                          CMPIInstance **_inst,
                          const CMPIBroker *broker,
@@ -188,10 +224,12 @@
                 goto out;
         }
 
-        CMSetProperty(inst, "Name",
-                      (CMPIValue *)"Switch Virtualization Capabilities", 
-                      CMPI_chars);
-    
+        s = set_inst_properties(broker, context, reference, inst);
+        if (s.rc != CMPI_RC_OK) { 
+                CU_DEBUG("Failed to set instance properties");
+                goto out;
+        }
+
         if_list = run_command(CMD, &count, &s);
         if (if_list == 0) {
                 CU_DEBUG("Failed to get network interfaces");




More information about the Libvirt-cim mailing list