[PATCH 0 of 2] Correctly place the ValueRole, ValueRange, and PropertyPolicy attributes

This set (which includes my previous patch) creates a reference function to set the mentioned attributes on the SDC reference, as well as removing the code to set the on the RASD.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1209667695 25200 # Node ID db6526d1cb9c15334a73c25ab6e5fb511855013a # Parent d4ea8516ae04a2e3ab0060f297035b107b59b81d Add the ValueRole to the SDC reference This extends the default make_reference() function to set the proper ValueRole and ValueRange properties for the AC->RASD reference. Changes: - Add in PropertyPolicy Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r d4ea8516ae04 -r db6526d1cb9c src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu May 01 10:45:16 2008 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Thu May 01 11:48:15 2008 -0700 @@ -1063,6 +1063,52 @@ static CMPIStatus vsmsd_to_migrate_cap(c return s; } +static CMPIInstance *make_ref_valuerole(const CMPIObjectPath *source_ref, + const CMPIInstance *target_inst, + struct std_assoc_info *info, + struct std_assoc *assoc) +{ + CMPIInstance *ref_inst = NULL; + uint16_t valuerole = SDC_ROLE_SUPPORTED; + uint16_t valuerange; + uint16_t ppolicy = SDC_POLICY_INDEPENDENT; + const char *iid = NULL; + + ref_inst = make_reference(_BROKER, + source_ref, + target_inst, + info, + assoc); + + if (cu_get_str_prop(target_inst, "InstanceID", &iid) != CMPI_RC_OK) { + CU_DEBUG("Target instance does not have an InstanceID"); + goto out; + } + + if (strstr("Default", iid) != NULL) + valuerange = SDC_RANGE_POINT; + else if (strstr("Increment", iid) != NULL) + valuerange = SDC_RANGE_INC; + else if (strstr("Maximum", iid) != NULL) + valuerange = SDC_RANGE_MAX; + else if (strstr("Minimum", iid) != NULL) + valuerange = SDC_RANGE_MIN; + else + CU_DEBUG("Unknown default RASD type: `%s'", iid); + + if (valuerange == SDC_RANGE_POINT) + valuerole = SDC_ROLE_DEFAULT; + + CMSetProperty(ref_inst, "ValueRole", + (CMPIValue *)&valuerole, CMPI_uint16); + CMSetProperty(ref_inst, "ValueRange", + (CMPIValue *)&valuerange, CMPI_uint16); + CMSetProperty(ref_inst, "PropertyPolicy", + (CMPIValue *)&ppolicy, CMPI_uint16); + out: + return ref_inst; +} + LIBVIRT_CIM_DEFAULT_MAKEREF() static char* group_component[] = { @@ -1105,7 +1151,7 @@ static struct std_assoc _alloc_cap_to_ra .assoc_class = (char**)&assoc_classname, .handler = alloc_cap_to_rasd, - .make_ref = make_ref + .make_ref = make_ref_valuerole }; static struct std_assoc _rasd_to_alloc_cap = {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1209667697 25200 # Node ID 122027a2c63e875939492ec0c7f39299ca6fed25 # Parent db6526d1cb9c15334a73c25ab6e5fb511855013a Remove incorrectly-placed ValueRole/ValueRange in RASDs from AC::SDC Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r db6526d1cb9c -r 122027a2c63e src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu May 01 11:48:15 2008 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Thu May 01 11:48:17 2008 -0700 @@ -856,10 +856,6 @@ static CMPIInstance *sdc_rasd_inst(const const char *inst_id = NULL; const char *base = NULL; uint16_t resource_type; - /* Defaults for the following are from - CIM_SettingsDefineCapabilities.mof. */ - uint16_t policy = SDC_POLICY_INDEPENDENT; - uint16_t role = SDC_ROLE_SUPPORTED; switch(type) { case SDC_RASD_MIN: @@ -867,29 +863,24 @@ static CMPIInstance *sdc_rasd_inst(const goto out; prop_list = rasd->min(ref, s); inst_id = "Minimum"; - range = SDC_RANGE_MIN; break; case SDC_RASD_MAX: if (rasd->max == NULL) goto out; prop_list = rasd->max(ref, s); inst_id = "Maximum"; - range = SDC_RANGE_MAX; break; case SDC_RASD_INC: if (rasd->inc == NULL) goto out; prop_list = rasd->inc(ref, s); inst_id = "Increment"; - range = SDC_RANGE_INC; break; case SDC_RASD_DEF: if (rasd->def == NULL) goto out; prop_list = rasd->def(ref, s); inst_id = "Default"; - role = SDC_ROLE_DEFAULT; - range = SDC_RANGE_POINT; break; default: cu_statusf(broker, s, @@ -913,9 +904,6 @@ static CMPIInstance *sdc_rasd_inst(const NAMESPACE(ref)); CMSetProperty(inst, "InstanceID", inst_id, CMPI_chars); - CMSetProperty(inst, "PropertyPolicy", &policy, CMPI_uint16); - CMSetProperty(inst, "ValueRole", &role, CMPI_uint16); - CMSetProperty(inst, "ValueRange", &range, CMPI_uint16); resource_type = rasd->resource_type; CMSetProperty(inst, "ResourceType", &resource_type, CMPI_uint16);

Dan Smith wrote:
This set (which includes my previous patch) creates a reference function to set the mentioned attributes on the SDC reference, as well as removing the code to set the on the RASD.
+1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert