Skip to content

suse_ip module implementation - #60702

Merged
garethgreenaway merged 10 commits into
saltstack:masterfrom
vzhestkov:suse_ip
May 26, 2022
Merged

garethgreenaway merged 10 commits into
saltstack:masterfrom
vzhestkov:suse_ip

Conversation

@vzhestkov

Copy link
Copy Markdown
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

@s0undt3ch s0undt3ch left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread tests/pytests/unit/modules/test_suse_ip.py Outdated
@vzhestkov

Copy link
Copy Markdown
Contributor Author

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

@vzhestkov
vzhestkov requested a review from s0undt3ch August 19, 2021 07:32
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread tests/pytests/unit/modules/test_suse_ip.py Outdated
@garethgreenaway garethgreenaway added the Phosphorus v3005.0 Release code name and version label Apr 20, 2022
@garethgreenaway

Copy link
Copy Markdown
Contributor

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

Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
@vzhestkov

Copy link
Copy Markdown
Contributor Author

Changelog entry and documentaion were added.

@Ch3LL

Ch3LL commented May 20, 2022

Copy link
Copy Markdown
Contributor

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

Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated
Comment thread salt/modules/suse_ip.py Outdated

@s0undt3ch s0undt3ch left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread salt/modules/suse_ip.py Outdated
Comment thread tests/pytests/unit/modules/test_suse_ip.py Outdated
@vzhestkov

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

@vzhestkov
vzhestkov requested review from s0undt3ch and twangboy May 26, 2022 13:35
@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.

5 participants