
# HG changeset patch # User Jay Gagnon <grendel@linux.vnet.ibm.com> # Date 1194557532 18000 # Node ID cf0a2938ba0b9d2e7af8a5790d0e56cc7564df73 # Parent 2d09468e2de7ed9194907bfff1efbb16ba40202d Add another relationship to ElementCapabilities, the ResourcePool-AllocationCapabilities connection. Only supports the pool_to_alloc direction, because it is the only one that's terribly interesting, but the other direction will need to be added at some point. Signed-off-by: Jay Gagnon <grendel@linux.vnet.ibm.com> diff -r 2d09468e2de7 -r cf0a2938ba0b src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Thu Nov 08 16:30:43 2007 -0500 +++ b/src/Virt_ElementCapabilities.c Thu Nov 08 16:32:12 2007 -0500 @@ -179,6 +179,50 @@ static CMPIStatus cap_to_cs(const CMPIOb return s; } +static CMPIStatus alloc_to_pool(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + /* Pool to alloc is more important. That will be done first. */ + return (CMPIStatus){CMPI_RC_OK, NULL}; +} + +static CMPIStatus pool_to_alloc(const CMPIObjectPath *ref, + struct std_assoc_info *info, + struct inst_list *list) +{ + int ret; + char *inst_id; + uint16_t type; + CMPIInstance *inst = NULL; + CMPIStatus s = {CMPI_RC_OK}; + + inst_id = cu_get_str_path(ref, "InstanceID"); + if (inst_id == NULL) { + CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, + "Could not get InstanceID."); + goto out; + } + + inst = get_typed_instance(_BROKER, "AllocationCapabilities", + NAMESPACE(ref)); + CMSetProperty(inst, "InstanceID", inst_id, CMPI_chars); + + ret = cu_get_u16_path(ref, "ResourceType", &type); + if (ret != 1) { + CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, + "Could not get ResourceType."); + goto out; + } + CMSetProperty(inst, "ResourceType", &type, CMPI_uint16); + + inst_list_add(list, inst); + + out: + free(inst_id); + + return s; +} static CMPIInstance *make_ref(const CMPIObjectPath *ref, const CMPIInstance *inst, struct std_assoc_info *info, @@ -273,6 +317,28 @@ struct std_assoc ele_cap_to_computer_sys .assoc_class = "CIM_ElementCapabilities", .handler = cap_to_cs, + .make_ref = make_ref +}; + +struct std_assoc alloc_cap_to_resource_pool = { + .source_class = "CIM_AllocationCapabilities", + .source_prop = "Capabilities", + + .target_class = "CIM_ResourcePool", + .target_prop = "ManagedElement", + + .handler = alloc_to_pool, + .make_ref = make_ref +}; + +struct std_assoc resource_pool_to_alloc_cap = { + .source_class = "CIM_ResourcePool", + .source_prop = "ManagedElement", + + .target_class = "CIM_AllocationCapabilities", + .target_prop = "Capabilities", + + .handler = pool_to_alloc, .make_ref = make_ref }; @@ -282,6 +348,8 @@ struct std_assoc *assoc_handlers[] = { &system_to_vsm_cap, &vsm_cap_to_system, &ele_cap_to_computer_system, + &alloc_cap_to_resource_pool, + &resource_pool_to_alloc_cap, NULL };