24 singular_db<l2_xconnect::key_t, l2_xconnect> l2_xconnect::m_db;
32 : m_east_itf(east_itf.singular())
33 , m_west_itf(west_itf.singular())
40 : m_east_itf(o.m_east_itf)
41 , m_west_itf(o.m_west_itf)
42 , m_xconnect_east(o.m_xconnect_east)
43 , m_xconnect_west(o.m_xconnect_west)
50 if (m_east_itf->name() < m_west_itf->name())
51 return (std::make_pair(m_east_itf->key(), m_west_itf->key()));
52 return (std::make_pair(m_west_itf->key(), m_east_itf->key()));
58 return ((*m_east_itf == *l.m_east_itf) && (*m_west_itf == *l.m_west_itf));
61 std::shared_ptr<l2_xconnect>
64 return (m_db.find(key));
70 if (m_xconnect_east && m_xconnect_west &&
74 m_xconnect_east, m_east_itf->handle(), m_west_itf->handle()));
76 m_xconnect_west, m_west_itf->handle(), m_east_itf->handle()));
85 if (m_xconnect_east && m_xconnect_west &&
89 m_xconnect_east, m_east_itf->handle(), m_west_itf->handle()));
91 m_xconnect_west, m_west_itf->handle(), m_east_itf->handle()));
100 m_db.release(
key(),
this);
106 std::ostringstream s;
107 s <<
"L2-xconnect:[" << m_east_itf->to_string() <<
" " 108 << m_west_itf->to_string() <<
" " << m_xconnect_east.
to_string() <<
" " 122 m_xconnect_east, m_east_itf->handle(), m_west_itf->handle()));
124 m_xconnect_west, m_west_itf->handle(), m_east_itf->handle()));
128 std::shared_ptr<l2_xconnect>
131 return (m_db.find_or_add(temp.
key(), temp));
134 std::shared_ptr<l2_xconnect>
137 return find_or_add(*
this);
153 l2_xconnect::event_handler::handle_replay()
164 std::shared_ptr<l2_xconnect_cmds::dump_cmd>
cmd =
165 std::make_shared<l2_xconnect_cmds::dump_cmd>();
170 for (
auto& x_record : *cmd) {
171 auto& payload = x_record.get_payload();
174 <<
" east-itf: " << payload.rx_sw_if_index
175 <<
" west-itf: " << payload.tx_sw_if_index;
177 std::shared_ptr<interface> east_itf =
179 std::shared_ptr<interface> west_itf =
182 if (east_itf && west_itf) {
183 if (east_itf->name() > west_itf->name())
192 l2_xconnect::event_handler::order()
const static std::shared_ptr< l2_xconnect > find(const key_t &key)
Static function to find the bridge_domain in the model.
A functor class that binds L2 configuration to an interface.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.
A Class representing the cross connnect of an L2 interface with another l2 interface.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
static rc_t write()
Write/Execute all commands hitherto enqueued.
static const log_level_t DEBUG
static const handle_t INVALID
A value of an interface handle_t that means the itf does not exist.
std::string to_string() const
convert to string format for debug purposes
std::shared_ptr< l2_xconnect > singular() const
Return the 'singular instance' of the L2 config that matches this object.
A cmd class that Unbinds L2 configuration from an interface.
const key_t key() const
Return the xconnect's key.
rc_t rc() const
Get the HW return code.
bool operator==(const l2_xconnect &l) const
Comparison operator - for UT.
static void dump(std::ostream &os)
Dump all l2_xconnects into the stream provided.
A representation of an interface in VPP.
std::string to_string() const
convert to string format for debug purposes
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
static const rc_t OK
The HW write was successfull.
static void enqueue(cmd *f)
Enqueue A command for execution.
l2_xconnect(const interface &east_itf, const interface &west_itf)
Construct a new object matching the desried state.
std::pair< interface::key_t, interface::key_t > key_t
Key type for an L2 xconnect in the singular DB.
~l2_xconnect()
Destructor.
Then L2/objects that bind to interfaces, BD, ACLS, etc.
The VPP Object Model (VOM) library.
A representation of a method call to VPP.
static bool register_listener(listener *listener)
Register a listener of events.