cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1102
Views
20
Helpful
5
Replies

Add a commit comment from python code

Hello,

I'm wondering how can I add a comment to a commit launched from python code using MAAPI API.

I found that there is a function called 

int maapi_set_comment(int sock, int thandle, const char *comment)

but I didn't figure out how can I use it.

Thanks in advance,

1 Accepted Solution

Accepted Solutions

Nabsch
Spotlight
Spotlight

Hello Alaeddine ,

 

Here an example where i create a device-group then i set  a comment  

with ncs.maapi.Maapi() as m:
    with ncs.maapi.Session(m, 'admin', 'test_context'):
        with m.start_write_trans() as trans:
            root = ncs.maagic.get_root(trans)
            root.ncs__devices.device_group.create("test-python512115")
            trans.set_comment("commit via PYTHON1")
            trans.apply()

 

You can verify the comment in cli

 

admin@ncs# show configuration commit list
2022-01-26 18:15:19
SNo.  ID       User       Client      Time Stamp          Label       Comment
~~~~  ~~       ~~~~       ~~~~~~      ~~~~~~~~~~          ~~~~~       ~~~~~~~
10017 10017    admin      system      2022-01-26 18:06:46             commit via PYTHON1

 

View solution in original post

5 Replies 5

Nabsch
Spotlight
Spotlight

Hello Alaeddine ,

 

Here an example where i create a device-group then i set  a comment  

with ncs.maapi.Maapi() as m:
    with ncs.maapi.Session(m, 'admin', 'test_context'):
        with m.start_write_trans() as trans:
            root = ncs.maagic.get_root(trans)
            root.ncs__devices.device_group.create("test-python512115")
            trans.set_comment("commit via PYTHON1")
            trans.apply()

 

You can verify the comment in cli

 

admin@ncs# show configuration commit list
2022-01-26 18:15:19
SNo.  ID       User       Client      Time Stamp          Label       Comment
~~~~  ~~       ~~~~       ~~~~~~      ~~~~~~~~~~          ~~~~~       ~~~~~~~
10017 10017    admin      system      2022-01-26 18:06:46             commit via PYTHON1

 

Thank you very much for your reply.

fracjackmac
Level 1
Level 1

Hello @AlaeddineJebnoun90723 and @Nabsch,

 

Would you please provide a link to the MAAPI API?  I'm not familiar with this API and am interested in learning more about it.

 

Thanks!

Hello , 

 

Here  a Link to documentation  but you should also have a look to the source code.

 

Thank you @Nabsch.