Modify author and message in Commit
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 ?
Do these help: https://github.com/ytti/oxidized/blob/master/extra/syslog.rb https://github.com/ytti/oxidized/blob/master/extra/rest_client.rb
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?
The syslog.rb and rest_client.rb have example how to accomplish
- give commit message and author
- 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?
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.
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.
We figured out , how to do it , thank you .
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?
@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')