oxidized icon indicating copy to clipboard operation
oxidized copied to clipboard

Modify author and message in Commit

Open arko95 opened this issue 10 years ago • 8 comments

Hello

We would like to do a call at API with https://github.com/ytti/oxidized-web/blob/master/lib/oxidized/web/webapp.rb#L103 to modify the Author and message for Commit with https://github.com/ytti/oxidized/blob/master/extra/rest_client.rb. How we could do it ? Could you give me some tips ?

arko95 avatar Jul 29 '16 08:07 arko95

Do these help: https://github.com/ytti/oxidized/blob/master/extra/syslog.rb https://github.com/ytti/oxidized/blob/master/extra/rest_client.rb

ytti avatar Jul 29 '16 09:07 ytti

Yes it could helps, but the idea it´s when we get the node configuration , be able to change the author and the default message 'updated < node_name >'. We want to get a personalized message and author name and then push it to our remote git . We are thinking to use oxidized-web RESTful API to do so .

What we need to figure out it's how to use this endpoint to change author and message ? :

 # use this to attach author/email/message to commit
      put '/node/next/?:group?/:node' do
        node, @json = route_parse :node
        opt = JSON.load request.body.read
        nodes.next node, opt
        redirect url_for('/nodes') unless @json
        @data = 'ok'
        out
      end "

How to format json data to send with PUT method? Can we use the rest_client.rb to do this?

arko95 avatar Jul 29 '16 11:07 arko95

The syslog.rb and rest_client.rb have example how to accomplish

  1. give commit message and author
  2. ask oxidized to fetch config for node, attaching message and author to it

So you can only put this information in, before you ask oxidized to fetch some config.

What is your actual practical use case. Will the message and author be static always? Or will you somehow determine case-by-case what it will be, if so, how will you determine it?

ytti avatar Jul 29 '16 12:07 ytti

What we want to do : Set a big interval of 24h for the automatic fetch of Oxidized. Then when one user modify some configuration during this interval, we wants that this user be able input the node name, his author-name, and a message to commit, and proceed to fetch of config . Exactly as button update (with glyphicon-repeat) do, in the oxidized-web interface.

arko95 avatar Jul 29 '16 12:07 arko95

syslog.rb does that automatically, provided you're using junos which allows commit messages, in ios it'll just include the username.

But if you want to do this manually, then that's fine. Just have some script you use to edit device, and in the script after user exists device, you could ask 'fetch config?' and you could ask for commit message. Then you'll just lauch curl for the /next, like in rest_client.rb.

ytti avatar Jul 29 '16 12:07 ytti

We figured out , how to do it , thank you .

arko95 avatar Aug 01 '16 10:08 arko95

Hi @arko95, any chance you could update this with your solution to help anyone else stumbling across this thread with similar issues in the future?

zyio avatar Aug 08 '16 10:08 zyio

@arko95 you could do a request like this:

PUT /node/next/:device
{
  "user": "username",
  "msg": "commit message goes here"
}

or with the rest_client.rb

rest = Oxidized::RestClient.new('localhost', 8888)
rest.next(name: 'device', user: 'username', msg: 'commit message goes here')

ref.: lib/oxidized/nodes.rb & extra/rest_client.rb

danilopopeye avatar Aug 09 '16 13:08 danilopopeye