inclusive language: use "port" instead of "slave"

In order to promote a diverse and inclusive environment we are replacing
all the reference to "slave" for "port".

Test case added.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
This commit is contained in:
Fernando Fernandez Mancera 2021-02-01 23:13:06 +01:00 committed by Fernando Fernández Mancera
parent a283e47c12
commit 3167b3c125
8 changed files with 102 additions and 73 deletions

View file

@ -210,7 +210,7 @@ Note that the `speed` and `duplex` link settings are required when autonegotiati
The `bridge`, `bond`, `team` device types work similar. Note that `team` is not supported in RHEL6 kernels.
For slaves, the `slave_type` and `controller` properties must be set. Note that slaves should not have `ip` settings.
For ports, the `port_type` and `controller` properties must be set. Note that ports should not have `ip` settings.
The `controller` refers to the `name` of a profile in the Ansible
playbook. It is neither an interface-name nor a connection-id of
@ -622,7 +622,7 @@ network_connections:
auto6: no
```
Setting `controller` and `slave_type`:
Setting `controller` and `port_type`:
```yaml
network_connections:
@ -630,13 +630,13 @@ network_connections:
type: bond
interface_name: bond0
controller: internal-br0
slave_type: bridge
port_type: bridge
- name: br0-bond0-eth1
type: ethernet
interface_name: eth1
controller: br0-bond0
slave_type: bond
port_type: bond
```
Configuring VLANs:
@ -809,7 +809,7 @@ components that rely on the ifcfg files and react on changes.
The `initscripts` provider requires the different profiles to be in the right
order when they depend on each other. For example the bonding controller device
needs to be specified before the slave devices.
needs to be specified before the port devices.
When removing a profile for NetworkManager it also takes the connection
down and possibly removes virtual interfaces. With the `initscripts` provider

View file

@ -16,8 +16,8 @@
mode: active-backup
miimon: 110
# enslave an ethernet to the bond
- name: prod2-slave1
# set an ethernet as port to the bond
- name: prod2-port1
state: up
type: ethernet
interface_name: "{{ network_interface_name2 }}"

View file

@ -13,13 +13,13 @@
dhcp4: no
auto6: no
# enslave an ethernet to the bridge
- name: prod2-slave1
# set an ethernet port to the bridge
- name: prod2-port1
state: up
type: ethernet
interface_name: "{{ network_interface_name2 }}"
controller: prod2
slave_type: bridge
port_type: bridge
# on top of it, create a VLAN with ID 100 and static
# addressing

View file

@ -428,19 +428,19 @@ class IfcfgUtil:
m = ArgUtil.connection_find_controller(
connection["controller"], connections, idx
)
if connection["slave_type"] == "bridge":
if connection["port_type"] == "bridge":
ifcfg["BRIDGE"] = m
elif connection["slave_type"] == "bond":
elif connection["port_type"] == "bond":
ifcfg["MASTER"] = m
ifcfg["SLAVE"] = "yes"
elif connection["slave_type"] == "team":
elif connection["port_type"] == "team":
ifcfg["TEAM_MASTER"] = m
if "TYPE" in ifcfg:
del ifcfg["TYPE"]
if connection["type"] != "team":
ifcfg["DEVICETYPE"] = "TeamPort"
else:
raise MyError("invalid slave_type '%s'" % (connection["slave_type"]))
raise MyError("invalid port_type '%s'" % (connection["port_type"]))
if ip["route_append_only"] and content_current:
route4_file = content_current["route"]
@ -949,7 +949,7 @@ class NMUtil:
if connection["controller"] is not None:
s_con.set_property(
NM.SETTING_CONNECTION_SLAVE_TYPE, connection["slave_type"]
NM.SETTING_CONNECTION_SLAVE_TYPE, connection["port_type"]
)
s_con.set_property(
NM.SETTING_CONNECTION_MASTER,
@ -1267,7 +1267,7 @@ class NMUtil:
):
# controller connections qualify as activated once they
# reach IP-Config state. That is because they may
# wait for slave devices to attach
# wait for port devices to attach
return True, None
# fall through
elif ac_state == NM.ActiveConnectionState.ACTIVATED:

View file

@ -1180,7 +1180,7 @@ class ArgValidator_DictConnection(ArgValidatorDict):
"wireless",
"dummy",
]
VALID_SLAVE_TYPES = ["bridge", "bond", "team"]
VALID_PORT_TYPES = ["bridge", "bond", "team"]
def __init__(self):
ArgValidatorDict.__init__(
@ -1208,8 +1208,12 @@ class ArgValidator_DictConnection(ArgValidatorDict):
),
ArgValidatorBool("autoconnect", default_value=True),
ArgValidatorStr(
"port_type",
enum_values=ArgValidator_DictConnection.VALID_PORT_TYPES,
),
ArgValidatorDeprecated(
"slave_type",
enum_values=ArgValidator_DictConnection.VALID_SLAVE_TYPES,
deprecated_by="port_type",
),
ArgValidatorStr("controller"),
ArgValidatorDeprecated("master", deprecated_by="controller"),
@ -1403,23 +1407,23 @@ class ArgValidator_DictConnection(ArgValidatorDict):
if "type" in result:
if "controller" in result:
if "slave_type" not in result:
result["slave_type"] = None
if "port_type" not in result:
result["port_type"] = None
if result["controller"] == result["name"]:
raise ValidationError(
name + ".controller", '"controller" cannot refer to itself'
)
else:
if "slave_type" in result:
if "port_type" in result:
raise ValidationError(
name + ".slave_type",
"'slave_type' requires a 'controller' property",
name + ".port_type",
"'port_type' requires a 'controller' property",
)
if "ip" in result:
if "controller" in result:
raise ValidationError(
name + ".ip", 'a slave cannot have an "ip" property'
name + ".ip", 'a port cannot have an "ip" property'
)
else:
if "controller" not in result:
@ -1428,7 +1432,7 @@ class ArgValidator_DictConnection(ArgValidatorDict):
if "zone" in result:
if "controller" in result:
raise ValidationError(
name + ".zone", '"zone" cannot be configured for slave types'
name + ".zone", '"zone" cannot be configured for port types'
)
else:
result["zone"] = None
@ -1657,24 +1661,24 @@ class ArgValidator_ListConnections(ArgValidatorList):
"references non-existing 'controller' connection '%s'"
% (connection["controller"]),
)
if c["type"] not in ArgValidator_DictConnection.VALID_SLAVE_TYPES:
if c["type"] not in ArgValidator_DictConnection.VALID_PORT_TYPES:
raise ValidationError(
name + "[" + str(idx) + "].controller",
"references 'controller' connection '%s' which is "
"not a controller "
"type by '%s'" % (connection["controller"], c["type"]),
)
if connection["slave_type"] is None:
connection["slave_type"] = c["type"]
elif connection["slave_type"] != c["type"]:
if connection["port_type"] is None:
connection["port_type"] = c["type"]
elif connection["port_type"] != c["type"]:
raise ValidationError(
name + "[" + str(idx) + "].controller",
"references 'controller' connection '%s' which is "
"of type '%s' instead of slave_type '%s'"
"of type '%s' instead of port_type '%s'"
% (
connection["controller"],
c["type"],
connection["slave_type"],
connection["port_type"],
),
)
if connection["parent"]:

View file

@ -18,7 +18,7 @@ PRIORITIES = (
"state",
"persistent_state",
"controller",
"slave_type",
"port_type",
"parent",
"ignore_errors",
"force_state_change",

View file

@ -4,9 +4,9 @@
vars:
controller_profile: bond0
controller_device: nm-bond
slave1_profile: bond0.0
port1_profile: bond0.0
dhcp_interface1: test1
slave2_profile: bond0.1
port2_profile: bond0.1
dhcp_interface2: test2
tasks:
- name: "INIT Prepare setup"
@ -20,7 +20,7 @@
vars:
interface: "{{ dhcp_interface2 }}"
- block:
- name: "TEST Add Bond with 2 slaves"
- name: "TEST Add Bond with 2 ports"
debug:
msg: "##################################################"
- import_role:
@ -36,13 +36,13 @@
mode: active-backup
miimon: 110
# add an ethernet to the bond
- name: "{{ slave1_profile }}"
- name: "{{ port1_profile }}"
state: up
type: ethernet
interface_name: "{{ dhcp_interface1 }}"
controller: "{{ controller_profile }}"
# add a second ethernet to the bond
- name: "{{ slave2_profile }}"
- name: "{{ port2_profile }}"
state: up
type: ethernet
interface_name: "{{ dhcp_interface2 }}"
@ -55,8 +55,8 @@
profile: "{{ item }}"
loop:
- "{{ controller_profile }}"
- "{{ slave1_profile }}"
- "{{ slave2_profile }}"
- "{{ port1_profile }}"
- "{{ port2_profile }}"
- command: grep 'Polling Interval'
/proc/net/bonding/{{ controller_device }}
name: "** TEST check polling interval"
@ -80,10 +80,10 @@
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ slave2_profile }}"
- name: "{{ port2_profile }}"
persistent_state: absent
state: down
- name: "{{ slave1_profile }}"
- name: "{{ port1_profile }}"
persistent_state: absent
state: down
- name: "{{ controller_profile }}"

View file

@ -180,7 +180,7 @@ class TestValidator(unittest.TestCase):
"mtu": None,
"name": "5",
"parent": None,
"slave_type": None,
"port_type": None,
"zone": None,
}
@ -473,7 +473,7 @@ class TestValidator(unittest.TestCase):
"name": "5",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": None,
"type": "ethernet",
"zone": None,
@ -526,7 +526,7 @@ class TestValidator(unittest.TestCase):
"name": "5",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -573,7 +573,7 @@ class TestValidator(unittest.TestCase):
"name": "5",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -663,7 +663,7 @@ class TestValidator(unittest.TestCase):
"name": "prod1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -727,7 +727,7 @@ class TestValidator(unittest.TestCase):
"name": "prod1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -793,7 +793,7 @@ class TestValidator(unittest.TestCase):
"name": "prod1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -851,7 +851,7 @@ class TestValidator(unittest.TestCase):
"name": "prod.100",
"parent": "prod1",
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "vlan",
"vlan": {"id": 100},
@ -936,7 +936,7 @@ class TestValidator(unittest.TestCase):
"name": "prod1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -994,7 +994,7 @@ class TestValidator(unittest.TestCase):
"name": "prod.100",
"parent": "prod1",
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "vlan",
"vlan": {"id": 101},
@ -1074,7 +1074,7 @@ class TestValidator(unittest.TestCase):
"name": "eth0-parent",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -1127,7 +1127,7 @@ class TestValidator(unittest.TestCase):
"name": "veth0.0",
"parent": "eth0-parent",
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "macvlan",
"wait": None,
@ -1180,7 +1180,7 @@ class TestValidator(unittest.TestCase):
"name": "veth0.1",
"parent": "eth0-parent",
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "macvlan",
"wait": None,
@ -1268,7 +1268,7 @@ class TestValidator(unittest.TestCase):
"name": "prod2",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "bridge",
"wait": None,
@ -1304,10 +1304,10 @@ class TestValidator(unittest.TestCase):
"ieee802_1x": None,
"wireless": None,
"mtu": None,
"name": "prod2-slave1",
"name": "prod2-port1",
"parent": None,
"persistent_state": "present",
"slave_type": "bridge",
"port_type": "bridge",
"state": "up",
"type": "ethernet",
"wait": None,
@ -1323,7 +1323,7 @@ class TestValidator(unittest.TestCase):
"ip": {"dhcp4": False, "auto6": False},
},
{
"name": "prod2-slave1",
"name": "prod2-port1",
"state": "up",
"type": "ethernet",
"interface_name": "eth1",
@ -1370,7 +1370,7 @@ class TestValidator(unittest.TestCase):
"name": "bond1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "bond",
"wait": None,
@ -1418,7 +1418,7 @@ class TestValidator(unittest.TestCase):
"name": "bond1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "bond",
"wait": None,
@ -1476,7 +1476,7 @@ class TestValidator(unittest.TestCase):
"name": "5",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": None,
"type": "ethernet",
"zone": None,
@ -1522,7 +1522,7 @@ class TestValidator(unittest.TestCase):
"name": "5",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -1596,7 +1596,7 @@ class TestValidator(unittest.TestCase):
"name": "6643-controller",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "bridge",
"wait": None,
@ -1635,7 +1635,7 @@ class TestValidator(unittest.TestCase):
"name": "6643",
"parent": None,
"persistent_state": "present",
"slave_type": "bridge",
"port_type": "bridge",
"state": "up",
"type": "ethernet",
"wait": None,
@ -1690,7 +1690,7 @@ class TestValidator(unittest.TestCase):
"name": "infiniband.1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "infiniband",
"wait": None,
@ -1763,7 +1763,7 @@ class TestValidator(unittest.TestCase):
"name": "infiniband.2",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "infiniband",
"wait": None,
@ -1856,7 +1856,7 @@ class TestValidator(unittest.TestCase):
"name": "555",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -1957,7 +1957,7 @@ class TestValidator(unittest.TestCase):
"name": "e556",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -2082,7 +2082,7 @@ class TestValidator(unittest.TestCase):
"name": "eth0",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -2158,7 +2158,7 @@ class TestValidator(unittest.TestCase):
"name": "eth0",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -2234,7 +2234,7 @@ class TestValidator(unittest.TestCase):
"name": "eth0",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "ethernet",
"wait": None,
@ -2301,7 +2301,7 @@ class TestValidator(unittest.TestCase):
"name": "wireless1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "wireless",
"wait": None,
@ -2376,7 +2376,7 @@ class TestValidator(unittest.TestCase):
"name": "wireless1",
"parent": None,
"persistent_state": "present",
"slave_type": None,
"port_type": None,
"state": "up",
"type": "wireless",
"wait": None,
@ -3205,6 +3205,31 @@ class TestValidator(unittest.TestCase):
self.assertTrue("controller" in connection)
self.assertTrue("master" not in connection)
def test_set_deprecated_slave_type(self):
"""
When passing the deprecated "slave_type" it is updated to "port_type".
"""
input_connections = [
{
"name": "prod2",
"state": "up",
"type": "bridge",
},
{
"name": "prod2-port1",
"state": "up",
"type": "ethernet",
"interface_name": "eth1",
"controller": "prod2",
"slave_type": "bridge",
},
]
connections = ARGS_CONNECTIONS.validate(input_connections)
self.assertTrue(len(connections) == 2)
for connection in connections:
self.assertTrue("port_type" in connection)
self.assertTrue("slave_type" not in connection)
@my_test_skipIf(nmutil is None, "no support for NM (libnm via pygobject)")
class TestNM(unittest.TestCase):