-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support ASA Multi-Context Mode #21
Comments
This is some poc code for multicontext support. I've then modified the get_config() & cli() methods to accept an optional context parameter. import napalm
import napalm_asa
drv = napalm.get_network_driver('asa')
dev = drv(hostname='192.168.2.10', username='cisco', password='cisco')
dev.open()
dev.get_config(context='customer_1') This is just an example of how it could work. Not sure if it is a good idea to add optional arguments to "standard" napalm methods. |
Hi @dbarrosop |
So that's certainly going to break the integration. We have discussed accepting everywhere **kwargs for cases like the one you described but that's a big change and we haven't had the time/consensus to do so. What I'd suggest is, either, you bring this topic to the main napalm org and see what comes out of there or you use an
Alternatively:
Or both. I, mean, you can do what you think is best but what you are proposing today (without the general kwargs solution) this is going to break if someone tries to use this in a multivendor setup (whch is kind of the point of napalm after all :P) |
That's why we were involving you, we don't want anything to break. I do like a combination of both alternatives that you bring up. Thanks for the feedback |
I've removed the optional parameter from the methods. |
Looking good! I agree, let's continue with the optional_arg + setter for context! thanks for the input @dbarrosop |
can you have a look here wvandeun@4e31c22 ? I've implemented multi context support for all getters as discussed above. |
Nice work @Enzzzy! I don't have any major concerns about the code, I think you have a good direction that we can follow to implement this. Just a couple of notes(sorry if I'm a bit picky): On L240 I get why you named the method Also on the same method, I usually prefer to write things more explicitly, even if it means writing a bit more code. How do you feel about refactoring the following bit? return self.multicontext and \
self._context and \
endpoint not in MC_INCOMPATIBLE_ENDPOINTS It may be just my weak python skills talking, but I would prefer that the return value be more explicit. oh, and also on L363, the current form works, but the linter will complain about it, better change to something like: if context not in self.contexts: Other minor things like extra spaces and such we can fix when working on the tests. Thank you for getting this rolling! |
I've made the suggested improvements and fixed the linting issues. Todo: write tests |
👏 Speaking of tests, I was bitten by an issue recently on #22. I will describe the problem there and the fix I could figure out so far. |
I'm creating this issue following @Enzzzy's suggestion on Slack. We will try to provide some POC code and discuss what is the best way to implement multi-context support for this driver.
The text was updated successfully, but these errors were encountered: