def push_vlan(vlan_vid): """Push a VLAN tag with optional selection of eth type.""" vid = vlan_vid vlan_eth_type = None if isinstance(vlan_vid, dict): vid = vlan_vid['vid'] if 'eth_type' in vlan_vid: vlan_eth_type = vlan_vid['eth_type'] if vlan_eth_type is None: return valve_of.push_vlan_act(vid) return valve_of.push_vlan_act(vid, eth_type=vlan_eth_type)
def push_vlan(acl_table, vlan_vid): """Push a VLAN tag with optional selection of eth type.""" vid = vlan_vid vlan_eth_type = None if isinstance(vlan_vid, dict): vid = vlan_vid['vid'] if 'eth_type' in vlan_vid: vlan_eth_type = vlan_vid['eth_type'] if vlan_eth_type is None: return valve_of.push_vlan_act(acl_table, vid) return valve_of.push_vlan_act( acl_table, vid, eth_type=vlan_eth_type)
def rewrite_vlan(output_dict): vlan_actions = [] if 'pop_vlans' in output_dict: for _ in range(output_dict['pop_vlans']): vlan_actions.append(valve_of.pop_vlan()) # if vlan tag is specified, push it. if 'vlan_vid' in output_dict: vlan_actions.extend( valve_of.push_vlan_act(output_dict['vlan_vid'])) # or, if a list, push them all (all with type Q). elif 'vlan_vids' in output_dict: for vid in output_dict['vlan_vids']: vlan_actions.extend(valve_of.push_vlan_act(vid)) return vlan_actions
def _port_add_vlan_untagged(self, port, vlan, forwarding_table, mirror_act): push_vlan_act = mirror_act + valve_of.push_vlan_act(vlan.vid) push_vlan_inst = [ valve_of.apply_actions(push_vlan_act), valve_of.goto_table(forwarding_table) ] null_vlan = namedtuple('null_vlan', 'vid') null_vlan.vid = valve_of.ofp.OFPVID_NONE return self._port_add_vlan_rules(port, null_vlan, push_vlan_inst)
def _port_add_vlan_rules(self, port, vlan, mirror_act, push_vlan=True): actions = copy.copy(mirror_act) match_vlan = vlan if push_vlan: actions.extend(valve_of.push_vlan_act( self.vlan_table, vlan.vid)) match_vlan = NullVLAN() if self.has_externals: if port.loop_protect_external: actions.append(self.vlan_table.set_no_external_forwarding_requested()) else: actions.append(self.vlan_table.set_external_forwarding_requested()) inst = ( valve_of.apply_actions(actions), self.vlan_table.goto(self._find_forwarding_table(vlan))) return self.vlan_table.flowmod( self.vlan_table.match(in_port=port.number, vlan=match_vlan), priority=self.low_priority, inst=inst)