[Libvirt-cim] [PATCH 07 of 12] HS: Adoption of changes to std_assoc struct in std_association

Heidi Eckhart heidieck at linux.vnet.ibm.com
Fri Nov 30 09:43:36 UTC 2007


# HG changeset patch
# User Heidi Eckhart <heidieck at linux.vnet.ibm.com>
# Date 1196416046 -3600
# Node ID 7ed5aecb4249c6d18b412262ab0362c220b4f95e
# Parent  8a75970ed83c888e50b7b83360078c8ab32316db
HS: Adoption of changes to std_assoc struct in std_association

This is the follow up patch to the API changes made in
std_association. The struct std_assoc does now take lists
for source, target and assoc classnames.
Signed-off-by: Heidi Eckhart <heidieck at linux.vnet.ibm.com>

diff -r 8a75970ed83c -r 7ed5aecb4249 src/Virt_HostedService.c
--- a/src/Virt_HostedService.c	Thu Nov 29 13:33:17 2007 +0100
+++ b/src/Virt_HostedService.c	Fri Nov 30 10:47:26 2007 +0100
@@ -81,16 +81,17 @@ static CMPIInstance *make_ref(const CMPI
                               struct std_assoc_info *info,
                               struct std_assoc *assoc)
 {
+        CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIInstance *refinst = NULL;
-        char *base;
+        virConnectPtr conn = NULL;
 
-        base = class_base_name(assoc->assoc_class);
-        if (base == NULL)
-                goto out;
+        conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
+        if (conn == NULL)
+                return NULL;
 
         refinst = get_typed_instance(_BROKER,
-                                     CLASSNAME(ref),
-                                     base,
+                                     pfx_from_conn(conn),
+                                     "HostedService",
                                      NAMESPACE(ref));
 
         if (refinst != NULL) {
@@ -101,67 +102,60 @@ static CMPIInstance *make_ref(const CMPI
                 set_reference(assoc, refinst, ref, instop);
         }
 
-out:
+        virConnectClose(conn);
+
         return refinst;
 }
 
-static struct std_assoc xen_host_to_service = {
-        .source_class = "Xen_HostSystem",
+char* antecedent[] = {  
+        "Xen_HostSystem",
+        "KVM_HostSystem",
+        NULL
+};
+
+char* dependent[] = {
+        "Xen_ResourcePoolConfigurationService",
+        "Xen_VirtualSystemManagementService",
+        "KVM_ResourcePoolConfigurationService",
+        "KVM_VirtualSystemManagementService",
+        NULL
+};
+
+char* assoc_classname[] = {
+        "Xen_HostedService",
+        "KVM_HostedService",        
+        NULL
+};
+
+static struct std_assoc _host_to_service = {
+        .source_class = (char**)&antecedent,
         .source_prop = "Antecedent",
 
-        .target_class = "CIM_ManagedElement",
+        .target_class = (char**)&dependent,
         .target_prop = "Dependent",
 
-        .assoc_class = "CIM_HostedService",
+        .assoc_class = (char**)&assoc_classname,
 
         .handler = host_to_service,
         .make_ref = make_ref
 };
 
-static struct std_assoc xen_service_to_host = {
-        .source_class = "CIM_Service",
+static struct std_assoc _service_to_host = {
+        .source_class = (char**)&dependent,
         .source_prop = "Dependent",
-
-        .target_class = "CIM_ManagedElement",
+        
+        .target_class = (char**)&antecedent,
         .target_prop = "Antecedent",
 
-        .assoc_class = "CIM_HostedService",
-
-        .handler = service_to_host,
-        .make_ref = make_ref
-};
-
-static struct std_assoc kvm_host_to_service = {
-        .source_class = "KVM_HostSystem",
-        .source_prop = "Antecedent",
-
-        .target_class = "CIM_Service",
-        .target_prop = "Dependent",
-
-        .assoc_class = "CIM_HostedService",
-
-        .handler = host_to_service,
-        .make_ref = make_ref
-};
-
-static struct std_assoc kvm_service_to_host = {
-        .source_class = "CIM_Service",
-        .source_prop = "Dependent",
-
-        .target_class = "KVM_ComputerSystem",
-        .target_prop = "Antecedent",
-
-        .assoc_class = "CIM_HostedService",
-
+        .assoc_class = (char**)&assoc_classname,
+        
         .handler = service_to_host,
         .make_ref = make_ref
 };
 
 static struct std_assoc *handlers[] = {
-        &xen_host_to_service,
-        &xen_service_to_host,
-        &kvm_host_to_service,
-        &kvm_service_to_host,
+        &_host_to_service,
+        &_service_to_host,
         NULL
 };
 




More information about the Libvirt-cim mailing list