Python format for returning a list output for confd action

Hi,
My confd action model returns an output which is a list :slight_smile:
output {
list outlist {
leaf A {
type string;
}
leaf B{
type string;
}
}

My callpoint is implemented in Python.

I have returned data when the output is a single leaf using something like this
result = [_confd.TagValue(_confd.XmlTag(ns_hash, tag),
_confd.Value(value))]
dp.action_reply_values(self.uinfo, result)

I am not able to figure out how to do it for returning the data in the list format.

Thanking you.

For Python API related questions, it is best to file RT tickets with our support team.

@waitai 's recommendation is correct, best to file an RT ticket with support.

Quick pseudo code hint based on your pseudo code:

result = [
        _confd.TagValue(_confd.XmlTag(ns_hash, outlist_tag),
                 _confd.Value(_confd.C_XMLBEGIN)
                 ),
        _confd.TagValue(_confd.XmlTag(ns_hash, A_tag),
                 _confd.Value(value)),
	_confd.TagValue(_confd.XmlTag(ns_hash, B_tag),
                 _confd.Value(value)),
        _confd.TagValue(_confd.XmlTag(ns_hash, outlist_tag),
                 _confd.Value(_confd.C_XMLEND)
                 )
    ]

Thanks for the solution.

The XML tags worked when called with the following format.
begin_tag = _confd.TagValue(_confd.XmlTag(ns_hash,outlist_tag),_confd.Value((outlist_tag,ns_hash),_confd.C_XMLBEGIN))
result.append(begin_tag)
.
.
.
.

_confd.TagValue(_confd.XmlTag(ns_hash,outlist_tag),_confd.Value((outlist_tag,ns_hash),_confd.C_XMLEND))
result.append(begin_tag)

Thanks again.

Hi, We are facing similar problem to show some values in a list. We are using Python 2.7. Simply while calling, confd.XmlTag, getting error.
ns.hash ( It is integer with hash value)
outlist_tag = ns.configuration_result (it is string which is tag name โ€œresultโ€)

_confd.XmlTag(ns.hash,outlist_tag)

Error is: Config manager: Unable to perform config operation: an integer is required

If giving hash value for result tag (i.e.: 401396173) , it works, but output is integer and meaningless.
This is what is in the list of output:
[_confd.TagValue(tag=401396173, ns=1550764805), _confd.TagValue(tag=1998270519, ns=1550764805), _confd.TagValue(tag=1714291735, ns=1550764805), _confd.TagValue(tag=401396173, ns=1550764805), _confd.TagValue(tag=401396173, ns=1550764805), _confd.TagValue(tag=1998270519, ns=1550764805), _confd.TagValue(tag=1714291735, ns=1550764805), _confd.TagValue(tag=401396173, ns=1550764805)]

Any idea? Thanks in advance.

The corrected pseudo code based on the reply from @Srijit:

result = [
    _confd.TagValue(_confd.XmlTag(ns_hash, outlist_tag),
                               _confd.Value((outlist_tag,ns_hash),_confd.C_XMLBEGIN)),
    _confd.TagValue(_confd.XmlTag(ns_hash, A_tag),
                               _confd.Value(value, _confd.C_STR)),
    _confd.TagValue(_confd.XmlTag(ns_hash, B_tag),
                               _confd.Value(value, _confd.C_STR)),
    _confd.TagValue(_confd.XmlTag(ns_hash, outlist_tag),
                               _confd.Value((outlist_tag,ns_hash),_confd.C_XMLEND))
]

Note that it is a good habit to enter the type for the value too, even though it is not required for a string type.