SNMP configuration state retrieval does not work as expected

Hi,

We set SNMP protocol version config by writing in the below yang path

        if maapi.exists(self.snmp.maapisock, tctx.th,
                '/oc-sys:system/snmp-server/config/protocol-version'):
            versions = maapi.get_elem(self.snmp.maapisock, tctx.th,
                    '/oc-sys:system/snmp-server/config/protocol-version').as_pyval()

            ## Iterate through all members of the leaf-list and for those
            ## that are not defined, mark that protocol-version to disabled
            for version in CONFD_TAG_TO_PROTOCOL_VERSION_STR:
                if version in versions:
                    maapi.set_elem(self.snmp.maapisock, tctx.th, V(True, _confd.C_BOOL),
                            '/confdConfig/snmpAgent/snmpVersions/{}'.format(
                                CONFD_TAG_TO_PROTOCOL_VERSION_STR[version]))
                else:
                    maapi.set_elem(self.snmp.maapisock, tctx.th, V(False, _confd.C_BOOL),
                            '/confdConfig/snmpAgent/snmpVersions/{}'.format(
                                CONFD_TAG_TO_PROTOCOL_VERSION_STR[version]))

while displaying the SNMP config state, using following code to get protocol version

      elif tag.tag == arc_oc_sys_aug_ns.ns.arc_oc_sys_aug_protocol_version:
            protocol_versions = []

            ## Retrieve all enabled protocol versions for the SNMP
            ## agent
            for version in PROTOCOL_VERSION_STR_TO_CONFD_TAG:
                if maapi.exists(self.snmp.maapisock, tctx.th,
                        '/tfcm:confd-state/tfcm:snmp/tfcm:version/tfcm:{}'.format(
                            version)):
                    protocol_versions.append(PROTOCOL_VERSION_STR_TO_CONFD_TAG[version])

            if knext < len(protocol_versions) - 1:
                key = []
                key.append(V(protocol_versions[knext + 1], _confd.C_ENUM_VALUE))
                dp.data_reply_next_key(tctx, key, knext + 1)
            else:
                dp.data_reply_next_key(tctx, None, 0)

The problem that I am seeing that if I configure snmp v2c and v3, config is getting applied, when i display the configured state. I always see only v2c (which is default).

I am just wondering if the configured snmp version is really getting reflected in /tfcm:confd-state/tfcm:snmp/tfcm:version/

any thoughts here?

The configured snmp version really should be reflected in /confd-state/snmp/version. But note it is reflected only after the transaction in which you configure /confdConfig/snmpAgent/snmpVersions has been committed; maybe this is the problem?

yes, looks like some error has stopped it getting committed. will check the error further. Thanks for the input.