How to loading initial data for openconfig-platform into CDB

How to loading initial data for openconfig-platform into CDB?
I install a new Confd Basic 7.6.
I complie the opencoifg/public YANG file to *.fxs and copy to $CONFD_DIR/etc/confd/.
How to initialize the openconfig-platform data for hardware inventory such as CPU、FAN、LINE_CARD … ?

I try to load $CONFD_DIR/var/confd/cdb/components_init.xml ,recieve the respone when run the command "confd --start-phase0 ":

CDB boot error: failed to load /media/vdb/tools/confd7.6/var/confd/cdb/components_init.xml:6: object is not writable: /oc-platform:components/oc-platform:component[oc-platform:name=‘4’]/oc-platform:state


components_init.xml:


<config>
 <components xmlns="http://openconfig.net/yang/platform">
            <component>
                <name>4</name>
                <state>
                    <name>N9K-X9732C-EXM</name>
                    <description>32x100G Ethernet Module</description>
                    <hardware-version>0.1230</hardware-version>
                    <id>4</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-18429-01</part-no>
                    <serial-no>FOC205114M4</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>LINECARD</type>
                </state>
            </component>
            <component>
                <name>1</name>
                <state>
                    <name>N9K-X9732C-EXM</name>
                    <description>32x100G Ethernet Module</description>
                    <hardware-version>0.1220</hardware-version>
                    <id>1</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-18429-01</part-no>
                    <serial-no>FOC20444YCE</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>LINECARD</type>
                </state>
            </component>
            <component>
                <name>2</name>
                <state>
                    <name>N9K-X9736C-FX</name>
                    <description>36x40/100G Ethernet Module</description>
                    <hardware-version>0.3030</hardware-version>
                    <id>2</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-18315-03</part-no>
                    <serial-no>FOC21127NR2</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>LINECARD</type>
                </state>
            </component>
            <component>
                <name>3</name>
                <state>
                    <name>N9K-X9736C-FX</name>
                    <description>36x40/100G Ethernet Module</description>
                    <hardware-version>0.3060</hardware-version>
                    <id>3</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-18315-03</part-no>
                    <serial-no>FOC21234PKU</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>LINECARD</type>
                </state>
            </component>
            <component>
                <name>25</name>
                <state>
                    <id>25</id>
                    <type>FABRIC</type>
                </state>
            </component>
            <component>
                <name>21</name>
                <state>
                    <id>21</id>
                    <type>FABRIC</type>
                </state>
            </component>
            <component>
                <name>26</name>
                <state>
                    <name>N9K-C9504-FM-E</name>
                    <description>4-slot Fabric Module</description>
                    <hardware-version>1.0</hardware-version>
                    <id>26</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-17450-02</part-no>
                    <serial-no>SAL2024RSSH</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>FABRIC</type>
                </state>
            </component>
            <component>
                <name>24</name>
                <state>
                    <name>N9K-C9504-FM-E</name>
                    <description>4-slot Fabric Module</description>
                    <hardware-version>1.0</hardware-version>
                    <id>24</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-17450-02</part-no>
                    <serial-no>SAL2024RSSE</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>FABRIC</type>
                </state>
            </component>
            <component>
                <name>23</name>
                <state>
                    <name>N9K-C9504-FM-E</name>
                    <description>4-slot Fabric Module</description>
                    <hardware-version>1.0</hardware-version>
                    <id>23</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-17450-02</part-no>
                    <serial-no>FOC21070SAQ</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>FABRIC</type>
                </state>
            </component>
            <component>
                <name>22</name>
                <state>
                    <name>N9K-C9504-FM-E</name>
                    <description>4-slot Fabric Module</description>
                    <hardware-version>1.0</hardware-version>
                    <id>22</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>INACTIVE</oper-status>
                    <part-no>73-17450-02</part-no>
                    <serial-no>FOC21070RB9</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>FABRIC</type>
                </state>
            </component>
            <component>
                <name>28</name>
                <state>
                    <id>28</id>
                    <type>CPU</type>
                </state>
            </component>
            <component>
                <name>27</name>
                <state>
                    <name>N9K-SUP-B</name>
                    <description>Supervisor Module</description>
                    <hardware-version>0.1020</hardware-version>
                    <id>27</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>02</part-no>
                    <serial-no>SAL1826VG0K</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>CPU</type>
                </state>
            </component>
            <component>
                <name>29</name>
                <state>
                    <name>N9K-SC-A</name>
                    <description>System Controller</description>
                    <hardware-version>1.4</hardware-version>
                    <id>29</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-15294-02</part-no>
                    <serial-no>SAL1917DYUQ</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>FRU</type>
                </state>
            </component>
            <component>
                <name>30</name>
                <state>
                    <name>N9K-SC-A</name>
                    <description>System Controller</description>
                    <hardware-version>1.4</hardware-version>
                    <id>30</id>
                    <mfg-name>Cisco Systems, Inc.</mfg-name>
                    <oper-status>ACTIVE</oper-status>
                    <part-no>73-15294-02</part-no>
                    <serial-no>SAL1917DYTA</serial-no>
                    <software-version>9.2(0.108)</software-version>
                    <type>FRU</type>
                </state>
            </component>
        </components>
    </config>

