7 #include <sandesh/common/vns_types.h>
30 : agent_(agent), phy_intf_set_(), prev_stats_(), prev_vrouter_(),
31 cpu_stats_count_(0), do_vn_walk_(false), do_vm_walk_(false),
32 do_interface_walk_(false), vn_walk_ref_(NULL), vm_walk_ref_(NULL),
33 interface_walk_ref_(NULL), vn_listener_id_(
DBTableBase::kInvalidId),
36 physical_device_listener_id_(
DBTableBase::kInvalidId),
38 *(agent_->event_manager())->io_service(),
"UveDBWalkTimer",
153 UveVrouterAgent::Send(uve);
157 VrouterAgent vrouter_agent;
159 vrouter_agent.set_virtual_machine_list(*(list.get()));
160 VrouterAgentObjectCount vm_count;
161 vm_count.set_active(list.get()->size());
162 vrouter_agent.set_vm_count(vm_count);
180 std::ostringstream ostr;
182 list.get()->push_back(ostr.str());
225 VrouterAgent vrouter_agent;
227 vrouter_agent.set_connected_networks(*(list.get()));
228 vrouter_agent.set_vn_count((*list).size());
255 list.get()->push_back(vn->
GetName());
302 VrouterAgent vrouter_agent;
304 vrouter_agent.set_interface_list(*(if_list.get()));
305 vrouter_agent.set_error_intf_list(*(err_if_list.get()));
306 vrouter_agent.set_no_config_intf_list(*(nova_if_list.get()));
308 vrouter_agent.set_unmanaged_if_list(*(unmanaged_list.get()));
309 prev_vrouter_.set_unmanaged_if_list(*(unmanaged_list.get()));
312 VrouterAgentObjectCount vmi_count;
313 vmi_count.set_active((if_list.get()->size() + nova_if_list.get()->size()));
314 vrouter_agent.set_vmi_count(vmi_count);
315 vrouter_agent.set_down_interface_count((err_if_list.get()->size() +
316 nova_if_list.get()->size()));
322 prev_vrouter_.set_no_config_intf_list(*(nova_if_list.get()));
325 (*err_if_list).clear();
326 (*nova_if_list).clear();
327 (*unmanaged_list).clear();
351 if (!pd || !pd->
master()) {
352 unmanaged_list.get()->push_back(port->
cfg_name());
369 bond_childIntf_map.begin();
370 for(; it != bond_childIntf_map.end(); it++) {
372 bond_intf = it->second;
374 err_if_list.get()->push_back(it->first);
385 intf_list.get()->push_back(port->
cfg_name());
387 err_if_list.get()->push_back(port->
cfg_name());
394 if (u == boost::uuids::nil_uuid()) {
434 intf_list, err_if_list, nova_if_list, unmanaged_list),
436 intf_list, err_if_list, nova_if_list, unmanaged_list));
446 bool set_state =
false, reset_state =
false;
450 bool vmport_active =
false;
452 switch(intf->
type()) {
493 bond_childIntf_map.begin();
494 for(; it != bond_childIntf_map.end(); it++) {
496 bond_intf = it->second;
501 std::vector<std::string> prev_err_if_list =
503 if (std::find(prev_err_if_list.begin(),
504 prev_err_if_list.end(), it->first)
505 != prev_err_if_list.end()) {
519 }
else if (reset_state) {
528 VirtualGatewayConfig::SubnetList::iterator subnet_it =
530 while (subnet_it != source_list.end()) {
531 string subnet_str = subnet_it->ip_.to_string() +
"/" +
533 target_list.push_back(subnet_str);
539 AgentVhostConfig vhost_cfg;
540 AgentXenConfig xen_cfg;
541 AgentVmwareConfig vmware_cfg;
543 vector<AgentVgwConfig> gw_cfg_list;
547 vrouter_agent.set_log_file(param->
log_file());
548 vrouter_agent.set_config_file(param->
config_file());
549 vrouter_agent.set_log_local(param->
log_local());
550 vrouter_agent.set_log_flow(param->
log_flow());
552 vrouter_agent.set_log_level(param->
log_level());
554 vrouter_agent.set_tunnel_type(param->
tunnel_type());
555 vrouter_agent.set_hostname_cfg(param->
host_name());
563 vrouter_agent.set_control_ip(param->
mgmt_ip().to_string());
567 vhost_cfg.set_ip(param->
vhost_addr().to_string());
568 vhost_cfg.set_ip_prefix_len(param->
vhost_plen());
570 vhost_cfg.set_gateway(param->
gateway_list()[0].to_string());
573 vrouter_agent.set_vhost_cfg(vhost_cfg);
582 xen_cfg.set_xen_ll_ip(param->
xen_ll_addr().to_string());
583 xen_cfg.set_xen_ll_prefix_len(param->
xen_ll_plen());
584 vrouter_agent.set_xen_cfg(xen_cfg);
586 hypervisor =
"vmware";
588 vrouter_agent.set_vmware_cfg(vmware_cfg);
590 vrouter_agent.set_hypervisor(hypervisor);
593 VirtualGatewayConfigTable::Table::iterator it = table->
table().begin();
594 while (it != table->
table().end()) {
595 AgentVgwConfig gw_cfg;
598 vector<string> ip_blocks_list;
599 vector<string> route_str_list;
604 gw_cfg.set_interface_name(it->interface_name());
605 gw_cfg.set_vrf_name(it->vrf_name());
606 gw_cfg.set_ip_blocks_list(ip_blocks_list);
607 gw_cfg.set_route_list(route_str_list);
609 gw_cfg_list.push_back(gw_cfg);
612 vrouter_agent.set_gateway_cfg_list(gw_cfg_list);
613 vrouter_agent.set_headless_mode_cfg(
true);
615 vrouter_agent.set_bgpaas_enabled(
618 vrouter_agent.set_loopback_ip(param->
loopback_ip().to_string());
619 std::vector<string> gateway_list;
620 for (std::vector<Ip4Address>::const_iterator iter = param->
gateway_list().begin();
622 gateway_list.push_back((*iter).to_string());
624 vrouter_agent.set_gateway_list(gateway_list);
629 VrouterAgent vrouter_agent;
630 bool changed =
false, bgp_aas, port_mirror;
631 static bool first =
true;
634 vector<string> ip_list;
635 vector<string> dns_list;
639 vnsConstants vnsVrouterType;
644 vitf.set_name(vhost->
name());
646 vrouter_agent.set_vhost_if(vitf);
655 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
656 (VrouterAgentType::VROUTER_AGENT_TOR));
658 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
659 (VrouterAgentType::VROUTER_AGENT_TSN));
661 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
662 (VrouterAgentType::VROUTER_AGENT_EMBEDDED));
666 vrouter_agent.set_platform(vnsVrouterType.
667 VrouterAgentPlatformTypeMap.at
668 (VrouterAgentPlatformType::
669 VROUTER_AGENT_ON_NIC));
671 vrouter_agent.set_platform(vnsVrouterType.
672 VrouterAgentPlatformTypeMap.at
673 (VrouterAgentPlatformType::
674 VROUTER_AGENT_ON_HOST_DPDK));
676 vrouter_agent.set_platform(vnsVrouterType.
677 VrouterAgentPlatformTypeMap.at
678 (VrouterAgentPlatformType::
679 VROUTER_AGENT_ON_HOST));
690 VrouterObjectLimits prev_vr_limits =
prev_vrouter_.get_vr_limits();
691 if (vr_limits != prev_vr_limits) {
692 vrouter_agent.set_vr_limits(vr_limits);
705 vrouter_agent.set_bgpaas_enabled(bgp_aas);
711 if (
prev_vrouter_.get_port_mirror_enabled() != port_mirror) {
712 vrouter_agent.set_port_mirror_enabled(port_mirror);
717 vector<AgentInterface> phy_if_list;
724 pitf.set_name(intf->
name());
726 phy_if_list.push_back(pitf);
730 vrouter_agent.set_phy_if(phy_if_list);
735 std::vector<AgentXmppPeer> xmpp_list;
749 peer.set_status(
true);
751 peer.set_status(
false);
755 peer.set_primary(
true);
757 peer.set_primary(
false);
759 xmpp_list.push_back(peer);
765 vrouter_agent.set_xmpp_peer_list(xmpp_list);
771 ip_list.push_back(rid.to_string());
775 vrouter_agent.set_self_ip_list(ip_list);
789 vrouter_agent.set_dns_servers(dns_list);
794 std::vector<VrouterAgentResUsage> limit_exceeded_list;
795 VrouterAgentResUsage
usage;
796 bool limit_exceeded =
false;
797 bool table_limit =
false;
799 for(VrLimitExceeded::iterator res_map_it = res_usage_map.begin();
800 res_map_it != res_usage_map.end(); ++res_map_it ) {
801 if (res_map_it->second !=
"Normal") {
802 usage.set_name(res_map_it->first);
803 usage.set_status(res_map_it->second);
804 limit_exceeded_list.push_back(
usage);
805 if (res_map_it->second ==
"TableLimit" && !table_limit) {
807 limit_exceeded =
true;
808 }
else if (res_map_it->second ==
"Exceeded" && !limit_exceeded ) {
809 limit_exceeded =
true;
816 prev_vrouter_.get_vr_limit_exceeded_list() != limit_exceeded_list) {
817 vrouter_agent.set_vr_limit_exceeded_list(limit_exceeded_list);
818 prev_vrouter_.set_vr_limit_exceeded_list(limit_exceeded_list);
819 vrouter_agent.set_res_limit(limit_exceeded);
820 vrouter_agent.set_res_table_limit(table_limit);
825 std::vector<L3mhPhysicalInterfaceStatus> vr_l3mh_intf_list;
826 bool l3mh_phy_interface_down =
false;
829 L3mhPhysicalInterfaceStatus l3mh_interface_status;
831 l3mh_interface_status.set_name(intf->
name());
833 vr_l3mh_intf_list.push_back(l3mh_interface_status);
835 l3mh_phy_interface_down =
true;
840 prev_vrouter_.get_vr_l3mh_intf_list() != vr_l3mh_intf_list) {
841 vrouter_agent.set_vr_l3mh_intf_list(vr_l3mh_intf_list);
843 vrouter_agent.set_l3mh_phy_interface_down(l3mh_phy_interface_down);
852 VrouterStatsAgent stats;
859 static bool cpu_first =
true;
860 CpuLoadInfo cpu_load_info;
862 if (
prev_stats_.get_cpu_info() != cpu_load_info || cpu_first) {
863 stats.set_cpu_info(cpu_load_info);
879 (
const vector<string> &list) {
880 VrouterAgent vrouter_agent;
883 vrouter_agent.set_tor_prouter_list(list);
885 vrouter_agent.set_tsn_prouter_list(list);
887 vrouter_agent.set_embedded_prouter_list(list);
897 VrouterStats::Send(uve);
901 ComputeCpuStateTrace::Send(ccs);
905 ComputeCpuState astate;
906 VrouterCpuInfo ainfo;
907 vector<VrouterCpuInfo> aciv;
910 ainfo.set_cpu_share(info.get_cpu_share());
911 ainfo.set_mem_virt(info.get_meminfo().get_virt());
912 ainfo.set_mem_res(info.get_meminfo().get_res());
913 const SysMemInfo &sys_mem_info(info.get_sys_mem_info());
914 ainfo.set_used_sys_mem(sys_mem_info.get_used() -
915 sys_mem_info.get_buffers() - sys_mem_info.get_cached());
916 ainfo.set_one_min_cpuload(info.get_cpuload().get_one_min_avg());
917 aciv.push_back(ainfo);
918 astate.set_cpu_info(aciv);
boost::asio::ip::address_v4 Ip4Address
std::map< std::string, std::string > VrLimitExceeded
AgentDBEntry * FindActiveEntry(const DBEntry *key)
const std::string & vmware_physical_port() const
const std::string & tunnel_type() const
const int vhost_plen() const
const std::string & host_name() const
uint32_t linklocal_vm_flows() const
uint32_t flow_cache_timeout() const
const std::vector< std::string > collector_server_list() const
const std::string & log_category() const
const std::string & config_file() const
const std::string log_file() const
uint32_t linklocal_system_flows() const
const std::string & vhost_name() const
const Ip4Address & vhost_addr() const
VirtualGatewayConfigTable * vgw_config_table() const
const AddressList & gateway_list() const
const std::string & xen_ll_name() const
const Ip4Address & xen_ll_addr() const
uint16_t http_server_port() const
const Ip4Address & loopback_ip() const
const std::vector< std::string > controller_server_list() const
const std::string & log_level() const
const std::vector< std::string > & eth_port_list() const
const int xen_ll_plen() const
bool isVmwareMode() const
const Ip4Address & mgmt_ip() const
const std::vector< std::string > dns_server_list() const
static const uint32_t kDefaultInterval
XmppChannel * GetXmppChannel()
InterfaceTable * interface_table() const
const std::string & subcluster_name() const
bool vrouter_on_nic_mode() const
VmTable * vm_table() const
AgentXmppChannel * controller_xmpp_channel(uint8_t idx) const
VrLimitExceeded & get_vr_limits_exceeded_map()
const std::string & dns_server(uint8_t idx) const
const uint64_t controller_xmpp_channel_setup_time(uint8_t idx) const
bool vrouter_on_host() const
AgentParam * params() const
const std::string & agent_name() const
bool router_id_configured()
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
float vr_limit_high_watermark()
bool vrouter_on_host_dpdk() const
static const std::string & NullString()
VnTable * vn_table() const
PhysicalDeviceTable * physical_device_table() const
bool tor_agent_enabled() const
const Interface * vhost_interface() const
Ip4Address router_id() const
const int8_t & ifmap_active_xmpp_server_index() const
float vr_limit_low_watermark()
VrouterObjectLimits GetVrouterObjectLimits()
static void FillCpuInfo(CpuLoadInfo &info, bool system)
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
void ClearState(DBTableBase *tbl_base, ListenerId listener)
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
static const int kInvalidId
void Unregister(ListenerId listener)
void WalkAgain(DBTableWalkRef walk)
DBTableWalkRef AllocWalker(WalkFn walk_fn, WalkCompleteFn walk_complete)
void ReleaseWalker(DBTableWalkRef &walk)
const MacAddress & mac() const
bool os_oper_state() const
const std::string & name() const
const boost::uuids::uuid & GetUuid() const
Interface * physical_interface() const
std::string ToString() const
static MirrorTable * GetInstance()
BgpAsAService * bgp_as_a_service() const
const BondChildIntfMap & getBondChildIntfMap() const
std::map< const std::string, Bond_ChildIntf > BondChildIntfMap
BondChildIntfMap::const_iterator BondChildIntfMapIterator
PhysicalDevice * physical_device() const
PhysicalDevice * physical_device() const
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
static bool DeleteTimer(Timer *Timer)
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
const Table & table() const
std::vector< Subnet > SubnetList
const boost::uuids::uuid & GetUuid() const
const boost::uuids::uuid & logical_interface() const
const std::string & cfg_name() const
const string & GetName() const
std::string GetMacAddress(const MacAddress &mac) const
void VmWalkDone(DBTableBase *base, StringVectorPtr list)
virtual void DispatchComputeCpuStateMsg(const ComputeCpuState &ccs)
void InterfaceNotify(DBTablePartBase *partition, DBEntryBase *e)
PhysicalDevice * VmiToPhysicalDevice(const VmInterface *port)
bool AppendVn(DBTablePartBase *part, DBEntryBase *e, StringVectorPtr l)
DBTableBase::ListenerId vm_listener_id_
void VnNotify(DBTablePartBase *partition, DBEntryBase *e)
DBTable::DBTableWalkRef vn_walk_ref_
PhysicalDevice * InterfaceToPhysicalDevice(Interface *intf)
DBTable::DBTableWalkRef interface_walk_ref_
virtual void DispatchVrouterMsg(const VrouterAgent &uve)
void BuildAgentConfig(VrouterAgent &vrouter_agent)
DBTableBase::ListenerId vn_listener_id_
void SendVrouterProuterAssociation(const std::vector< std::string > &list)
DBTableBase::ListenerId intf_listener_id_
virtual void DispatchVrouterStatsMsg(const VrouterStatsAgent &uve)
PhysicalInterfaceSet phy_intf_set_
void VmNotify(DBTablePartBase *partition, DBEntryBase *e)
void SubnetToStringList(VirtualGatewayConfig::SubnetList &l1, std::vector< std::string > &l2)
virtual bool SendVrouterMsg()
DBTable::DBTableWalkRef vm_walk_ref_
bool StartInterfaceWalk()
VrouterUveEntryBase(Agent *agent)
VrouterStatsAgent prev_stats_
void InterfaceWalkDone(DBTableBase *base, StringVectorPtr if_l, StringVectorPtr err_if_l, StringVectorPtr nova_if_l, StringVectorPtr unmanaged_list)
DBTableBase::ListenerId physical_device_listener_id_
bool AppendVm(DBTablePartBase *part, DBEntryBase *e, StringVectorPtr l)
void BuildAndSendComputeCpuStateMsg(const CpuLoadInfo &info)
bool AppendInterface(DBTablePartBase *part, DBEntryBase *entry, StringVectorPtr intf_list, StringVectorPtr err_list, StringVectorPtr nova_if_list, StringVectorPtr unmanaged_list)
void AppendInterfaceInternal(const VmInterface *port, StringVectorPtr intf_list, StringVectorPtr err_if_list)
void VnWalkDone(DBTableBase *base, StringVectorPtr list)
virtual ~VrouterUveEntryBase()
boost::shared_ptr< std::vector< std::string > > StringVectorPtr
void PhysicalDeviceNotify(DBTablePartBase *partition, DBEntryBase *e)
VrouterAgent prev_vrouter_
virtual xmps::PeerState GetPeerState() const =0
static std::string UuidToString(const boost::uuids::uuid &id)
static const std::string integerToString(const NumberType &num)
const std::string BuildInfo