If you have an openconfig setup like similar to this:
module: openconfig-network-instance
+--rw network-instances
+--rw network-instance* [name]
+--rw name -> ../config/name
+--rw config
| +--rw name? string
+--rw protocols
+--rw protocol* [identifier name]
+--rw identifier -> ../config/identifier
+--rw name -> ../config/name
+--rw config
| +--rw identifier? identityref
| +--rw name? string
+--rw isis
| +--rw levels
| | +--rw level* [level-number]
| | +--rw level-number -> ../config/level-number
| | +--rw config
| | | +--rw level-number? oc-isis-types:level-number
| | +--ro link-state-database
| | | +--ro lsp* [lsp-id]
| | | +--ro lsp-id -> ../state/lsp-id
| | | +--ro state
| | | | +--ro lsp-id? oc-isis-types:lsp-id
| | | +--ro tlvs
| | | | +--ro tlv* [type]
| | | | +--ro type -> ../state/type
| | | | +--ro state
| | | | | +--ro type? identityref
| | | | +--ro extended-ipv4-reachability
| | | | | +--ro prefixes
| | | | | +--ro prefix* [prefix]
| | | | | +--ro prefix -> ../state/prefix
| | | | | +--ro state
| | | | | | +--ro prefix? inet:ipv4-prefix
| | | | | +--ro subtlvs
| | | | | | +--ro subtlv* [type]
| | | | | | +--ro type -> ../state/type
| | | | | | +--ro state
| | | | | | | +--ro type? identityref
| | | | | | +--ro prefix-sids
| | | | | | +--ro prefix-sid* [value]
| | | | | | +--ro value -> ../state/value
| | | | | | +--ro state
| | | | | | +--ro value? uint32
| | | | | | +--ro flags* enumeration
| | | | | | +--ro algorithm? uint8
The easiest way to add configuration and operational state data is to use an XML file similar to this one (for the above use case):
$ cat my-cfg-and-oper-data.xml
<config xmlns="http://tail-f.com/ns/config/1.0">
<network-instances xmlns="http://openconfig.net/yang/network-instance">
<network-instance>
<name>test</name>
<config>
<name>test</name>
</config>
<inter-instance-policies>
<apply-policy>
<state>
<default-import-policy>REJECT_ROUTE</default-import-policy>
<default-export-policy>REJECT_ROUTE</default-export-policy>
</state>
</apply-policy>
</inter-instance-policies>
<protocols>
<protocol>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:ISIS</identifier>
<name>test</name>
<config>
<identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:ISIS</identifier>
<name>test</name>
</config>
<isis>
<global>
<state>
<authentication-check>true</authentication-check>
<instance>0</instance>
<maximum-area-addresses>3</maximum-area-addresses>
<level-capability>LEVEL_1_2</level-capability>
<poi-tlv>false</poi-tlv>
<iid-tlv>false</iid-tlv>
<fast-flooding>true</fast-flooding>
</state>
<lsp-bit>
<overload-bit>
<state>
<set-bit>false</set-bit>
<set-bit-on-boot>false</set-bit-on-boot>
<advertise-high-metric>false</advertise-high-metric>
</state>
</overload-bit>
<attached-bit>
<state>
<ignore-bit>false</ignore-bit>
<suppress-bit>false</suppress-bit>
</state>
</attached-bit>
</lsp-bit>
<nsr>
<state>
<enabled>false</enabled>
</state>
</nsr>
<graceful-restart>
<state>
<enabled>false</enabled>
</state>
</graceful-restart>
<timers>
<state>
<lsp-lifetime-interval>1200</lsp-lifetime-interval>
</state>
<spf>
<state>
<spf-hold-interval>5000</spf-hold-interval>
</state>
</spf>
</timers>
<mpls>
<igp-ldp-sync>
<state>
<enabled>true</enabled>
</state>
</igp-ldp-sync>
</mpls>
<inter-level-propagation-policies>
<level1-to-level2>
<state>
<default-import-policy>REJECT_ROUTE</default-import-policy>
</state>
</level1-to-level2>
<level2-to-level1>
<state>
<default-import-policy>REJECT_ROUTE</default-import-policy>
</state>
</level2-to-level1>
</inter-level-propagation-policies>
</global>
<levels>
<level>
<level-number>1</level-number>
<config>
<level-number>1</level-number>
</config>
<state>
<enabled>false</enabled>
<authentication-check>true</authentication-check>
</state>
<link-state-database>
<lsp>
<lsp-id>1111.1111.1111.11-11</lsp-id>
<state>
<lsp-id>1111.1111.1111.11-11</lsp-id>
<version>1</version>
<version2>1</version2>
</state>
<tlvs>
<tlv>
<type xmlns:oc-isis-lsdb-types="http://openconfig.net/yang/isis-lsdb-types">oc-isis-lsdb-types:EXTENDED_IPV4_REACHABILITY</type>
<state>
<type xmlns:oc-isis-lsdb-types="http://openconfig.net/yang/isis-lsdb-types">oc-isis-lsdb-types:EXTENDED_IPV4_REACHABILITY</type>
</state>
<extended-ipv4-reachability>
<prefixes>
<prefix>
<prefix>35.0.0.0/8</prefix>
<state>
<prefix>35.0.0.0/8</prefix>
</state>
<subtlvs>
<subtlv>
<type xmlns:oc-isis-lsdb-types="http://openconfig.net/yang/isis-lsdb-types">oc-isis-lsdb-types:IP_REACHABILITY_SUBTLVS_TYPE</type>
<state>
<type xmlns:oc-isis-lsdb-types="http://openconfig.net/yang/isis-lsdb-types">oc-isis-lsdb-types:IP_REACHABILITY_SUBTLVS_TYPE</type>
</state>
<prefix-sids>
<prefix-sid>
<value>1</value>
<state>
<flags>READVERTISEMENT</flags>
<flags>NODE</flags>
<algorithm>1</algorithm>
</state>
</prefix-sid>
</prefix-sids>
</subtlv>
</subtlvs>
</prefix>
</prefixes>
</extended-ipv4-reachability>
</tlv>
</tlvs>
</lsp>
</link-state-database>
<traffic-engineering>
<state>
<enabled>false</enabled>
</state>
</traffic-engineering>
<authentication>
<state>
<csnp-authentication>false</csnp-authentication>
<psnp-authentication>false</psnp-authentication>
<lsp-authentication>false</lsp-authentication>
</state>
</authentication>
</level>
</levels>
</isis>
</protocol>
</protocols>
</network-instance>
</network-instances>
</config>
Now we can use maapi to first load the config:
$ confd_load -dd -o -m -l my-cfg-and-oper-data.xml
TRACE Connected (maapi) to ConfD
starting user session ctxt=system user=system groups=[system]
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_LOAD_CONFIG_FILE --> CONFD_OK
TRACE MAAPI_APPLY_TRANS --> CONFD_OK
TRACE MAAPI_END_USER_SESSION --> CONFD_OK
And then load the state (config false) data:
$ confd_load -dd -O -m -l my-cfg-and-oper-data.xml
TRACE Connected (maapi) to ConfD
starting user session ctxt=system user=system groups=[system]
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_LOAD_CONFIG_FILE --> CONFD_OK
TRACE MAAPI_APPLY_TRANS --> CONFD_OK
TRACE MAAPI_END_USER_SESSION --> CONFD_OK
You can of of course use maapi_set / maapi_create / maapi_set_values / cdb_set_values etc if you wish. Here an example using maapi_delete() maapi_set() and maapi_create():
confd_cmd -dd -c 'mdel /network-instances; mcreate /network-instances/network-instance{test}; mset /network-instances/network-instance{test}/config/name test; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/config/identifier" ISIS; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/config/name" test; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/config/level-number" 1'
confd_cmd -dd -o -c 'mdel "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database"; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/state/lsp-id" 1111.1111.1111.11-11; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/state/type" EXTENDED_IPV4_REACHABILITY;mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/state/prefix" 35.0.0.0/8; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/subtlvs/subtlv{IP_REACHABILITY_SUBTLVS_TYPE}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/subtlvs/subtlv{IP_REACHABILITY_SUBTLVS_TYPE}/state/type" IP_REACHABILITY_SUBTLVS_TYPE; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/subtlvs/subtlv{IP_REACHABILITY_SUBTLVS_TYPE}/prefix-sids/prefix-sid{1}"; mset "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/subtlvs/subtlv{IP_REACHABILITY_SUBTLVS_TYPE}/prefix-sids/prefix-sid{1}/state/algorithm" 1; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/subtlvs/subtlv{IP_REACHABILITY_SUBTLVS_TYPE}/prefix-sids/prefix-sid{1}/state/flags{READVERTISEMENT}"; mcreate "/network-instances/network-instance{test}/protocols/protocol{ISIS test}/isis/levels/level{1}/link-state-database/lsp{1111.1111.1111.11-11}/tlvs/tlv{EXTENDED_IPV4_REACHABILITY}/extended-ipv4-reachability/prefixes/prefix{35.0.0.0/8}/subtlvs/subtlv{IP_REACHABILITY_SUBTLVS_TYPE}/prefix-sids/prefix-sid{1}/state/flags{NODE}"'