The CDB init files can contain only configuration. In OpenConfig models, everything under state is operational/state data, so it cannot be in the init files.

What you can or should do:

  • You will need to remove the state container data from the init file.

  • At the same time, if you want your system to contain initial configuration after startup, you may need to add data to /components/component/config, if only because OpenConfig models have the nasty habit to define key leafs as leafrefs to leafs under the container config.

  • As for the state data, you have two options: you can keep that stored in CDB, but you need to populate it only after ConfD has started. A simple option how to populate it is using confd_load, e.g. like

      $ confd_load -O -l -m components_init.xml
    

    You also may want to consider making your operational data persistent; see the documentation and also cdb_oper example set.

    Another option is to implement a full-fledged operational data provider, though this requires non-negligible effort. The module openconfig-platform contains state data such as temperature or power usage readings; that can still be implemented using a stats push approach, but proper data provider might be more elegant.

Run the command ,get a error:

[root@TEF-01 ~]# confd_load -O -l -m components_init.xml
confd_load: 283: maapi_connect(sock, addr, addrlen) failed: Bad protocol usage or unexpected retval (21): Library MAXDEPTH/MAXKEYLEN 20/9 for confd_hkeypath_t are too small, ConfD needs 35/8

That’s the known problem with MAXKEYLEN - this tool needs to be recompiled as well. Its source code is in $CONFD_DIR/src/confd/tools, the command to recompile it would be something like

$ CFLAGS="-DMAXDEPTH=35 -DMAXKEYLEN=8" make -f Makefile.confd_cmd \
 -W confd_load.c -W confd_cmd.c all

After comiiled, I copy new confd_cmd and confd_load to $CONFD_DIR/bin/.
Then I run command ,and I get new error:

 confd_load -O -l -m /root/components_init.xml
confd_load: error while loading shared libraries: libconfd.so: cannot open shared object file: No such file or directory

The library libconfd.so is by default stored in $CONFD_DIR/lib, and if you sourced $CONFD_DIR/confdrc you should have that directory in the LD_LIBRARY_PATH environment variable. So either your LD_LIBRARY_PATH is empty, in which case you should do

$ source $CONFD_DIR/confdrc

or $CONFD_DIR/lib does not contain the library - that might be because you removed it and did not replace it with the result of libconfd recompilation.

Now, I get new problem.I think my XML is Ok. What went wrong ? Thx!

You need to have the component configured first. By uploading state data you cannot modify configuration, and as long as there is no /components/component{4}, you cannot add state data for that. So, you first need to create the component “manually”, or upload or put to your initial CDB configuration something like this:

<config>
  <components xmlns="http://openconfig.net/yang/platform">
    <component>
      <name>4</name>
      <config>
        <name>4</name>
      </config>
    </component>
  </components>
</config>
1 Like

By the way, the three leafs name (/components/component/name, /components/component/config/name, /components/component/state/name) are all more or less assumed to be the same, though it is enforced by the data model only for the first two, so nothing really prevents you from reporting the state/name as N9K-X9732C-EXM even though the component is configured as 4.

1 Like

Is it a good idea to set the same value for the three leafs name ,such as ‘4’ or ’ N9K-X9732C-EXM '?
Thx!

This depends a lot on the actual deployment, but it is a component name, so I would say that a value like "4" may not be the best choice.

Thx! :smiley:

By the way,the components_init.xml is from Cisco DevNet: APIs, SDKs, Sandbox, and Community for Cisco Developers

I see. Note that the data were created as a response to a get query with the XPath filter /components/component/state - that’s why there’s nothing else. As to name vs. config/name vs. state/name: the first two need to be the same, this is required by the data model. The pragmatics of OpenConfig models is that everything under config/ is what the northbound management system configures, values under state/ are what the device actually uses; ideally, the common leaves should have the same values. For components this might be a bit tricky, since components cannot really be created by the configuration - perhaps this is the reason why NX-OS authors decided to implement it like that.

2 Likes