ConfD User Community

Python maapi dry-run

Have used NCS before and used dry run api. Can’t find a method for that in confd. I currently use the confd basic version 7.2.1. If there is no support in basic is it supported in premium?
NCS config:
outputResult = t.request_action_str_th(‘services commit-dry-run outformat native’,
‘/ncs:services/commit-dry-run’)

Code below works fine but would need the dry run (as in NCS above) to check if my cmdb inventory is in sync with confd db. Or put in another way, would like to have a method checking if my settings change the confd db, i.e. a convenient diff function.

import confd

with confd.maapi.Maapi() as m:
    with confd.maapi.Session(m, 'admin', 'python'):
        with m.start_read_trans() as t:
            root = confd.maagic.get_root(t)
            #print(root.l2domain.name)
            for name in root.l2domain:
                print(name.name)
                print(name.icl)


with confd.maapi.Maapi() as m:
    with confd.maapi.Session(m, 'admin', 'python'):
        with m.start_write_trans() as t:
            root = confd.maagic.get_root(t)
            root.l2domain.create('VSW_test3')
            root.l2domain['VSW_test3'].icl = 'ae0.2345'
            t.apply()

No. The dry-run concept in NSO/NCS doesn’t apply to ConfD, since it is supposed to answer the question “what changes will be done to which managed device?”, and ConfD doesn’t have “managed devices” - it is intended to be used on the devices that NSO or some other orchestrator manages.

To find out what changes to the running data store your current maapi-initiated transaction would incur if committed, you can use the C API function maapi_diff_iterate() - there “should” be an equivalent for the Python API, but I can’t find it at the moment.

It’s not obvious to me why you need this functionality (other than for a human-interactive interface such as the CLI) though - you could just commit the transaction. If there are no changes, it will effectively be a no-op.