|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
# Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
# This file is part of nmstate
|
|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
# This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
0535c1 |
# it under the terms of the GNU Lesser General Public License as published by
|
|
Packit Service |
0535c1 |
# the Free Software Foundation, either version 2.1 of the License, or
|
|
Packit Service |
0535c1 |
# (at your option) any later version.
|
|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
0535c1 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
0535c1 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
0535c1 |
# GNU Lesser General Public License for more details.
|
|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
# You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
0535c1 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
from libnmstate.schema import Ethernet
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
from .base_iface import BaseIface
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class EthernetIface(BaseIface):
|
|
Packit Service |
0535c1 |
def merge(self, other):
|
|
Packit Service |
0535c1 |
"""
|
|
Packit Service |
0535c1 |
Given the other_state, update the ethernet interfaces state base on
|
|
Packit Service |
0535c1 |
the other_state ethernet interfaces data.
|
|
Packit Service |
0535c1 |
Usually the other_state represents the current state.
|
|
Packit Service |
0535c1 |
If auto-negotiation, speed and duplex settings are not provided,
|
|
Packit Service |
0535c1 |
but exist in the current state, they need to be set to None
|
|
Packit Service |
0535c1 |
to not override them with the values from the current settings
|
|
Packit Service |
0535c1 |
since the current settings are read from the device state and not
|
|
Packit Service |
0535c1 |
from the actual configuration. This makes it possible to distinguish
|
|
Packit Service |
0535c1 |
whether a user specified these values in the later configuration step.
|
|
Packit Service |
0535c1 |
"""
|
|
Packit Service |
0535c1 |
eth_conf = self._info.setdefault(Ethernet.CONFIG_SUBTREE, {})
|
|
Packit Service |
0535c1 |
eth_conf.setdefault(Ethernet.AUTO_NEGOTIATION, None)
|
|
Packit Service |
0535c1 |
eth_conf.setdefault(Ethernet.SPEED, None)
|
|
Packit Service |
0535c1 |
eth_conf.setdefault(Ethernet.DUPLEX, None)
|
|
Packit Service |
0535c1 |
super().merge(other)
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
def state_for_verify(self):
|
|
Packit Service |
0535c1 |
state = super().state_for_verify()
|
|
Packit Service |
0535c1 |
_capitalize_sriov_vf_mac(state)
|
|
Packit Service |
0535c1 |
return state
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
def _capitalize_sriov_vf_mac(state):
|
|
Packit Service |
0535c1 |
vfs = (
|
|
Packit Service |
0535c1 |
state.get(Ethernet.CONFIG_SUBTREE, {})
|
|
Packit Service |
0535c1 |
.get(Ethernet.SRIOV_SUBTREE, {})
|
|
Packit Service |
0535c1 |
.get(Ethernet.SRIOV.VFS_SUBTREE, [])
|
|
Packit Service |
0535c1 |
)
|
|
Packit Service |
0535c1 |
for vf in vfs:
|
|
Packit Service |
0535c1 |
vf_mac = vf.get(Ethernet.SRIOV.VFS.MAC_ADDRESS)
|
|
Packit Service |
0535c1 |
if vf_mac:
|
|
Packit Service |
0535c1 |
vf[Ethernet.SRIOV.VFS.MAC_ADDRESS] = vf_mac.upper()
|