Hi again,
Here's an example for the problem I mentioned
root@SC-1:~# immlist -c Test
<< Test - CONFIG >>
test : SA_STRING_T [1] {RDN, CONFIG, INITIALIZED}
multi2 : SA_UINT32_T [0..*] = Empty {CONFIG, WRITEABLE, MULTI_VALUE}
multi1 : SA_UINT32_T [0..*] = Empty {CONFIG, WRITEABLE, MULTI_VALUE}
root@SC-1:~# immcfg -c Test -a multi1=1 -a multi1=2 -a multi2=3 -a multi2=4
test=1
root@SC-1:~# immlist test=1
Name Type Value(s)
========================================================================
test SA_STRING_T test=1
*multi2 SA_UINT32_T <Empty>*
multi1 SA_UINT32_T 1 (0x1)2 (0x2)
The values for 'multi2' attribute were not added.
BR,
Hung Nguyen - DEK Technologies
--------------------------------------------------------------------------------
From: Hung Nguyen [email protected]
Sent: Tuesday, January 19, 2016 4:06PM
To: Neelakanta Reddy, Zoran Milinkovic
[email protected], [email protected]
Cc: Opensaf-devel
[email protected]
Subject: Re: [PATCH 1 of 1] immtool: immcfg allows creation of multiple values
for multi attributesa[#1626]
Hi Neel,
Please find my comments inline.
BR,
Hung Nguyen - DEK Technologies
--------------------------------------------------------------------------------
From: Neelakanta [email protected]
Sent: Tuesday, January 19, 2016 12:34PM
To: Zoran Milinkovic, Hung Nguyen
[email protected],[email protected]
Cc: Opensaf-devel
[email protected]
Subject: [PATCH 1 of 1] immtool: immcfg allows creation of multiple values for
multi attributesa[#1626]
osaf/tools/safimm/immcfg/imm_cfg.c | 48 +++++++++++++++++++++++++++++--------
1 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c
b/osaf/tools/safimm/immcfg/imm_cfg.c
--- a/osaf/tools/safimm/immcfg/imm_cfg.c
+++ b/osaf/tools/safimm/immcfg/imm_cfg.c
@@ -150,6 +150,8 @@ static void usage(const char *progname)
printf("\t\tchange one attribute for one object\n");
printf("\timmcfg -c SaAmfApplication -a saAmfAppType=Test
safApp=myTestApp1\n");
printf("\t\tcreate one object setting one initialized attribute\n");
+ printf("\timmcfg -c class -a attrMulti=one -a attrMulti=two obj=1\n");
+ printf("\t\tcreate object with multiple values for MULTI_VALUE
attribute\n");
printf("\timmcfg -d safAmfNode=Node01,safAmfCluster=1\n");
printf("\t\tdelete one object\n");
printf("\timmcfg -d safAmfNode=Node01,safAmfCluster=1
safAmfNode=Node02,safAmfCluster=1\n");
@@ -387,20 +389,24 @@ static SaImmAttrModificationT_2 *new_att
return attrMod;
}
-static SaAisErrorT get_attrValueType(SaImmAttrDefinitionT_2 **attrDefinitions,
SaImmAttrNameT attrName, SaImmValueTypeT *attrValueType) {
+static SaAisErrorT get_attrValueType(SaImmAttrDefinitionT_2 **attrDefinitions,
SaImmAttrNameT attrName,
+ SaImmValueTypeT *attrValueType, SaImmAttrFlagsT * flags) {
if(!attrDefinitions || !attrName)
return SA_AIS_ERR_NOT_EXIST;
int i=0;
while(attrDefinitions[i]) {
if(!strcmp(attrDefinitions[i]->attrName, attrName)) {
- if(attrValueType)
+ if(attrValueType){
*attrValueType =
attrDefinitions[i]->attrValueType;
+ if(flags){
+ *flags = attrDefinitions[i]->attrFlags;
+ }
+ }
return SA_AIS_OK;
}
i++;
}
-
return SA_AIS_ERR_NOT_EXIST;
}
@@ -412,7 +418,8 @@ static SaAisErrorT get_attrValueType(SaI
*
* @return SaImmAttrValuesT_2*
*/
-static SaImmAttrValuesT_2 *new_attr_value(SaImmAttrDefinitionT_2
**attrDefinitions, char *nameval, int isRdn)
+static SaImmAttrValuesT_2 *new_attr_value(SaImmAttrDefinitionT_2
**attrDefinitions, char *nameval, int isRdn,
+ SaImmAttrFlagsT * flags)
{
int res = 0;
char *name = strdup(nameval), *p;
@@ -435,7 +442,7 @@ static SaImmAttrValuesT_2 *new_attr_valu
name = NULL;
VERBOSE_INFO("new_attr_value attrValue->attrName: '%s' value:'%s'\n",
attrValue->attrName, isRdn ? nameval : value);
- error = get_attrValueType(attrDefinitions, attrValue->attrName,
&attrValue->attrValueType);
+ error = get_attrValueType(attrDefinitions, attrValue->attrName,
&attrValue->attrValueType, flags);
if (error != SA_AIS_OK) {
fprintf(stderr, "Attribute '%s' does not exist in class\n",
attrValue->attrName);
@@ -490,6 +497,7 @@ int object_create(const SaNameT **object
const SaStringT* errStrings=NULL;
SaImmClassCategoryT classCategory;
SaImmAttrDefinitionT_2 **attrDefinitions = NULL;
+ SaImmAttrFlagsT flags=0;
if((error = saImmOmClassDescriptionGet_2(immHandle, className,
&classCategory, &attrDefinitions)) != SA_AIS_OK) {
fprintf(stderr, "error - saImmOmClassDescriptionGet_2. FAILED:
%s\n", saf_error(error));
@@ -498,15 +506,33 @@ int object_create(const SaNameT **object
for (i = 0; i < optargs_len; i++) {
VERBOSE_INFO("object_create optargs[%d]: '%s'\n", i,
optargs[i]);
- if ((attrValue = new_attr_value(attrDefinitions, optargs[i],
0)) == NULL){
+ if ((attrValue = new_attr_value(attrDefinitions, optargs[i], 0,
&flags)) == NULL){
fprintf(stderr, "error - creating attribute from
'%s'\n", optargs[i]);
goto done;
}
- attrValues = realloc(attrValues, (attr_len + 1) *
sizeof(SaImmAttrValuesT_2 *));
- attrValues[attr_len - 1] = attrValue;
- attrValues[attr_len] = NULL;
- attr_len++;
+ if(attrValues && flags && SA_IMM_ATTR_MULTI_VALUE){
[Hung] & SA_IMM_ATTR_MULTI_VALUE (not &&)
+ int j=0;
+ while(attrValues[j]){
+ if(!strcmp(attrValue->attrName,
attrValues[j]->attrName)){
+ attrValues[j]->attrValues =
realloc(attrValues[j]->attrValues,
+
(attrValues[j]->attrValuesNumber+1) * sizeof(SaImmAttrValueT *));
+
attrValues[j]->attrValues[attrValues[j]->attrValuesNumber] =
attrValue->attrValues[0];
+ attrValues[j]->attrValuesNumber++;
+
+ free(attrValue->attrName);
+ free(attrValue->attrValues);
+ free(attrValue);
+ }
+ j++;
+ }
[Hung] What if we can't find the matching attribute here? If we have
more than one attributes defined as ATTR_MULTI_VALUE, the patch will not
work. When the 'for' loop goes to second MULTI_VALUE attribute,
attrValues will not be re-allocated for that attribute.
+ } else {
+
+ attrValues = realloc(attrValues, (attr_len + 1) *
sizeof(SaImmAttrValuesT_2 *));
+ attrValues[attr_len - 1] = attrValue;
+ attrValues[attr_len] = NULL;
+ attr_len++;
+ }
}
attrValues = realloc(attrValues, (attr_len + 1) *
sizeof(SaImmAttrValuesT_2 *));
@@ -560,7 +586,7 @@ int object_create(const SaNameT **object
}
VERBOSE_INFO("object_create rdn attribute attrValues[%d]: '%s'
\n", attr_len - 1, str);
- if ((attrValue = new_attr_value(attrDefinitions, str, 1)) ==
NULL){
+ if ((attrValue = new_attr_value(attrDefinitions, str, 1, NULL))
== NULL){
fprintf(stderr, "error - creating rdn attribute from
'%s'\n", str);
goto done;
}
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel