11 #include "vr_genetlink.h"
16 #include <uve/stats_interval_types.h>
24 using process::ConnectionInfo;
25 using process::ConnectionType;
26 using process::ProcessState;
27 using process::ConnectionStatus;
30 using process::g_process_info_constants;
45 uint32_t default_intvl, uint32_t incremental_intvl)
46 : vn_uve_table_(NULL), vm_uve_table_(NULL), vrouter_uve_entry_(NULL),
48 interface_uve_table_(NULL),
49 default_interval_(default_intvl),
50 incremental_interval_(incremental_intvl),
51 agent_(agent), bandwidth_intvl_(intvl),
53 *(agent->event_manager()->io_service()),
64 TagList::const_iterator it = tl.begin();
65 while (it != tl.end()) {
88 if (!info->
labels.empty()) {
119 std::stringstream ss;
120 ss <<
"0x" << std::setfill(
'0') <<
121 std::setw(8) << std::hex << (uint32_t)value;
127 TagList::const_iterator it = tl.begin();
128 while (it != tl.end()) {
151 if (!info->
labels.empty()) {
178 if (new_interval == 0) {
186 if (new_interval == 0) {
211 ConnectionStateManager::
215 module_id, instance_id,
217 this, _1, _2, _3),
"ObjectVRouter");
221 uint8_t &num_dns_servers) {
244 std::string &message) {
245 if (message.empty()) {
246 message = cinfo.get_type();
248 message +=
", " + cinfo.get_type();
250 const std::string &name(cinfo.get_name());
252 message +=
":" + name;
264 (
const std::vector<ConnectionInfo> &cinfos,
266 size_t num_conns = 0;
267 uint8_t num_control_nodes = 0, num_dns_servers = 0;
268 uint8_t down_control_nodes = 0;
271 std::string cup(g_process_info_constants.ConnectionStatusNames.
272 find(ConnectionStatus::UP)->second);
274 bool is_tor_connected =
false;
275 string tor_type(g_process_info_constants.ConnectionTypeNames.
276 find(ConnectionType::TOR)->second);
278 for (std::vector<ConnectionInfo>::const_iterator it = cinfos.begin();
279 it != cinfos.end(); it++) {
280 const ConnectionInfo &cinfo(*it);
281 const std::string &conn_status(cinfo.get_status());
282 if (cinfo.get_type() == tor_type) {
283 is_tor_connected =
true;
293 if (conn_status != cup) {
294 if (cinfo.get_name().compare(0, 13,
296 down_control_nodes++;
302 if ((num_control_nodes == 0) || (num_control_nodes == down_control_nodes)) {
303 pstate = ProcessState::NON_FUNCTIONAL;
304 if ((num_control_nodes == 0) && message.empty()) {
305 message =
"No control-nodes configured";
309 pstate = ProcessState::NON_FUNCTIONAL;
310 message +=
" No ToR Config";
312 pstate = ProcessState::FUNCTIONAL;
315 message +=
" connection down";
319 pstate = ProcessState::NON_FUNCTIONAL;
320 if (message.empty()) {
321 message =
"No Configuration for self";
323 message +=
", No Configuration for self";
334 if (num_conns != expected_conns) {
std::vector< int > TagList
const std::vector< std::string > collector_server_list() const
uint32_t xmpp_reconnects(uint8_t idx) const
static const uint32_t kUveCountPerTimer
boost::scoped_ptr< VrouterStatsCollector > vrouter_stats_collector_
static const uint64_t kBandwidthInterval
void VrouterAgentProcessState(const std::vector< process::ConnectionInfo > &c, process::ProcessState::type &state, std::string &message)
virtual void RegisterDBClients()
void BuildTagIdsFromList(const TagList &tl, UveTagData *info) const
boost::scoped_ptr< VnUveTableBase > vn_uve_table_
boost::scoped_ptr< VrouterUveEntryBase > vrouter_uve_entry_
boost::scoped_ptr< InterfaceUveTable > interface_uve_table_
AgentUveBase(Agent *agent, uint64_t intvl, uint32_t default_intvl, uint32_t incremental_intvl)
uint32_t incremental_interval_
void set_incremental_interval(uint32_t new_interval=kIncrementalInterval)
Sets the incremental interval (time between dispatches of Agent's information and its remnant to UVE)...
static AgentUveBase * singleton_
void set_default_interval(uint32_t new_interval=kDefaultInterval)
Sets the default interval (time between two dispatches of Agent's information to UVE).
boost::scoped_ptr< VmUveTableBase > vm_uve_table_
void UpdateMessage(const process::ConnectionInfo &info, std::string &message)
static const uint32_t kDefaultInterval
static const uint32_t kIncrementalInterval
uint8_t ExpectedConnections(uint8_t &num_c_nodes, uint8_t &num_d_servers)
boost::scoped_ptr< ProuterUveTable > prouter_uve_table_
uint32_t default_interval_
std::string IntegerToHexString(uint32_t value) const
process::ConnectionStateManager * connection_state_manager_
void BuildTagNamesFromList(const TagList &tl, UveTagData *info) const
bool HasSelfConfiguration() const
ServicesModule * services() const
TagTable * tag_table() const
const std::string & dns_server(uint8_t idx) const
AgentParam * params() const
const std::string & agent_name() const
EventManager * event_manager() const
void set_connection_state(process::ConnectionState *state)
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
const std::string & module_name() const
static const std::string & xmpp_control_node_prefix()
bool tor_agent_enabled() const
AgentStats * stats() const
const std::string & instance_id() const
boost::asio::io_context * io_service()
GlobalVrouter * global_vrouter() const
static const uint32_t kTagTypeBitShift
const std::string & TagName(uint32_t id)
void Init(boost::asio::io_context &service, const std::string &hostname, const std::string &module, const std::string &instance_id, ProcessStateFn status_cb, std::string table)
static const std::string integerToString(const NumberType &num)
std::vector< string > label_vector
std::vector< string > custom_tag_vector
std::set< string > label_set
std::set< string > custom_tag_set