|
Packit Service |
0535c1 |
#
|
|
Packit Service |
0535c1 |
# Copyright (c) 2018-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 |
import pkgutil
|
|
Packit Service |
0535c1 |
import yaml
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
def load(schema_name):
|
|
Packit Service |
0535c1 |
return yaml.load(
|
|
Packit Service |
0535c1 |
pkgutil.get_data("libnmstate", "schemas/" + schema_name + ".yaml"),
|
|
Packit Service |
0535c1 |
Loader=yaml.SafeLoader,
|
|
Packit Service |
0535c1 |
)
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
ifaces_schema = load("operational-state")
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Interface:
|
|
Packit Service |
0535c1 |
KEY = "interfaces"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
NAME = "name"
|
|
Packit Service |
0535c1 |
TYPE = "type"
|
|
Packit Service |
0535c1 |
STATE = "state"
|
|
Packit Service |
0535c1 |
DESCRIPTION = "description"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
IPV4 = "ipv4"
|
|
Packit Service |
0535c1 |
IPV6 = "ipv6"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
MAC = "mac-address"
|
|
Packit Service |
0535c1 |
MTU = "mtu"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Route:
|
|
Packit Service |
0535c1 |
KEY = "routes"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
RUNNING = "running"
|
|
Packit Service |
0535c1 |
CONFIG = "config"
|
|
Packit Service |
0535c1 |
STATE = "state"
|
|
Packit Service |
0535c1 |
STATE_ABSENT = "absent"
|
|
Packit Service |
0535c1 |
TABLE_ID = "table-id"
|
|
Packit Service |
0535c1 |
DESTINATION = "destination"
|
|
Packit Service |
0535c1 |
NEXT_HOP_INTERFACE = "next-hop-interface"
|
|
Packit Service |
0535c1 |
NEXT_HOP_ADDRESS = "next-hop-address"
|
|
Packit Service |
0535c1 |
METRIC = "metric"
|
|
Packit Service |
0535c1 |
USE_DEFAULT_METRIC = -1
|
|
Packit Service |
0535c1 |
USE_DEFAULT_ROUTE_TABLE = 0
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class RouteRule:
|
|
Packit Service |
0535c1 |
KEY = "route-rules"
|
|
Packit Service |
0535c1 |
CONFIG = "config"
|
|
Packit Service |
0535c1 |
IP_FROM = "ip-from"
|
|
Packit Service |
0535c1 |
IP_TO = "ip-to"
|
|
Packit Service |
0535c1 |
PRIORITY = "priority"
|
|
Packit Service |
0535c1 |
ROUTE_TABLE = "route-table"
|
|
Packit Service |
0535c1 |
USE_DEFAULT_PRIORITY = -1
|
|
Packit Service |
0535c1 |
USE_DEFAULT_ROUTE_TABLE = 0
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class DNS:
|
|
Packit Service |
0535c1 |
KEY = "dns-resolver"
|
|
Packit Service |
0535c1 |
RUNNING = "running"
|
|
Packit Service |
0535c1 |
CONFIG = "config"
|
|
Packit Service |
0535c1 |
SERVER = "server"
|
|
Packit Service |
0535c1 |
SEARCH = "search"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Constants:
|
|
Packit Service |
0535c1 |
INTERFACES = Interface.KEY
|
|
Packit Service |
0535c1 |
ROUTES = Route.KEY
|
|
Packit Service |
0535c1 |
DNS = DNS.KEY
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class InterfaceState:
|
|
Packit Service |
0535c1 |
KEY = Interface.STATE
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
DOWN = "down"
|
|
Packit Service |
0535c1 |
UP = "up"
|
|
Packit Service |
0535c1 |
ABSENT = "absent"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class InterfaceType:
|
|
Packit Service |
0535c1 |
KEY = Interface.TYPE
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
BOND = "bond"
|
|
Packit Service |
0535c1 |
DUMMY = "dummy"
|
|
Packit Service |
0535c1 |
ETHERNET = "ethernet"
|
|
Packit Service |
0535c1 |
LINUX_BRIDGE = "linux-bridge"
|
|
Packit Service |
0535c1 |
OVS_BRIDGE = "ovs-bridge"
|
|
Packit Service |
0535c1 |
OVS_INTERFACE = "ovs-interface"
|
|
Packit Service |
0535c1 |
OVS_PORT = "ovs-port"
|
|
Packit Service |
0535c1 |
UNKNOWN = "unknown"
|
|
Packit Service |
0535c1 |
VLAN = "vlan"
|
|
Packit Service |
0535c1 |
VXLAN = "vxlan"
|
|
Packit Service |
0535c1 |
TEAM = "team"
|
|
Packit Service |
0535c1 |
OTHER = "other"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
VIRT_TYPES = (
|
|
Packit Service |
0535c1 |
BOND,
|
|
Packit Service |
0535c1 |
DUMMY,
|
|
Packit Service |
0535c1 |
LINUX_BRIDGE,
|
|
Packit Service |
0535c1 |
OVS_BRIDGE,
|
|
Packit Service |
0535c1 |
OVS_PORT,
|
|
Packit Service |
0535c1 |
OVS_INTERFACE,
|
|
Packit Service |
0535c1 |
TEAM,
|
|
Packit Service |
0535c1 |
VLAN,
|
|
Packit Service |
0535c1 |
VXLAN,
|
|
Packit Service |
0535c1 |
)
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class InterfaceIP:
|
|
Packit Service |
0535c1 |
ENABLED = "enabled"
|
|
Packit Service |
0535c1 |
ADDRESS = "address"
|
|
Packit Service |
0535c1 |
ADDRESS_IP = "ip"
|
|
Packit Service |
0535c1 |
ADDRESS_PREFIX_LENGTH = "prefix-length"
|
|
Packit Service |
0535c1 |
DHCP = "dhcp"
|
|
Packit Service |
0535c1 |
AUTO_DNS = "auto-dns"
|
|
Packit Service |
0535c1 |
AUTO_GATEWAY = "auto-gateway"
|
|
Packit Service |
0535c1 |
AUTO_ROUTES = "auto-routes"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class InterfaceIPv4(InterfaceIP):
|
|
Packit Service |
0535c1 |
pass
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class InterfaceIPv6(InterfaceIP):
|
|
Packit Service |
0535c1 |
AUTOCONF = "autoconf"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Bond:
|
|
Packit Service |
0535c1 |
KEY = InterfaceType.BOND
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = "link-aggregation"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
MODE = "mode"
|
|
Packit Service |
0535c1 |
SLAVES = "slaves"
|
|
Packit Service |
0535c1 |
OPTIONS_SUBTREE = "options"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class BondMode:
|
|
Packit Service |
0535c1 |
ROUND_ROBIN = "balance-rr"
|
|
Packit Service |
0535c1 |
ACTIVE_BACKUP = "active-backup"
|
|
Packit Service |
0535c1 |
XOR = "balance-xor"
|
|
Packit Service |
0535c1 |
BROADCAST = "broadcast"
|
|
Packit Service |
0535c1 |
LACP = "802.3ad"
|
|
Packit Service |
0535c1 |
TLB = "balance-tlb"
|
|
Packit Service |
0535c1 |
ALB = "balance-alb"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Bridge:
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = "bridge"
|
|
Packit Service |
0535c1 |
OPTIONS_SUBTREE = "options"
|
|
Packit Service |
0535c1 |
PORT_SUBTREE = "port"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Port:
|
|
Packit Service |
0535c1 |
NAME = "name"
|
|
Packit Service |
0535c1 |
VLAN_SUBTREE = "vlan"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Vlan:
|
|
Packit Service |
0535c1 |
ENABLE_NATIVE = "enable-native"
|
|
Packit Service |
0535c1 |
TRUNK_TAGS = "trunk-tags"
|
|
Packit Service |
0535c1 |
MODE = "mode"
|
|
Packit Service |
0535c1 |
TAG = "tag"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Mode:
|
|
Packit Service |
0535c1 |
ACCESS = "access"
|
|
Packit Service |
0535c1 |
TRUNK = "trunk"
|
|
Packit Service |
0535c1 |
UNKNOWN = "unknown"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class TrunkTags:
|
|
Packit Service |
0535c1 |
ID = "id"
|
|
Packit Service |
0535c1 |
ID_RANGE = "id-range"
|
|
Packit Service |
0535c1 |
MIN_RANGE = "min"
|
|
Packit Service |
0535c1 |
MAX_RANGE = "max"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class LinuxBridge(Bridge):
|
|
Packit Service |
0535c1 |
TYPE = "linux-bridge"
|
|
Packit Service |
0535c1 |
STP_SUBTREE = "stp"
|
|
Packit Service |
0535c1 |
MULTICAST_SUBTREE = "multicast"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Options:
|
|
Packit Service |
0535c1 |
GROUP_FORWARD_MASK = "group-forward-mask"
|
|
Packit Service |
0535c1 |
MAC_AGEING_TIME = "mac-ageing-time"
|
|
Packit Service |
0535c1 |
MULTICAST_SNOOPING = "multicast-snooping"
|
|
Packit Service |
0535c1 |
GROUP_ADDR = "group-addr"
|
|
Packit Service |
0535c1 |
GROUP_FWD_MASK = "group-fwd-mask"
|
|
Packit Service |
0535c1 |
HASH_ELASTICITY = "hash-elasticity"
|
|
Packit Service |
0535c1 |
HASH_MAX = "hash-max"
|
|
Packit Service |
0535c1 |
MULTICAST_ROUTER = "multicast-router"
|
|
Packit Service |
0535c1 |
MULTICAST_LAST_MEMBER_COUNT = "multicast-last-member-count"
|
|
Packit Service |
0535c1 |
MULTICAST_LAST_MEMBER_INTERVAL = "multicast-last-member-interval"
|
|
Packit Service |
0535c1 |
MULTICAST_MEMBERSHIP_INTERVAL = "multicast-membership-interval"
|
|
Packit Service |
0535c1 |
MULTICAST_QUERIER = "multicast-querier"
|
|
Packit Service |
0535c1 |
MULTICAST_QUERIER_INTERVAL = "multicast-querier-interval"
|
|
Packit Service |
0535c1 |
MULTICAST_QUERY_USE_IFADDR = "multicast-query-use-ifaddr"
|
|
Packit Service |
0535c1 |
MULTICAST_QUERY_INTERVAL = "multicast-query-interval"
|
|
Packit Service |
0535c1 |
MULTICAST_QUERY_RESPONSE_INTERVAL = "multicast-query-response-interval"
|
|
Packit Service |
0535c1 |
MULTICAST_STARTUP_QUERY_COUNT = "multicast-startup-query-count"
|
|
Packit Service |
0535c1 |
MULTICAST_STARTUP_QUERY_INTERVAL = "multicast-startup-query-interval"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
# Read only properties begin
|
|
Packit Service |
0535c1 |
HELLO_TIMER = "hello-timer"
|
|
Packit Service |
0535c1 |
GC_TIMER = "gc-timer"
|
|
Packit Service |
0535c1 |
# Read only properties end
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Port(Bridge.Port):
|
|
Packit Service |
0535c1 |
STP_HAIRPIN_MODE = "stp-hairpin-mode"
|
|
Packit Service |
0535c1 |
STP_PATH_COST = "stp-path-cost"
|
|
Packit Service |
0535c1 |
STP_PRIORITY = "stp-priority"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class STP:
|
|
Packit Service |
0535c1 |
ENABLED = "enabled"
|
|
Packit Service |
0535c1 |
FORWARD_DELAY = "forward-delay"
|
|
Packit Service |
0535c1 |
HELLO_TIME = "hello-time"
|
|
Packit Service |
0535c1 |
MAX_AGE = "max-age"
|
|
Packit Service |
0535c1 |
PRIORITY = "priority"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Ethernet:
|
|
Packit Service |
0535c1 |
TYPE = InterfaceType.ETHERNET
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = "ethernet"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
AUTO_NEGOTIATION = "auto-negotiation"
|
|
Packit Service |
0535c1 |
SPEED = "speed"
|
|
Packit Service |
0535c1 |
DUPLEX = "duplex"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
FULL_DUPLEX = "full"
|
|
Packit Service |
0535c1 |
HALF_DUPLEX = "half"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
SRIOV_SUBTREE = "sr-iov"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class SRIOV:
|
|
Packit Service |
0535c1 |
TOTAL_VFS = "total-vfs"
|
|
Packit Service |
0535c1 |
VFS_SUBTREE = "vfs"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class VFS:
|
|
Packit Service |
0535c1 |
ID = "id"
|
|
Packit Service |
0535c1 |
MAC_ADDRESS = "mac-address"
|
|
Packit Service |
0535c1 |
SPOOF_CHECK = "spoof-check"
|
|
Packit Service |
0535c1 |
TRUST = "trust"
|
|
Packit Service |
0535c1 |
MIN_TX_RATE = "min-tx-rate"
|
|
Packit Service |
0535c1 |
MAX_TX_RATE = "max-tx-rate"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class VLAN:
|
|
Packit Service |
0535c1 |
TYPE = InterfaceType.VLAN
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = "vlan"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
ID = "id"
|
|
Packit Service |
0535c1 |
BASE_IFACE = "base-iface"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class VXLAN:
|
|
Packit Service |
0535c1 |
TYPE = InterfaceType.VXLAN
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = "vxlan"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
ID = "id"
|
|
Packit Service |
0535c1 |
BASE_IFACE = "base-iface"
|
|
Packit Service |
0535c1 |
REMOTE = "remote"
|
|
Packit Service |
0535c1 |
DESTINATION_PORT = "destination-port"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class OvsDB:
|
|
Packit Service |
0535c1 |
OVS_DB_SUBTREE = "ovs-db"
|
|
Packit Service |
0535c1 |
# Don't use hypen as this is OVS data base entry
|
|
Packit Service |
0535c1 |
EXTERNAL_IDS = "external_ids"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class OVSInterface(OvsDB):
|
|
Packit Service |
0535c1 |
TYPE = InterfaceType.OVS_INTERFACE
|
|
Packit Service |
0535c1 |
PATCH_CONFIG_SUBTREE = "patch"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Patch:
|
|
Packit Service |
0535c1 |
PEER = "peer"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class OVSBridge(Bridge, OvsDB):
|
|
Packit Service |
0535c1 |
TYPE = "ovs-bridge"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Options:
|
|
Packit Service |
0535c1 |
FAIL_MODE = "fail-mode"
|
|
Packit Service |
0535c1 |
MCAST_SNOOPING_ENABLED = "mcast-snooping-enable"
|
|
Packit Service |
0535c1 |
RSTP = "rstp"
|
|
Packit Service |
0535c1 |
STP = "stp"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Port(Bridge.Port):
|
|
Packit Service |
0535c1 |
LINK_AGGREGATION_SUBTREE = "link-aggregation"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class LinkAggregation:
|
|
Packit Service |
0535c1 |
MODE = "mode"
|
|
Packit Service |
0535c1 |
SLAVES_SUBTREE = "slaves"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Slave:
|
|
Packit Service |
0535c1 |
NAME = "name"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Options:
|
|
Packit Service |
0535c1 |
DOWN_DELAY = "bond-downdelay"
|
|
Packit Service |
0535c1 |
UP_DELAY = "bond-updelay"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Mode:
|
|
Packit Service |
0535c1 |
ACTIVE_BACKUP = "active-backup"
|
|
Packit Service |
0535c1 |
BALANCE_SLB = "balance-slb"
|
|
Packit Service |
0535c1 |
BALANCE_TCP = "balance-tcp"
|
|
Packit Service |
0535c1 |
LACP = "lacp"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Team:
|
|
Packit Service |
0535c1 |
TYPE = InterfaceType.TEAM
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = InterfaceType.TEAM
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
PORT_SUBTREE = "ports"
|
|
Packit Service |
0535c1 |
RUNNER_SUBTREE = "runner"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Port:
|
|
Packit Service |
0535c1 |
NAME = "name"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Runner:
|
|
Packit Service |
0535c1 |
NAME = "name"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class RunnerMode:
|
|
Packit Service |
0535c1 |
LOAD_BALANCE = "loadbalance"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class LLDP:
|
|
Packit Service |
0535c1 |
CONFIG_SUBTREE = "lldp"
|
|
Packit Service |
0535c1 |
ENABLED = "enabled"
|
|
Packit Service |
0535c1 |
NEIGHBORS_SUBTREE = "neighbors"
|
|
Packit Service |
0535c1 |
|
|
Packit Service |
0535c1 |
class Neighbors:
|
|
Packit Service |
0535c1 |
DESCRIPTION = "_description"
|
|
Packit Service |
0535c1 |
TLV_TYPE = "type"
|
|
Packit Service |
0535c1 |
TLV_SUBTYPE = "subtype"
|
|
Packit Service |
0535c1 |
ORGANIZATION_CODE = "oui"
|