osaf/tools/safimm/immcfg/imm_cfg.c |  53 ++++++++++++++++++++++++++++++-------
 1 files changed, 42 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,8 @@ int object_create(const SaNameT **object
        const SaStringT* errStrings=NULL;
        SaImmClassCategoryT classCategory;
        SaImmAttrDefinitionT_2 **attrDefinitions = NULL;
+       SaImmAttrFlagsT flags=0;
+       SaBoolT attrAdded = SA_FALSE;
 
        if((error = saImmOmClassDescriptionGet_2(immHandle, className, 
&classCategory, &attrDefinitions)) != SA_AIS_OK) {
                fprintf(stderr, "error - saImmOmClassDescriptionGet_2. FAILED: 
%s\n", saf_error(error));
@@ -498,15 +507,37 @@ 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)){
+                       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++;
+                                       attrAdded = SA_TRUE;
+
+                                       free(attrValue->attrName);
+                                       free(attrValue->attrValues);
+                                       free(attrValue);
+                                       break;
+                               }               
+                               j++;
+                       }
+               } 
+               if(!attrAdded){
+
+                       attrValues = realloc(attrValues, (attr_len + 1) * 
sizeof(SaImmAttrValuesT_2 *));
+                       attrValues[attr_len - 1] = attrValue;
+                       attrValues[attr_len] = NULL;
+                       attr_len++;
+               }
+               attrAdded = SA_FALSE;
        }
 
        attrValues = realloc(attrValues, (attr_len + 1) * 
sizeof(SaImmAttrValuesT_2 *));
@@ -560,7 +591,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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to