-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can config management really not be implemented? #71
Comments
This is a trap. Once I (or any one else) implement this, I will have tons of maintenance with escaping mikrotik scripting language. MikroTik may change without prior information (which they did this in the past breaking backwards compatibility) syntax. It is just a PITA. Uniqueness in some command paths. Two options here. User provides tuple with keys which form a unique key, or provide those in library. Again thing may change. No commit/rollback. This is self explanatory. It can be emulated in plugin BUT when access is cut off in middle of configuration, no way to roll back. API does not provide safe mode access. Neither you can control timeouts via cli. With all those points, I can implement a simple yaml / json file parsing with rules and do "config replace". One thing for sure. I need feedback and not everything can be done (see points above) |
Makes sense - thanks for clarifying. So basically, whereas the commands in a Cisco or Juniper config file represent a desired configuration state, the commands in the RouterOS represent actions. Or in other words, there's not necessarily an idempotent config syntax. |
Yes. Exactly. |
Technically, there is a workaround but it requires a reboot of the device. |
Hmm. Didn't know that. Thx for information. IMO this is crude but acceptable. |
You're welcome, I'm glad to help. Another caveat is that you need to upload the rsc file to the device before issuing the command which I don't know if it is possible through the API. As you mentioned this is indeed crude and not justifiable on edge/core devices but acceptable on leaf nodes. |
Yes. I agree. Since there is no other way, end user must decide if reboot is ok for his device. |
I've just come across this while considering a deployment of Netbox + NAPALM ROS. Did anything ever come of the discussion with @adamharm in #40 regarding creating configuration merge system? I ask because I already have something tentatively working in this regard, and I'd be happy for it to be used here. I may also be up for submitting the PR myself (I'm not 100% sure I'm going to go ahead with Netbox yet). The code I have is about 800 lines of fairly well structure Python, plus unit tests. It will take two RouterOS configurations and produce a diff. When the diff is executed, it will move the router config from the old state to the new state. It is smart enough to maintain the order of ordered sections (i.e. firewall config), and can identify configuration expressions by their unique keys (i.e. That all being said, it isn't perfect. It is the kind of thing that works well within limitations. Certainly if you stick to the output of ExamplesSimple:
Firewall NAT rules:
If this would be useful let me know. |
Even if it is not useful to anyone else, I have a use case where this would be a perfect solution |
Hey @dBitech, I'm glad to hear it. Ok, I've just spun it up into its own little project: https://github.com/gardunha/routeros-diff You'll probably run into some quirks, but feel free to raise issues / send PRs. I took some time to refactor & comment the code before releasing. Additionally, I'd be happy for |
Hi. @adamcharnock Thx for your input. Your solution seems good enough. I have couple of questions though.
|
That is good to hear @luqasz. Answers below:
Can you clarify this, I'm not sure I completely understand.
An excellent point. I have added settings and released version |
We are interested in replacing and merging config. Napalm provides methods for that. E.g if you want to add a ip address to a list and you don't care / don't want to touch other entries then, you will use a merge option. If you want to have exactly what you say in config file (later to be parsed), then you want a replace method. |
As for NATURAL_KEYS, we still need some way to add it to parsable config. |
Hi @luqasz, Ok, I see what you are saying.
I have not looked into merging yet. I suspect merging could be defined as some combination of the following:
I don't think this would be too hard to implement in
Ok, this is the parsable config system provided by |
Destination config is a file that we want to apply ?
Nope. |
Correct. I'm using this terminology:
Ok, in that case, can you clarify your original meaning? |
It seems we are bouncing back and forth a bit here. The questions on my mind are:
|
For what I see so far, yes. We would have to test it either way to see what issues we will encounter.
I am thinking about merging your code / work into https://github.com/luqasz/librouteros. Those functionalities are pretty much on pair with each other. I know that librouteros provides API only code, however we can expand it and provide extra functionalities. I think it will be easier in long term to maintain and provide a consistent library. What do you think ? |
I've had a think and that sounds like a good idea to me. My thoughts are:
|
FYI @luqasz, I have this working now. Napalm-ros forkI've got a fork with the SSH client added and config reading & writing working. However, I realised that early on I also turned the fork into a working Netbox plugin. I think this was primarily because I wanted some way to store each host's SSH keys, so I created a Django model for it. This fork should still work just fine without Netbox being available. I coded it in such a way that it should be optional. That being said, I've been juggling so many different packages to get this working that I'm willing to accept that I may have drawn the line in the wrong place in this case. Netbox RouterOSThis is a working Netbox plugin which I have now successfully end-to-end tested. I've successfully used it to push new configuration diffs onto a RouterOS device via the SSH functionality implemented above. See the github repo for list of features. Screenshot: AddendumJust for my own sanity I want to brain dump out the various layers to this:
That feels like quite a lot of turtles, and has certainly made my head hurt from time to time. I'm not sure anything needs to be done about it, but I feel better for writing it down! I'm keen to get all of this released and usable soon. The main thing I need to make this happen is a decision from you on whether you want to merge my Secondarily, and non-blocking, is any discussion on merging |
Ok. Let's merge your work. Please correct me if I am wrong. Do you want to merge code from |
@adamcharnock What do you think ? |
Hey @luqasz - sorry for the delayed response. I'm also starting a WISP and building a house 🙄
Given my experiences in recent weeks, I think it would be best to delay this. I still finding the occasional problem with with Also, I previously asked, "I would like to retain some stewardship of the diffing code. Would you be open to me becoming a collaborator on librouteros?". Do you have any thoughts on this?
Great. Just to confirm, that is the merge of my |
Sure. Everyone can contribute to librouteros.
Ok so napalm-ros should produce parsable config string for routeros-diff.
Yes. Please merge into config-diff branch |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
In the README, you make the statement:
Is this really accurate? You can run
/export file=<filename>
as well as/import file-name=<filename>
to export/import the config and modify it in file format. Is there a technical reason that this is not a workable solution? I know you mention that order matters in some places and not others. Is this the issue? And if so, is there not a way around this, such as generating the file from scratch each time? The OS seems to handle references fairly well in the export by using[find ...]
rather than referencing objects by number. So is it just that this is a PITA to implement, or is it somehow not possible because of how the plugin interface works?The text was updated successfully, but these errors were encountered: