def setup_lldpad_ports(self):
<EOL>ovs_bridges = ovs_lib.get_bridges(self.root_helper)<EOL>if self.ext_br not in ovs_bridges or self.integ_br not in ovs_bridges:<EOL><INDENT>self.uplink_fail_reason = cconstants.bridge_not_cfgd_reason % (<EOL>ovs_bridges, self.integ_br, self.ext_br)<EOL>LOG.error("<STR_LIT:%s>", self.uplink_fail_reason)<EOL>raise dfae.DfaAgentFailed(reason=self.uplink_fail_reason)<EOL><DEDENT>br = ovs_lib.OVSBridge(self.ext_br, root_helper=self.root_helper)<EOL>self.ext_br_obj = br<EOL>int_br = ovs_lib.OVSBridge(self.integ_br, root_helper=self.root_helper)<EOL>self.integ_br_obj = int_br<EOL>self.phy_peer_port, self.int_peer_port = self.find_interconnect_ports()<EOL>if self.phy_peer_port is None or self.int_peer_port is None:<EOL><INDENT>self.uplink_fail_reason = cconstants.veth_not_cfgd_reason % (<EOL>self.phy_peer_port, self.int_peer_port)<EOL>LOG.error("<STR_LIT:%s>", self.uplink_fail_reason)<EOL>raise dfae.DfaAgentFailed(reason=self.uplink_fail_reason)<EOL><DEDENT>lldp_ovs_veth_str = constants.LLDPAD_OVS_VETH_PORT + self.uplink<EOL>if len(lldp_ovs_veth_str) > constants.MAX_VETH_NAME:<EOL><INDENT>lldp_ovs_veth_str = self.gen_veth_str(<EOL>constants.LLDPAD_OVS_VETH_PORT,<EOL>self.uplink)<EOL><DEDENT>lldp_loc_veth_str = constants.LLDPAD_LOC_VETH_PORT + self.uplink<EOL>if len(lldp_loc_veth_str) > constants.MAX_VETH_NAME:<EOL><INDENT>lldp_loc_veth_str = self.gen_veth_str(<EOL>constants.LLDPAD_LOC_VETH_PORT,<EOL>self.uplink)<EOL><DEDENT>ip_wrapper = ip_lib.IPWrapper()<EOL>self.delete_vdp_flows()<EOL>br.delete_port(lldp_ovs_veth_str)<EOL>if ip_lib.device_exists(lldp_ovs_veth_str):<EOL><INDENT>lldp_loc_veth = ip_wrapper.device(lldp_loc_veth_str)<EOL>lldp_ovs_veth = ip_wrapper.device(lldp_ovs_veth_str)<EOL><DEDENT>else:<EOL><INDENT>lldp_loc_veth, lldp_ovs_veth = (<EOL>ip_wrapper.add_veth(lldp_loc_veth_str,<EOL>lldp_ovs_veth_str))<EOL><DEDENT>if not br.port_exists(self.uplink):<EOL><INDENT>phy_port_num = br.add_port(self.uplink)<EOL><DEDENT>else:<EOL><INDENT>phy_port_num = br.get_port_ofport(self.uplink)<EOL><DEDENT>if phy_port_num == cconstants.INVALID_OFPORT:<EOL><INDENT>self.uplink_fail_reason = cconstants.invalid_uplink_ofport_reason<EOL>LOG.error("<STR_LIT:%s>", self.uplink_fail_reason)<EOL>return False<EOL><DEDENT>if not br.port_exists(lldp_ovs_veth_str):<EOL><INDENT>lldp_ovs_portnum = br.add_port(lldp_ovs_veth)<EOL><DEDENT>else:<EOL><INDENT>lldp_ovs_portnum = br.get_port_ofport(lldp_ovs_veth)<EOL><DEDENT>if lldp_ovs_portnum == cconstants.INVALID_OFPORT:<EOL><INDENT>self.uplink_fail_reason = cconstants.lldp_ofport_not_detect_reason<EOL>LOG.error("<STR_LIT:%s>", self.uplink_fail_reason)<EOL>return False<EOL><DEDENT>lldp_loc_veth.link.set_up()<EOL>lldp_ovs_veth.link.set_up()<EOL>self.program_vdp_flows(lldp_ovs_portnum, phy_port_num)<EOL>self.phy_peer_port_num = br.get_port_ofport(self.phy_peer_port)<EOL>self.int_peer_port_num = int_br.get_port_ofport(self.int_peer_port)<EOL>if (self.phy_peer_port_num == cconstants.INVALID_OFPORT or<EOL>self.int_peer_port_num == cconstants.INVALID_OFPORT):<EOL><INDENT>self.uplink_fail_reason = cconstants.invalid_peer_ofport_reason % (<EOL>self.phy_peer_port_num, self.int_peer_port_num)<EOL>LOG.error("<STR_LIT:%s>", self.uplink_fail_reason)<EOL>return False<EOL><DEDENT>self.lldpad_info = (lldpad.LldpadDriver(lldp_loc_veth_str, self.uplink,<EOL>self.root_helper))<EOL>ret = self.lldpad_info.enable_evb()<EOL>if not ret:<EOL><INDENT>self.uplink_fail_reason = cconstants.evb_cfg_fail_reason<EOL>LOG.error("<STR_LIT:%s>", self.uplink_fail_reason)<EOL>return False<EOL><DEDENT>self.lldp_local_veth_port = lldp_loc_veth_str<EOL>self.lldp_ovs_veth_port = lldp_ovs_veth_str<EOL>LOG.info("<STR_LIT>")<EOL>return True<EOL>
Setup the flows for passing LLDP/VDP frames in OVS.