def test_merge_with_desired_ports_not_defined(self): cur_iface_info = gen_bridge_iface_info() des_iface_info = gen_bridge_iface_info() expected_iface_info = gen_bridge_iface_info() des_iface_info[LB.CONFIG_SUBTREE].pop(LB.PORT_SUBTREE) des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) assert des_iface.to_dict() == expected_iface_info
def test_merged_with_desire_remove_all_ports(self): cur_iface_info = gen_bridge_iface_info() des_iface_info = gen_bridge_iface_info() expected_iface_info = gen_bridge_iface_info() expected_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [] des_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [] des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) assert des_iface.to_dict() == expected_iface_info
def test_fix_access_mode_with_enable_native(self): cur_iface_info = gen_bridge_iface_info_with_vlan_filter() des_iface_info = gen_bridge_iface_info_with_vlan_filter() expected_iface_info = gen_bridge_iface_info_with_vlan_filter() cur_vlan_conf = cur_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE][0][ Port.VLAN_SUBTREE] cur_vlan_conf[Vlan.ENABLE_NATIVE] = True cur_vlan_conf[Vlan.MODE] = Vlan.Mode.TRUNK des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) des_iface.pre_edit_validation_and_cleanup() assert des_iface.to_dict() == expected_iface_info
def test_desire_port_name_only_merge_config_from_current(self): cur_iface_info = gen_bridge_iface_info() des_iface_info = gen_bridge_iface_info() expected_iface_info = gen_bridge_iface_info() expected_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [ deepcopy(SLAVE2_PORT_CONFIG) ] des_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [ { Port.NAME: SLAVE2_IFACE_NAME }, ] des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) assert des_iface.to_dict() == expected_iface_info
def test_desire_port_name_full_merge_from_current(self): cur_iface_info = gen_bridge_iface_info() des_iface_info = gen_bridge_iface_info() des_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [ { Port.NAME: SLAVE2_IFACE_NAME }, { Port.NAME: SLAVE1_IFACE_NAME }, ] des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) des_iface.sort_slaves() cur_iface.sort_slaves() assert des_iface.to_dict() == gen_bridge_iface_info()
def test_merge_fix_tag_with_trunk_disabled_native(self): cur_iface_info = gen_bridge_iface_info_with_vlan_filter() des_iface_info = gen_bridge_iface_info_with_vlan_filter() des_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE][0][ Port.VLAN_SUBTREE] = { Vlan.ENABLE_NATIVE: False, Vlan.MODE: Vlan.Mode.TRUNK, Vlan.TRUNK_TAGS: [{ Vlan.TrunkTags.ID: 101 }], } expected_iface_info = deepcopy(des_iface_info) des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) des_iface.pre_edit_validation_and_cleanup() assert des_iface.to_dict() == expected_iface_info
def test_remove_trunk_tag_if_access_mode(self): cur_iface_info = gen_bridge_iface_info_with_vlan_filter() des_iface_info = gen_bridge_iface_info_with_vlan_filter() des_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE][1][ Port.VLAN_SUBTREE] = { Vlan.MODE: Vlan.Mode.ACCESS, } expected_iface_info = gen_bridge_iface_info_with_vlan_filter() expected_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE][1][ Port.VLAN_SUBTREE] = { Vlan.MODE: Vlan.Mode.ACCESS, Vlan.TAG: 105 } des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) des_iface.pre_edit_validation_and_cleanup() assert des_iface.to_dict() == expected_iface_info
def test_desire_port_name_partial_merge_from_current_with_vlan_filter( self, ): cur_iface_info = gen_bridge_iface_info_with_vlan_filter() des_iface_info = gen_bridge_iface_info_with_vlan_filter() expected_port_config = deepcopy(SLAVE2_PORT_CONFIG) expected_port_config[Port.VLAN_SUBTREE] = SLAVE2_VLAN_CONFIG_TRUNK expected_iface_info = gen_bridge_iface_info() expected_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [ expected_port_config ] des_iface_info[LB.CONFIG_SUBTREE][LB.PORT_SUBTREE] = [ { Port.NAME: SLAVE2_IFACE_NAME }, ] des_iface = LinuxBridgeIface(des_iface_info) cur_iface = LinuxBridgeIface(cur_iface_info) des_iface.merge(cur_iface) assert des_iface.to_dict() == expected_iface_info