def test_vlans(self): """Test that the vlans() method behaves correctly""" vlan100 = MockVLAN('v100') vlan200 = MockVLAN('v200') vlan300 = MockVLAN('v300') tagged_vlans = [vlan200, vlan300] native_vlan = vlan100 port = Port(1, 1, {}) port.native_vlan = native_vlan self.assertEqual(port.vlans(), [native_vlan]) port.tagged_vlans = tagged_vlans self.assertEqual(set(port.vlans()), set([native_vlan] + tagged_vlans)) port.native_vlan = None self.assertEqual(set(port.vlans()), set(tagged_vlans))
def test_vlans(self): """Test that the vlans() method behaves correctly""" vlan100 = MockVLAN('v100') vlan200 = MockVLAN('v200') vlan300 = MockVLAN('v300') tagged_vlans = [vlan200, vlan300] native_vlan = vlan100 port = Port(1, 1, {}) port.native_vlan = native_vlan self.assertIn(native_vlan, port.vlans()) port.tagged_vlans = tagged_vlans self.assertEqual(set(port.vlans()), set([native_vlan] + tagged_vlans)) port.native_vlan = None self.assertEqual(set(port.vlans()), set(tagged_vlans))
def _dp_parse_port(dp_id, p_identifier, port_conf, vlans): port = Port(p_identifier, port_conf) if port.native_vlan is not None: v_identifier = port.native_vlan vlan = _get_vlan_by_identifier(dp_id, v_identifier, vlans) port.native_vlan = vlan vlan.add_untagged(port) port_tagged_vlans = [ _get_vlan_by_identifier(dp_id, v_identifier, vlans) for v_identifier in port.tagged_vlans ] port.tagged_vlans = port_tagged_vlans for vlan in port.tagged_vlans: vlan.add_tagged(port) for vlan in port.vlans(): _dp_add_vlan(dp, vlan) return port