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

suse_ip module implementation #60702

Merged
merged 10 commits into from May 26, 2022
Merged

Conversation

vzhestkov
Copy link
Contributor

What does this PR do?

Implements ip module for SUSE based distros.

Previous Behavior

The following state produces a traceback due to the missing ip.build_interface:

dhcp_interface:
  network.managed:
    - name: eth1
    - enabled: True
    - type: eth
    - proto: static
    - ipaddr: 192.168.5.1
    - netmask: 255.255.255.0

New Behavior

          ID: dhcp_interface
    Function: network.managed
        Name: eth1
      Result: True
     Comment: Interface eth1 updated.
     Started: 11:55:49.856726
    Duration: 5440.104 ms
     Changes:   
              ----------
              interface:
                  --- 
                  +++ 
                  @@ -1,2 +1,4 @@
                   STARTMODE='auto'
                  -BOOTPROTO='none'
                  +BOOTPROTO='static'
                  +IPADDR='192.168.5.1'
                  +NETMASK='255.255.255.0'
              status:
                  Interface eth1 restart to validate

More complex state example:

system:
  network.system:
    - enabled: True
    - hostname: vz-m41-s152.tf.local
    - gateway: 172.16.82.1
    - gatewaydev: eth0
    - nozeroconf: True
    - nisdomain: example.com
    - require_reboot: True
    - retain_settings: True
    - dns:
      - 172.16.82.1
      - 8.8.8.8
      - 8.8.4.4
    - dns_search:
      - tf.local
      - demo.lab
      - vzhestkov.net

eth1:
  network.managed:
    - enabled: True
    - type: slave
    - bootproto: none
    - master: bond0

eth2:
  network.managed:
    - enabled: True
    - type: slave
    - bootproto: none
    - master: bond0

bond0:
  network.managed:
    - type: bond
    - ipaddr: 10.1.0.1
    - ipaddrs:
      - 10.2.0.1/24
      - 10.3.0.1/24
    - enable_ipv6: true
    - ipv6proto: static
    - ipv6addr: 2001:db8:dead:beef::1/64
    - ipv6addrs:
      - 2001:db8:dead:beef::3/64
      - 2001:db8:dead:beef::7/64
    - netmask: 255.255.255.0
    - mode: balance-rr
    - proto: static
    - enabled: True
    - slaves:
      - eth1
      - eth2
    - require:
      - network: eth1
      - network: eth2
    - miimon: 100
    - lacp_rate: fast
    - max_bonds: 1
    - updelay: 0
    - use_carrier: on
    - hashing-algorithm: layer2
    - mtu: 9000
    - autoneg: on
    - speed: 1000
    - duplex: full
    - rx: on
    - tx: off
    - sg: on
    - tso: off
    - ufo: off
    - gso: off
    - gro: off
    - lro: off

vlan10:
  network.managed:
  - type: vlan
  - vlan: True
  - vlan_id: 10
  - phys_dev: bond0
  - proto: static
  - ipaddr: 10.40.0.4/24
  - require:
    - network: bond0

routes_vlan10:
  network.routes:
    - name: vlan10
    - routes:
      - name: secure_network
        ipaddr: 10.22.0.0/24
        gateway: 10.40.0.22
      - name: HQ_network
        ipaddr: 10.11.0.0/16
        gateway: 10.40.0.11

routes:
  network.routes:
    - routes:
      - name: default
        ipaddr: default
        gateway: 172.16.82.1
      - name: test_net
        ipaddr: 10.222.0.0/24
        gateway: 10.2.0.222

Result:

local:
----------
          ID: system
    Function: network.system
      Result: True
     Comment: Global network settings are up to date.
     Started: 12:01:32.551018
    Duration: 133.025 ms
     Changes:   
              ----------
              network_settings:
                  --- 
                  +++ 
                  @@ -11,8 +11,8 @@
                   NETCONFIG_DNS_POLICY="auto"
                   NETCONFIG_DNS_FORWARDER="resolver"
                   NETCONFIG_DNS_FORWARDER_FALLBACK="yes"
                  -NETCONFIG_DNS_STATIC_SEARCHLIST=""
                  -NETCONFIG_DNS_STATIC_SERVERS=""
                  +NETCONFIG_DNS_STATIC_SEARCHLIST="tf.local demo.lab vzhestkov.net"
                  +NETCONFIG_DNS_STATIC_SERVERS="172.16.82.1 8.8.8.8 8.8.4.4"
                   NETCONFIG_DNS_RANKING="auto"
                   NETCONFIG_NTP_POLICY="auto"
                   NETCONFIG_NIS_POLICY="auto"
----------
          ID: eth1
    Function: network.managed
      Result: True
     Comment: Interface eth1 added.
     Started: 12:01:32.684302
    Duration: 295.086 ms
     Changes:   
              ----------
              interface:
                  Added network interface.
              status:
                  Interface eth1 is up
----------
          ID: eth2
    Function: network.managed
      Result: True
     Comment: Interface eth2 added.
     Started: 12:01:32.979723
    Duration: 414.275 ms
     Changes:   
              ----------
              interface:
                  Added network interface.
              status:
                  Interface eth2 is up
----------
          ID: bond0
    Function: network.managed
      Result: True
     Comment: Interface bond0 added.
     Started: 12:01:33.394726
    Duration: 3216.748 ms
     Changes:   
              ----------
              interface:
                  Added network interface.
              status:
                  Interface bond0 is up
----------
          ID: vlan10
    Function: network.managed
      Result: True
     Comment: Interface vlan10 added.
     Started: 12:01:36.612195
    Duration: 2639.309 ms
     Changes:   
              ----------
              interface:
                  Added network interface.
              status:
                  Interface vlan10 is up
----------
          ID: routes_vlan10
    Function: network.routes
        Name: vlan10
      Result: True
     Comment: Interface vlan10 routes added.
     Started: 12:01:39.252220
    Duration: 2268.239 ms
     Changes:   
              ----------
              network_routes:
                  Added interface vlan10 routes.
----------
          ID: routes
    Function: network.routes
      Result: True
     Comment: Interface routes routes are up to date.
     Started: 12:01:41.520919
    Duration: 3.606 ms
     Changes:   

Summary for local
------------
Succeeded: 7 (changed=6)
Failed:    0
------------
Total states run:     7
Total run time:   8.970 s

@vzhestkov vzhestkov requested a review from a team as a code owner August 10, 2021 08:02
@vzhestkov vzhestkov requested review from twangboy and removed request for a team August 10, 2021 08:02
s0undt3ch
s0undt3ch previously approved these changes Aug 14, 2021
Copy link
Member

@s0undt3ch s0undt3ch left a comment

Choose a reason for hiding this comment

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

Sorry for the long review.
Why raise AttributeError ? It's not trying to get or set attributes?
Or did I understand it incorrectly?

salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
tests/pytests/unit/modules/test_suse_ip.py Outdated Show resolved Hide resolved
@vzhestkov
Copy link
Contributor Author

@s0undt3ch, suggestions applied with the latest commits. Sorry for delay

salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
tests/pytests/unit/modules/test_suse_ip.py Outdated Show resolved Hide resolved
@garethgreenaway garethgreenaway added the Phosphorus v3005.0 Release code name and version label Apr 20, 2022
@garethgreenaway
Copy link
Contributor

@vzhestkov Thanks for the PR. This one needs a changelog.

salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
salt/modules/suse_ip.py Show resolved Hide resolved
@vzhestkov
Copy link
Contributor Author

Changelog entry and documentaion were added.

@Ch3LL
Copy link
Contributor

Ch3LL commented May 20, 2022

Pre-commit is failing here. Also @twangboy and @s0undt3ch can you re-review

salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
salt/modules/suse_ip.py Outdated Show resolved Hide resolved
Copy link
Member

@s0undt3ch s0undt3ch left a comment

Choose a reason for hiding this comment

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

Left some comments of thing that need to change.

salt/modules/suse_ip.py Outdated Show resolved Hide resolved
tests/pytests/unit/modules/test_suse_ip.py Outdated Show resolved Hide resolved
@vzhestkov
Copy link
Contributor Author

@s0undt3ch thanks, will try to address all the suggestions this week. The root cause of some of the points that basically it's a copy of rh_ip module, but with modifications which make sense for SUSE based distros as there are some differences in the configs.

@vzhestkov
Copy link
Contributor Author

@twangboy , @s0undt3ch just pushed the changes on your suggestions. Hope it sounds better now. Thanks for pointing issues.

@garethgreenaway garethgreenaway merged commit 2f71445 into saltstack:master May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Phosphorus v3005.0 Release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants