-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Enhance the proxy_napalm_wrap decorator to allow "proxyless" execution #48290
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
Conversation
Usually the Salt proxies have been designed using a single methodology: for each device you aim to manage, start one Proxy Minion. The NAPALM modules didn't make an exception, however, beginning with saltstack#38339 (therefore starting with release Nitrogen), the functionality has been enhanced in such a way that we can execute the code when we are able to install the regular Minion directly on the network hardware. There is another use case, for something, let's call it "proxyless" when we don't particularly need to start a Proxy process for each device, but rather simply invoke arbitrary functions. These changes make this possible, so with one single Minion (whether Proxy or regular), one is able to execute Salt commands going through the NAPALM library to connect to the remote network device by specifying the connection details from the command line and/or opts/pillar, e.g. ``salt server1 bgp.neighbors driver=junos host=1.2.3.4 username=salt``. If the ``server1`` Minion has the following block in the Pillar (for example): ```yaml napalm: driver: junos username: salt ``` The user would only need to provide the rest of the credentials (depending on each individual case): ``salt server1 bgp.neighbors host=1.2.3.4``.
…lm_inventory
This is going to ease the CLI usage, so we can reduce everything to simply
specifying the host of the device, e.g.,
Having the following configuration in the opts/pillar:
```yaml
napalm:
username: salt
password: test
napalm_inventory:
1.2.3.4:
driver: eos
edge01.bzr01:
driver: junos
```
With the above available in the opts/pillar for a Minion, say ``server1``, the
user would be able to execute: ``salt 'server1' bgp.neighbors host=1.2.3.4`` or
``salt 'server1' net.arp host=edge01.bzr01``, etc.
salt/utils/napalm.py
Outdated
| napalm_opts.update(inventory_opts) | ||
| log.debug('Merging the config for %s with the details found in the napalm inventory:', host) | ||
| log.debug(napalm_opts) | ||
| opts = opts.copy() # make sure we don't override the original |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will probably want to do a copy.deepcopy(opts) here instead, to get any nested options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks! When I wrote this I was too focused only at that chunk of config, but indeed, the others would be affected if not using copy.deepcopy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added bf7baae to fix this.
|
Other than one small change, this LGTM |
Usually the Salt proxies have been designed using a single methodology: for
each device you aim to manage, start one Proxy Minion. The NAPALM modules didn't
make an exception, however, beginning with #38339
(therefore starting with release Nitrogen), the functionality has been enhanced
in such a way that we can execute the code when we are able to install the
regular Minion directly on the network hardware.
There is another use case, for something, let's call it "proxyless" when we
don't particularly need to start a Proxy process for each device, but rather
simply invoke arbitrary functions. These changes make this possible, so with one
single Minion (whether Proxy or regular), one is able to execute Salt commands
going through the NAPALM library to connect to the remote network device by
specifying the connection details from the command line and/or opts/pillar, e.g.
salt server1 bgp.neighbors driver=junos host=1.2.3.4 username=salt.If the
server1Minion has the following block in the Pillar (for example):The user would only need to provide the rest of the credentials (depending on
each individual case):
salt server1 bgp.neighbors host=1.2.3.4.Having the following configuration in the opts/pillar, for example:
With the above available in the opts/pillar for a Minion, say
server1, theuser would be able to execute:
salt 'server1' bgp.neighbors host=1.2.3.4orsalt 'server1' net.arp host=edge01.bzr01, etc.