Skip to content
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

Add a few functions for network configuration manipulation #48739

Merged
merged 1 commit into from Jul 26, 2018

Conversation

Projects
None yet
2 participants
@mirceaulinic
Copy link
Member

commented Jul 24, 2018

In this PR I am adding a few handy functions to the existing net module, for feature parity with the file module. It actually uses the corresponding functions from file, loading the result on the network device. As far as I know, besides Junos, no other network platform supports configuration replace natively. With this functions, we don't need to worry about that anymore, as the operation is done on the system side where we have (almost) unlimited flexibility: download the configuration from the network device, apply the patch, and finally load the result.

This helped me cleanup many inconsistent parts of the config (as very frequently a chunk of configuration may be referenced in multiple places), e.g., when converting the name of some prefix lists from upper to lower:

$ sudo salt 'junos-router' net.replace_pattern 'PREFIX-LIST' 'prefix-list'
junos-router:
    ----------
    already_configured:
        False
    comment:
        Configuration discarded.
    diff:
        [edit policy-options]
        +   prefix-list prefix-list {
        +       1.2.3.4/32;
        +   }
        [edit policy-options]
        -   prefix-list PREFIX-LIST {
        -       1.2.3.4/32;
        -   }
        [edit firewall filter in-filter term accept-icmp from prefix-list]
        +      prefix-list;
        -      PREFIX-LIST;
        [edit firewall filter filter-l0-in term accept-icmp from prefix-list]
        +      prefix-list;
        -      PREFIX-LIST;
    loaded_config:
    result:
        True

@mirceaulinic mirceaulinic force-pushed the mirceaulinic:net-mod-funs branch from ab15960 to e026451 Jul 25, 2018

@rallytime
Copy link
Contributor

left a comment

Nice 👍

@rallytime rallytime merged commit 3f5349d into saltstack:develop Jul 26, 2018

5 of 9 checks passed

continuous-integration/jenkins/pr-merge This commit cannot be built
Details
codeclimate 4 issues to fix
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has failed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has failed
Details
WIP ready for review
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details

@mirceaulinic mirceaulinic deleted the mirceaulinic:net-mod-funs branch Jul 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.