Skip to content

Add a few functions for network configuration manipulation#48739

Merged
rallytime merged 1 commit intosaltstack:developfrom
mirceaulinic:net-mod-funs
Jul 26, 2018
Merged

Add a few functions for network configuration manipulation#48739
rallytime merged 1 commit intosaltstack:developfrom
mirceaulinic:net-mod-funs

Conversation

@mirceaulinic
Copy link
Contributor

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

Copy link
Contributor

@rallytime rallytime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@rallytime rallytime merged commit 3f5349d into saltstack:develop Jul 26, 2018
@mirceaulinic mirceaulinic deleted the net-mod-funs branch July 31, 2018 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants