# Oper Data Handler: Nested dynamic elements not allowed

**URL:** <https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029>\
**Category:** CDB and CDB API\
**Created:** [February 20, 2017, 12:44pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029 "2017-02-20T12:44:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![key](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@key](https://dmap-community.ductus.global/u/key)\
**Post date:** [February 20, 2017, 12:44pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/1 "2017-02-20T12:44:12Z")

</div>

Our yang file contains nested list as shown below:

```
list protocol{
    key "name";
    tailf:callpoint "get-oper";
    leaf name; /* string type */
    leaf description; /* string type */

    list layer{
	key "name";
	tailf:callpoint "get-oper";
	leaf name; /* string type */ 
	leaf number; /* Uint32 type */ 
    }
 }

```

get\_object() is implemented as below:

```
static int get_object(struct confd_trans_ctx *tctx,
						confd_hkeypath_t *keypath)
{
	if(CONFD_GET_XMLTAG(&(keypath->v[1][0])) == layer) {
		confd_value_t v[2];
		CONFD_SET_STR(&v[0], "ip");
		CONFD_SET_INT32(&v[1], 3);
		confd_data_reply_value_array(tctx, v, 2);
    } else if(CONFD_GET_XMLTAG(&(keypath->v[1][0])) == protocol) {
		confd_value_t v[4];
		CONFD_SET_STR(&v[0], "ospf");
		CONFD_SET_STR(&v[1], "routing protocol");
		confd_data_reply_value_array(tctx, v, 2);
	}
	return CONFD_OK;
}

```

The below error is seen when the command is given from confd cli:

> 20-Feb-2017::17:21:28.435 ubuntu confd[3842]: devel-c get\_next request for callpoint ‘get-oper’ path /protocol  
> 20-Feb-2017::17:21:28.437 ubuntu confd[3842]: devel-c get\_next succeeded for callpoint ‘get-oper’ path /protocol  
> 20-Feb-2017::17:21:28.438 ubuntu confd[3842]: devel-c get\_object request for callpoint ‘get-oper’ path /protocol{ospf}  
> 20-Feb-2017::17:21:28.442 ubuntu confd[3842]: devel-c get\_object succeeded for callpoint ‘get-oper’ path /protocol{ospf}  
> 20-Feb-2017::17:21:28.442 ubuntu confd[3842]: devel-c bad get\_object() return value: /protocol{ospf}/layer: Missing value

After that, the second list “layer” entries are added to get\_object() and saw the below issue:

> 20-Feb-2017::17:21:28.435 ubuntu confd[3842]: devel-c get\_next request for callpoint ‘get-oper’ path /protocol  
> 20-Feb-2017::17:21:28.437 ubuntu confd[3842]: devel-c get\_next succeeded for callpoint ‘get-oper’ path /protocol  
> 20-Feb-2017::17:21:28.438 ubuntu confd[3842]: devel-c get\_object request for callpoint ‘get-oper’ path /protocol{ospf}  
> 20-Feb-2017::17:21:28.442 ubuntu confd[3842]: devel-c get\_object succeeded for callpoint ‘get-oper’ path /protocol{ospf}  
> 20-Feb-2017::17:21:28.442 ubuntu confd[3842]: devel-c bad get\_object() return value: /protocol{ospf}/layer: Nested dynamic elements not allowed

```
static int get_object(struct confd_trans_ctx *tctx,
						confd_hkeypath_t *keypath)
{
	if(CONFD_GET_XMLTAG(&(keypath->v[1][0])) == layer) {
		confd_value_t v[2];
		CONFD_SET_STR(&v[0], "ip");
		CONFD_SET_INT32(&v[1], 3);
		confd_data_reply_value_array(tctx, v, 2);
    } else if(CONFD_GET_XMLTAG(&(keypath->v[1][0])) == protocol) {
		confd_value_t v[4];
		CONFD_SET_STR(&v[0], "ospf");
		CONFD_SET_STR(&v[1], "routing protocol");
		CONFD_SET_STR(&v[2], "ip");
		CONFD_SET_INT32(&v[3], 3);
		confd_data_reply_value_array(tctx, v, 4);
	}
	return CONFD_OK;
}

```

Please let us know if the nested list is not supported for get\_object().  
Using confd-6.0.2 and the above yang and data provider code are the best approximation of original code.

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [February 20, 2017, 1:31pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/2 "2017-02-20T13:31:03Z")

</div>

> [@key](#):
>
> ```
> CONFD_SET_STR(&v[0], "ospf");
> CONFD_SET_STR(&v[1], "routing protocol");
> confd_data_reply_value_array(tctx, v, 2);
> 
> ```

Should be:

```auto
CONFD_SET_STR(&v[0], "ospf");
CONFD_SET_STR(&v[1], "routing protocol");
CONFD_SET_NOEXISTS(&v[2]);
confd_data_reply_value_array(tctx, v, 3);

```

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [February 20, 2017, 1:37pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/3 "2017-02-20T13:37:13Z")

</div>

this is described in more detail in the ConfD user guide and/or man page, relevant to **confd\_data\_reply\_value\_array()** procedure, more specifically, **XML STRUCTURES** / **Value Array** sub-sections:

> List nodes use a single array element, with type C\_NOEXISTS (value ignored), regardless of the actual number of entries or their contents.

As a response to get\_object() for “protocol” entry, we just need to tell ConfD there’s some list as a potential content of the object we’re returning - and it’s up to ConfD to get the specific nested contents as necessary (again, invoking further data provider callbacks).

---

<div class="post-metadata">

**Author:** ![key](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@key](https://dmap-community.ductus.global/u/key)\
**Post date:** [February 21, 2017, 12:03pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/4 "2017-02-21T12:03:16Z")

</div>

I tried your suggestion as listed below:  
confd\_value\_t v[4];  
CONFD\_SET\_STR(&v[0], “ospf”);  
CONFD\_SET\_STR(&v[1], “routing protocol”);  
CONFD\_SET\_STR(&v[2], “ip”);  
CONFD\_SET\_INT32(&v[3], 3);  
CONFD\_SET\_NOEXISTS(&v[4]);  
CONFD\_SET\_NOEXISTS(&v[5]);  
confd\_data\_reply\_value\_array(tctx, v, 6);

The devel.log shows below snippet:  
 15-Feb-2017::02:47:52.734 ubuntu confd[2615]: devel-c bad get\_object() return value: /protocols{ospf}: Too many values

---

<div class="post-metadata">

**Author:** ![key](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@key](https://dmap-community.ductus.global/u/key)\
**Post date:** [February 21, 2017, 12:06pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/5 "2017-02-21T12:06:07Z")

</div>

Please let me know

1. if the nested list with same callpoint is not supported for get\_object()
2. if i need to handle any extra conditions for these nested list with key

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [February 21, 2017, 1:30pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/6 "2017-02-21T13:30:41Z")

</div>

This is described in the previously referenced ConfD user guide section **XML structures** :

> The simpler format is an array of confd\_value\_t elements corresponding to the complete contents of a list entry or container. The content of sub-list entries cannot be represented. The array is populated through a “depth first” traversal of the data tree as follows.

So, when using **confd\_data\_reply\_value\_array()** , single get\_object() request is to service single specific list entry - you should NOT mix the different (even though nested) lists.  
ConfD will invoke subsequent callback (e.g. get\_object()) requests for internal lists.  
Pseudo code:

```
if (CONFD_GET_XMLTAG(&(keypath->v[1][0])) == layer) {
	confd_value_t v[2];
	CONFD_SET_STR(&v[0], ...); // name
	CONFD_SET_INT32(&v[1], ...); // number
	confd_data_reply_value_array(tctx, v, 2);
} else if (CONFD_GET_XMLTAG(&(keypath->v[1][0])) == protocol) {
	confd_value_t v[3];
	CONFD_SET_STR(&v[0], ...); // name
	CONFD_SET_STR(&v[1], ...); // description
	CONFD_SET_NOEXISTS(&v[2]); // "abstract" representation of "layer" list
	confd_data_reply_value_array(tctx, v, 3);
}

```

---

<div class="post-metadata">

**Author:** ![key](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@key](https://dmap-community.ductus.global/u/key)\
**Post date:** [February 24, 2017, 7:42am UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/7 "2017-02-24T07:42:58Z")

</div>

Thanks a lot for the inputs. This issue is resolved.

---

<div class="post-metadata">

**Author:** ![antonsou](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@antonsou](https://dmap-community.ductus.global/u/antonsou)\
**Post date:** [June 19, 2017, 6:38am UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/8 "2017-06-19T06:38:06Z")

</div>

Hi,

From the above examble, if the list layer has one more sublist say X. Then from the above response, i have send response like

if (CONFD\_GET\_XMLTAG(&(keypath-\>v[1][0])) == layer) {  
confd\_value\_t v[2];  
CONFD\_SET\_STR(&v[0], …); // name  
CONFD\_SET\_INT32(&v[1], …); // number  
confd\_data\_reply\_value\_array(tctx, v, 2);  
} else if (CONFD\_GET\_XMLTAG(&(keypath-\>v[1][0])) == protocol) {  
confd\_value\_t v[4];  
CONFD\_SET\_STR(&v[0], …); // name  
CONFD\_SET\_STR(&v[1], …); // description  
CONFD\_SET\_NOEXISTS(&v[2]); // “abstract” representation of “layer” list  
CONFD\_SET\_NOEXISTS(&v[3]); // “abstract” representation of “X” list  
confd\_data\_reply\_value\_array(tctx, v, 4);  
}

Receiving “Too many values” error

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [July 3, 2017, 8:45am UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/9 "2017-07-03T08:45:03Z")

</div>

your description & example code seem to not match - is the new list X the direct child node of “layer”, or “protocol”?

---

<div class="post-metadata">

**Author:** ![antonsou](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@antonsou](https://dmap-community.ductus.global/u/antonsou)\
**Post date:** [July 3, 2017, 10:41am UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/10 "2017-07-03T10:41:56Z")

</div>

yes, But now it is clear to me, We able to handle the situation by sending CONFD\_SET\_NOEXISTS for each immediate sublist.

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [July 3, 2017, 12:21pm UTC](https://dmap-community.ductus.global/t/oper-data-handler-nested-dynamic-elements-not-allowed/1029/11 "2017-07-03T12:21:36Z")

</div>

yes, only immediate/direct descendant lists need the “NOEXISTS” placeholder.  
great, glad to hear it’s working well.
