8 #include <sandesh/common/vns_types.h>
31 : agent_(agent), phy_intf_set_(), prev_stats_(), prev_vrouter_(),
32 cpu_stats_count_(0), do_vn_walk_(false), do_vm_walk_(false),
33 do_interface_walk_(false), vn_walk_ref_(NULL), vm_walk_ref_(NULL),
34 interface_walk_ref_(NULL), vn_listener_id_(
DBTableBase::kInvalidId),
37 physical_device_listener_id_(
DBTableBase::kInvalidId),
39 *(agent_->event_manager())->io_service(),
"UveDBWalkTimer",
158 UveVrouterAgent::Send(uve);
162 VrouterAgent vrouter_agent;
164 vrouter_agent.set_virtual_machine_list(*(list.get()));
165 VrouterAgentObjectCount vm_count;
166 vm_count.set_active(list.get()->size());
167 vrouter_agent.set_vm_count(vm_count);
185 std::ostringstream ostr;
187 list.get()->push_back(ostr.str());
230 VrouterAgent vrouter_agent;
232 vrouter_agent.set_connected_networks(*(list.get()));
233 vrouter_agent.set_vn_count((*list).size());
260 list.get()->push_back(vn->
GetName());
307 VrouterAgent vrouter_agent;
309 vrouter_agent.set_interface_list(*(if_list.get()));
310 vrouter_agent.set_error_intf_list(*(err_if_list.get()));
311 vrouter_agent.set_no_config_intf_list(*(nova_if_list.get()));
313 vrouter_agent.set_unmanaged_if_list(*(unmanaged_list.get()));
314 prev_vrouter_.set_unmanaged_if_list(*(unmanaged_list.get()));
317 VrouterAgentObjectCount vmi_count;
318 vmi_count.set_active((if_list.get()->size() + nova_if_list.get()->size()));
319 vrouter_agent.set_vmi_count(vmi_count);
320 vrouter_agent.set_down_interface_count((err_if_list.get()->size() +
321 nova_if_list.get()->size()));
327 prev_vrouter_.set_no_config_intf_list(*(nova_if_list.get()));
330 (*err_if_list).clear();
331 (*nova_if_list).clear();
332 (*unmanaged_list).clear();
356 if (!pd || !pd->
master()) {
357 unmanaged_list.get()->push_back(port->
cfg_name());
374 bond_childIntf_map.begin();
375 for(; it != bond_childIntf_map.end(); it++) {
377 bond_intf = it->second;
379 err_if_list.get()->push_back(it->first);
390 intf_list.get()->push_back(port->
cfg_name());
392 err_if_list.get()->push_back(port->
cfg_name());
399 if (u == boost::uuids::nil_uuid()) {
439 intf_list, err_if_list, nova_if_list, unmanaged_list),
441 intf_list, err_if_list, nova_if_list, unmanaged_list));
451 bool set_state =
false, reset_state =
false;
455 bool vmport_active =
false;
457 switch(intf->
type()) {
498 bond_childIntf_map.begin();
499 for(; it != bond_childIntf_map.end(); it++) {
501 bond_intf = it->second;
506 std::vector<std::string> prev_err_if_list =
508 if (std::find(prev_err_if_list.begin(),
509 prev_err_if_list.end(), it->first)
510 != prev_err_if_list.end()) {
524 }
else if (reset_state) {
533 VirtualGatewayConfig::SubnetList::iterator subnet_it =
535 while (subnet_it != source_list.end()) {
536 string subnet_str = subnet_it->ip_.to_string() +
"/" +
538 target_list.push_back(subnet_str);
544 AgentVhostConfig vhost_cfg;
545 AgentXenConfig xen_cfg;
546 AgentVmwareConfig vmware_cfg;
548 vector<AgentVgwConfig> gw_cfg_list;
552 vrouter_agent.set_log_file(param->
log_file());
553 vrouter_agent.set_config_file(param->
config_file());
554 vrouter_agent.set_log_local(param->
log_local());
555 vrouter_agent.set_log_flow(param->
log_flow());
557 vrouter_agent.set_log_level(param->
log_level());
559 vrouter_agent.set_tunnel_type(param->
tunnel_type());
560 vrouter_agent.set_hostname_cfg(param->
host_name());
568 vrouter_agent.set_control_ip(param->
mgmt_ip().to_string());
572 vhost_cfg.set_ip(param->
vhost_addr().to_string());
573 vhost_cfg.set_ip_prefix_len(param->
vhost_plen());
575 vhost_cfg.set_gateway(param->
gateway_list()[0].to_string());
578 vrouter_agent.set_vhost_cfg(vhost_cfg);
587 xen_cfg.set_xen_ll_ip(param->
xen_ll_addr().to_string());
588 xen_cfg.set_xen_ll_prefix_len(param->
xen_ll_plen());
589 vrouter_agent.set_xen_cfg(xen_cfg);
591 hypervisor =
"vmware";
593 vrouter_agent.set_vmware_cfg(vmware_cfg);
595 vrouter_agent.set_hypervisor(hypervisor);
598 VirtualGatewayConfigTable::Table::iterator it = table->
table().begin();
599 while (it != table->
table().end()) {
600 AgentVgwConfig gw_cfg;
603 vector<string> ip_blocks_list;
604 vector<string> route_str_list;
609 gw_cfg.set_interface_name(it->interface_name());
610 gw_cfg.set_vrf_name(it->vrf_name());
611 gw_cfg.set_ip_blocks_list(ip_blocks_list);
612 gw_cfg.set_route_list(route_str_list);
614 gw_cfg_list.push_back(gw_cfg);
617 vrouter_agent.set_gateway_cfg_list(gw_cfg_list);
618 vrouter_agent.set_headless_mode_cfg(
true);
620 vrouter_agent.set_bgpaas_enabled(
623 vrouter_agent.set_loopback_ip(param->
loopback_ip().to_string());
624 std::vector<string> gateway_list;
625 for (std::vector<Ip4Address>::const_iterator iter = param->
gateway_list().begin();
627 gateway_list.push_back((*iter).to_string());
629 vrouter_agent.set_gateway_list(gateway_list);
634 VrouterAgent vrouter_agent;
635 bool changed =
false, bgp_aas, port_mirror;
636 static bool first =
true;
639 vector<string> ip_list;
640 vector<string> dns_list;
644 vnsConstants vnsVrouterType;
649 vitf.set_name(vhost->
name());
651 vrouter_agent.set_vhost_if(vitf);
660 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
661 (VrouterAgentType::VROUTER_AGENT_TOR));
663 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
664 (VrouterAgentType::VROUTER_AGENT_TSN));
666 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
667 (VrouterAgentType::VROUTER_AGENT_EMBEDDED));
671 vrouter_agent.set_platform(vnsVrouterType.
672 VrouterAgentPlatformTypeMap.at
673 (VrouterAgentPlatformType::
674 VROUTER_AGENT_ON_NIC));
676 vrouter_agent.set_platform(vnsVrouterType.
677 VrouterAgentPlatformTypeMap.at
678 (VrouterAgentPlatformType::
679 VROUTER_AGENT_ON_HOST_DPDK));
681 vrouter_agent.set_platform(vnsVrouterType.
682 VrouterAgentPlatformTypeMap.at
683 (VrouterAgentPlatformType::
684 VROUTER_AGENT_ON_HOST));
695 VrouterObjectLimits prev_vr_limits =
prev_vrouter_.get_vr_limits();
696 if (vr_limits != prev_vr_limits) {
697 vrouter_agent.set_vr_limits(vr_limits);
710 vrouter_agent.set_bgpaas_enabled(bgp_aas);
716 if (
prev_vrouter_.get_port_mirror_enabled() != port_mirror) {
717 vrouter_agent.set_port_mirror_enabled(port_mirror);
722 vector<AgentInterface> phy_if_list;
729 pitf.set_name(intf->
name());
731 phy_if_list.push_back(pitf);
735 vrouter_agent.set_phy_if(phy_if_list);
740 std::vector<AgentXmppPeer> xmpp_list;
754 peer.set_status(
true);
756 peer.set_status(
false);
760 peer.set_primary(
true);
762 peer.set_primary(
false);
764 xmpp_list.push_back(peer);
770 vrouter_agent.set_xmpp_peer_list(xmpp_list);
776 ip_list.push_back(rid.to_string());
780 vrouter_agent.set_self_ip_list(ip_list);
794 vrouter_agent.set_dns_servers(dns_list);
799 std::vector<VrouterAgentResUsage> limit_exceeded_list;
800 VrouterAgentResUsage
usage;
801 bool limit_exceeded =
false;
802 bool table_limit =
false;
804 for(VrLimitExceeded::iterator res_map_it = res_usage_map.begin();
805 res_map_it != res_usage_map.end(); ++res_map_it ) {
806 if (res_map_it->second !=
"Normal") {
807 usage.set_name(res_map_it->first);
808 usage.set_status(res_map_it->second);
809 limit_exceeded_list.push_back(
usage);
810 if (res_map_it->second ==
"TableLimit" && !table_limit) {
812 limit_exceeded =
true;
813 }
else if (res_map_it->second ==
"Exceeded" && !limit_exceeded ) {
814 limit_exceeded =
true;
821 prev_vrouter_.get_vr_limit_exceeded_list() != limit_exceeded_list) {
822 vrouter_agent.set_vr_limit_exceeded_list(limit_exceeded_list);
823 prev_vrouter_.set_vr_limit_exceeded_list(limit_exceeded_list);
824 vrouter_agent.set_res_limit(limit_exceeded);
825 vrouter_agent.set_res_table_limit(table_limit);
830 std::vector<L3mhPhysicalInterfaceStatus> vr_l3mh_intf_list;
831 bool l3mh_phy_interface_down =
false;
834 L3mhPhysicalInterfaceStatus l3mh_interface_status;
836 l3mh_interface_status.set_name(intf->
name());
838 vr_l3mh_intf_list.push_back(l3mh_interface_status);
840 l3mh_phy_interface_down =
true;
845 prev_vrouter_.get_vr_l3mh_intf_list() != vr_l3mh_intf_list) {
846 vrouter_agent.set_vr_l3mh_intf_list(vr_l3mh_intf_list);
848 vrouter_agent.set_l3mh_phy_interface_down(l3mh_phy_interface_down);
857 VrouterStatsAgent stats;
864 static bool cpu_first =
true;
865 CpuLoadInfo cpu_load_info;
867 if (
prev_stats_.get_cpu_info() != cpu_load_info || cpu_first) {
868 stats.set_cpu_info(cpu_load_info);
884 (
const vector<string> &list) {
885 VrouterAgent vrouter_agent;
888 vrouter_agent.set_tor_prouter_list(list);
890 vrouter_agent.set_tsn_prouter_list(list);
892 vrouter_agent.set_embedded_prouter_list(list);
902 VrouterStats::Send(uve);
906 ComputeCpuStateTrace::Send(ccs);
910 ComputeCpuState astate;
911 VrouterCpuInfo ainfo;
912 vector<VrouterCpuInfo> aciv;
915 ainfo.set_cpu_share(info.get_cpu_share());
916 ainfo.set_mem_virt(info.get_meminfo().get_virt());
917 ainfo.set_mem_res(info.get_meminfo().get_res());
918 const SysMemInfo &sys_mem_info(info.get_sys_mem_info());
919 ainfo.set_used_sys_mem(sys_mem_info.get_used() -
920 sys_mem_info.get_buffers() - sys_mem_info.get_cached());
921 ainfo.set_one_min_cpuload(info.get_cpuload().get_one_min_avg());
922 aciv.push_back(ainfo);
923 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
uint32_t default_interval() const
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
AgentUveBase * uve() 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