cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Getting error with maapi.load_config in NSO 5.3

158
Views
0
Helpful
1
Comments
Cisco Employee

Unable to write xml file in NSO 5.3 CDB using maapi.load_config with below command
"maapi.load_config(m['s'],m['th'], maapi.CONFIG_XML, "Test.xml")"


Creating the transaction object as,  th = _ncs.maapi.start_trans(s, _ncs.RUNNING ,_ncs.READ_WRITE)

 

Getting the following error message:

Error: external error (19): Error on line 1: object is not writable: /<path>

 

But when changing this to _ncs.OPERATIONAL it gives no error but data is not getting loaded to nso CDB .

1 Comment
Cisco Employee

Can you share your code little more?

 

I created the below small example, and it works fine.

$ cat load.py
import _ncs
import socket

s = socket.socket()
_ncs.maapi.connect(s, '127.0.0.1', _ncs.NCS_PORT)
_ncs.maapi.start_user_session(s, 'admin',
                    'low-level-read', [], '127.0.0.1',
                    _ncs.PROTO_TCP)
th = _ncs.maapi.start_trans(s, _ncs.RUNNING ,_ncs.READ_WRITE)
_ncs.maapi.load_config(s, th, _ncs.maapi.CONFIG_XML|_ncs.maapi.CONFIG_MERGE, "/tmp/user-test.xml")
_ncs.maapi.apply_trans(s, th, False)
_ncs.maapi.finish_trans(s, th)
_ncs.maapi.end_user_session(s)
_ncs.maapi.close(s)
$ python load.py
$

test file

$ cat /tmp/user-test.xml
<config xmlns="http://tail-f.com/ns/config/1.0">
  <aaa xmlns="http://tail-f.com/ns/aaa/1.1">
  <authentication>
  <users>
  <user>
    <name>test</name>
    <uid>1</uid>
    <gid>1</gid>
    <password>$6$</password>
    <ssh_keydir>/var/ncs/homes/public/.ssh</ssh_keydir>
    <homedir>/var/ncs/homes/public</homedir>
  </user>
  </users>
  </authentication>
  </aaa>
</config>
$