schema constants: Update the constant list
Add new content and refactor a bit the constants. Signed-off-by: Edward Haas <edwardh@redhat.com>
This commit is contained in:
parent
6f9b4801cf
commit
a2f08a9db2
@ -30,6 +30,7 @@ from libnmstate.appliers import linux_bridge
|
||||
from libnmstate.nm import nmclient
|
||||
from libnmstate.prettystate import format_desired_current_state_diff
|
||||
from libnmstate.schema import Constants
|
||||
from libnmstate.schema import InterfaceType
|
||||
|
||||
|
||||
class ApplyError(Exception):
|
||||
@ -405,7 +406,7 @@ def _remove_down_virt_iface_entries(ifaces_desired_state):
|
||||
for ifname, ifstate in six.viewitems(ifaces_desired_state):
|
||||
is_virt_down = (
|
||||
ifstate.get('state') == 'down' and
|
||||
ifstate.get('type') in Constants.VIRT_IFACE_TYPES
|
||||
ifstate.get('type') in InterfaceType.VIRT_TYPES
|
||||
)
|
||||
if not is_virt_down:
|
||||
ifaces[ifname] = ifstate
|
||||
|
@ -28,8 +28,31 @@ def load(schema_name):
|
||||
ifaces_schema = load('operational-state')
|
||||
|
||||
|
||||
class Interface(object):
|
||||
KEY = 'interfaces'
|
||||
|
||||
NAME = 'name'
|
||||
TYPE = 'type'
|
||||
STATE = 'state'
|
||||
|
||||
IPV4 = 'ipv4'
|
||||
IPV6 = 'ipv6'
|
||||
|
||||
|
||||
class Constants(object):
|
||||
INTERFACES = 'interfaces'
|
||||
INTERFACES = Interface.KEY
|
||||
|
||||
|
||||
class InterfaceState(object):
|
||||
KEY = Interface.STATE
|
||||
|
||||
DOWN = 'down'
|
||||
UP = 'up'
|
||||
ABSENT = 'absent'
|
||||
|
||||
|
||||
class InterfaceType(object):
|
||||
KEY = Interface.TYPE
|
||||
|
||||
BOND = 'bond'
|
||||
LINUX_BRIDGE = 'linux-bridge'
|
||||
@ -38,7 +61,7 @@ class Constants(object):
|
||||
OVS_INTERFACE = 'ovs-interface'
|
||||
VLAN = 'vlan'
|
||||
|
||||
VIRT_IFACE_TYPES = (
|
||||
VIRT_TYPES = (
|
||||
BOND,
|
||||
LINUX_BRIDGE,
|
||||
OVS_BRIDGE,
|
||||
|
Loading…
x
Reference in New Issue
Block a user