Esempio n. 1
0
def test_lot_of_vlans_with_bridges(eth1_up):
    interfaces = []
    for i in range(100, 400):
        interfaces.extend(
            [
                {
                    Interface.NAME: "vlan." + str(i),
                    Interface.TYPE: InterfaceType.VLAN,
                    Interface.STATE: InterfaceState.UP,
                    VLAN.CONFIG_SUBTREE: {VLAN.BASE_IFACE: "eth1", VLAN.ID: i},
                },
                {
                    Interface.NAME: "linux-br" + str(i),
                    Interface.TYPE: InterfaceType.LINUX_BRIDGE,
                    Interface.STATE: InterfaceState.UP,
                    LinuxBridge.CONFIG_SUBTREE: {
                        LinuxBridge.PORT_SUBTREE: [
                            {LinuxBridge.Port.NAME: "vlan." + str(i)}
                        ]
                    },
                },
            ]
        )
    checkpoint = libnmstate.apply({Interface.KEY: interfaces}, commit=False)
    libnmstate.rollback(checkpoint=checkpoint)
    time.sleep(5)
Esempio n. 2
0
def test_two_vlans_on_eth1_change_mtu_rollback(eth1_up):
    desired_state = statelib.show_only(("eth1",))
    vlans_state = create_two_vlans_state()
    desired_state[Interface.KEY].extend(vlans_state[Interface.KEY])
    for iface in desired_state[Interface.KEY]:
        iface[Interface.MTU] = 2000
    libnmstate.apply(desired_state)

    for iface in desired_state[Interface.KEY]:
        iface[Interface.MTU] = 2200
    libnmstate.apply(desired_state, commit=False)
    libnmstate.rollback()

    time.sleep(5)  # Give some time for NetworkManager to rollback

    eth1_vlan_iface_cstate = statelib.show_only((VLAN_IFNAME,))
    assert eth1_vlan_iface_cstate[Interface.KEY][0][Interface.MTU] == 2000
Esempio n. 3
0
def rollback(args):
    try:
        libnmstate.rollback(checkpoint=args.checkpoint)
    except NmstateValueError as e:
        print("ERROR rolling back change: {}\n".format(str(e)))
        return os.EX_DATAERR