|
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 InterfaceType
|
|
Packit Service |
293802 |
from libnmstate.schema import MacVlan
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
from .base_iface import NisporPluginBaseIface
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
MACVLAN_FLAG_NOPROMISC = 1
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
MACVLAN_MODES = {
|
|
Packit Service |
293802 |
"unknown": MacVlan.Mode.UNKNOWN,
|
|
Packit Service |
293802 |
"vepa": MacVlan.Mode.VEPA,
|
|
Packit Service |
293802 |
"bridge": MacVlan.Mode.BRIDGE,
|
|
Packit Service |
293802 |
"private": MacVlan.Mode.PRIVATE,
|
|
Packit Service |
293802 |
"passthru": MacVlan.Mode.PASSTHRU,
|
|
Packit Service |
293802 |
"source": MacVlan.Mode.SOURCE,
|
|
Packit Service |
293802 |
}
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
class NisporPluginMacVlanIface(NisporPluginBaseIface):
|
|
Packit Service |
293802 |
@property
|
|
Packit Service |
293802 |
def type(self):
|
|
Packit Service |
293802 |
return InterfaceType.MAC_VLAN
|
|
Packit Service |
293802 |
|
|
Packit Service |
5e62f7 |
def to_dict(self, config_only):
|
|
Packit Service |
5e62f7 |
info = super().to_dict(config_only)
|
|
Packit Service |
293802 |
info[MacVlan.CONFIG_SUBTREE] = {
|
|
Packit Service |
293802 |
MacVlan.BASE_IFACE: self._np_iface.base_iface,
|
|
Packit Service |
293802 |
MacVlan.MODE: MACVLAN_MODES.get(
|
|
Packit Service |
293802 |
self._np_iface.mode, MacVlan.Mode.UNKNOWN
|
|
Packit Service |
293802 |
),
|
|
Packit Service |
293802 |
MacVlan.PROMISCUOUS: self._flag_to_promiscuous(
|
|
Packit Service |
293802 |
self._np_iface.mac_vlan_flags
|
|
Packit Service |
293802 |
),
|
|
Packit Service |
293802 |
}
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
return info
|
|
Packit Service |
293802 |
|
|
Packit Service |
293802 |
@staticmethod
|
|
Packit Service |
293802 |
def _flag_to_promiscuous(flags):
|
|
Packit Service |
293802 |
return (flags & MACVLAN_FLAG_NOPROMISC) == 0
|