-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Rethinking the way configuration management for network devices is handled #48945
Rethinking the way configuration management for network devices is handled #48945
Conversation
6a2ae96
to
6a70bb1
Compare
salt/modules/napalm_network.py
Outdated
template_source=None, | ||
template_hash=None, |
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.
We can't remove any of these older kwargs without putting them on a deprecation path first. We'll need to support these with a warning for 2 feature releases. (So, Sodium would be the version to wan until and then remove the kwargs.) You can use the warn_until
function in salt.utils.versions
.
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.
I understand that I should revert 6a70bb1.
In that case, they will no longer be used (although defined in the function header). How would you suggest to proceed? Leave them defined and unused?
Sorry I know this is a bit controversial, it's also the first time I'm deprecating something so I'm not sure what's the best way. Also, please remember that the arguments in subject, as of today, basically aren't useful / don't make sense to be there in the first place. Thanks!
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.
so, you have **template_vars
, so you don't want anyone that is still passing stuff to this, to inject extra arguments to the template_vars.
I would put a for loop at the top of the function, that iterates over all of the arguments here, and just tells the user that they do not need to specify them, and in 2 releases, they will be passed to template_vars if they do not stop using them.
That should be good enough, then in 2 releases we will just delete all that, and delete these variables from the function definition.
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.
Thanks @gtmanfred - I will update this branch tomorrow.
salt/modules/napalm_network.py
Outdated
template_source=None, | ||
template_hash=None, |
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.
I do not like removing the template_hash. We should probably still keep this, even though cp.get_template does not support giving it a hash. We should be verifying the hash manually as part of the load_template process.
salt/modules/napalm_network.py
Outdated
template_source=None, | ||
template_hash=None, |
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.
so, you have **template_vars
, so you don't want anyone that is still passing stuff to this, to inject extra arguments to the template_vars.
I would put a for loop at the top of the function, that iterates over all of the arguments here, and just tells the user that they do not need to specify them, and in 2 releases, they will be passed to template_vars if they do not stop using them.
That should be good enough, then in 2 releases we will just delete all that, and delete these variables from the function definition.
salt/states/netconfig.py
Outdated
template_engine='jinja', | ||
skip_verify=False, |
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.
These should be handled the same way as they are in the load_template module.
@mirceaulinic I have changed the base branch of this PR from |
I spoke with @mirceaulinic a few minutes ago and helped clear up how the file state/module work internally. I think the confusion comes from the fact that However, it would still be good to have a function in the In the meantime, I think it would be good to do the following:
I am also not a fan of using arguments like |
8be9fa2
to
68019e3
Compare
Hello everyone - thanks again for your time and good ideas. I have pushed some changes into this branch, please re-review. |
@@ -2018,6 +2033,13 @@ def load_template(template_name, | |||
} | |||
) | |||
else: | |||
salt.utils.versions.warn_until( |
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.
I should have removed this in Fluorine
(https://docs.saltstack.com/en/develop/topics/releases/fluorine.html#module-deprecations), but it turns out that it has more implications than I initially thought, postponing this till Sodium
as well. Is that alright?
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.
👍
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.
One small change, otherwise this looks good.
'Sodium', | ||
('The \'{arg}\' argument to \'net.load_template\' is deprecated ' | ||
'and has been ignored').format(arg=deprecated_arg) | ||
) |
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.
Can we remove these args from template args?
Should be a simple del template_vars[deprecated_arg]
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.
Shall do.
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.
Okay, just added: ed8cec1. Thanks!
template_hash_name = [template_hash_name] | ||
elif not template_hash_name: | ||
template_hash_name = [None] * len(template_name) | ||
if template_hash and isinstance(template_hash, six.string_types) and not\ |
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.
I was wondering what's @terminalmage's take on this? Does this make sense to you, or would you suggest doing this in a better way? Thanks.
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.
Once this is added, this should be good to merge IMO
0a2220f
to
ed8cec1
Compare
What does this PR do?
There are two root causes for these changes:
I agree with this, and with these changes, this is going to be possible from now on. For example, a state such as:
Would totally be valid (previously only
template_name: https://bit.ly/2OhSgqP
was possible).net.load_template
function more than 2 years ago, I still wasn't fully comfortable with Salt and I didn't have enough experience to evaluate what's the best way to render templates on the fly. This is why I ended up usingfile.get_managed
: I was reading the template contents, dumping the rendered result into a temporary file, then reading the contents from there and load them into the device. Not only this is suboptimal, but Salt already hasfile.apply_template_on_contents
for this exact purpose, without creating temporary files and all that mess. Usingfile.get_managed
made me add a bunch of arguments such astemplate_user
,template_mode
etc., which never made sense, nobody actually used those as they refer to the temporary file which is anyway removed after this function is executed.With this said, I'm swapping the usage of the
file.get_managed
with the more appropriatefile.apply_template_on_contents
. This also means that thetemplate_user
,template_mode
,template_group
et. al. arguments would no longer be used.I have removed these arguments in b5a642e, but in case this should better be done in a later release I am happy to revert this commit and have the deprecated tags for the time being: 2ea0cbe
CC @gtmanfred
Notable byproducts:
After discussion with @gtmanfred, @rallytime and @terminalmage, (2) is not enough good reason to drop the template hash arguments, therefore we'll continue using
file.get_managed
. However, deprecatingtemplate_user
,template_group
, etc.