|
Packit Service |
293802 |
#
|
|
Packit Service |
293802 |
# Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
293802 |
#
|
|
Packit Service |
293802 |
# This file is part of nmstate
|
|
Packit Service |
293802 |
#
|
|
Packit Service |
293802 |
# This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
293802 |
# it under the terms of the GNU Lesser General Public License as published by
|
|
Packit Service |
293802 |
# the Free Software Foundation, either version 2.1 of the License, or
|
|
Packit Service |
293802 |
# (at your option) any later version.
|
|
Packit Service |
293802 |
#
|
|
Packit Service |
293802 |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
293802 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
293802 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
293802 |
# GNU Lesser General Public License for more details.
|
|
Packit Service |
293802 |
#
|
|
Packit Service |
293802 |
# You should have received a copy of the GNU Lesser General Public License
|
|
Packit Service |
293802 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
Packit Service |
293802 |
#
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
from libnmstate.schema import Ethernet
|
|
Packit Service |
293802 |
from libnmstate.schema import InterfaceType
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
from .base_iface import NisporPluginBaseIface
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
class NisporPluginEthernetIface(NisporPluginBaseIface):
|
|
Packit Service |
293802 |
@property
|
|
Packit Service |
293802 |
def type(self):
|
|
Packit Service |
293802 |
return InterfaceType.ETHERNET
|
|
Packit Service |
293802 |
|
|
Packit Service |
5e62f7 |
def to_dict(self, config_only):
|
|
Packit Service |
5e62f7 |
info = super().to_dict(config_only)
|
|
Packit Service |
293802 |
if self.np_iface.sr_iov:
|
|
Packit Service |
293802 |
vf_infos = []
|
|
Packit Service |
293802 |
for vf in self.np_iface.sr_iov.vfs:
|
|
Packit Service |
293802 |
vf_infos.append(
|
|
Packit Service |
293802 |
{
|
|
Packit Service |
293802 |
Ethernet.SRIOV.VFS.ID: vf.vf_id,
|
|
Packit Service |
5e62f7 |
Ethernet.SRIOV.VFS.MAC_ADDRESS: vf.mac.upper(),
|
|
Packit Service |
293802 |
Ethernet.SRIOV.VFS.SPOOF_CHECK: vf.spoof_check,
|
|
Packit Service |
293802 |
Ethernet.SRIOV.VFS.TRUST: vf.trust,
|
|
Packit Service |
293802 |
Ethernet.SRIOV.VFS.MIN_TX_RATE: vf.min_tx_rate,
|
|
Packit Service |
293802 |
Ethernet.SRIOV.VFS.MAX_TX_RATE: vf.max_tx_rate,
|
|
Packit Service |
293802 |
}
|
|
Packit Service |
293802 |
)
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
sriov_info = {
|
|
Packit Service |
293802 |
Ethernet.SRIOV.TOTAL_VFS: len(self.np_iface.sr_iov.vfs),
|
|
Packit Service |
293802 |
Ethernet.SRIOV.VFS_SUBTREE: vf_infos,
|
|
Packit Service |
293802 |
}
|
|
Packit Service |
293802 |
info[Ethernet.CONFIG_SUBTREE] = {
|
|
Packit Service |
293802 |
Ethernet.SRIOV_SUBTREE: sriov_info
|
|
Packit Service |
293802 |
}
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
return info
|