7 #include <sandesh/common/vns_types.h>
28 : agent_(agent), phy_intf_set_(), prev_stats_(), prev_vrouter_(),
29 cpu_stats_count_(0), do_vn_walk_(false), do_vm_walk_(false),
30 do_interface_walk_(false), vn_walk_ref_(NULL), vm_walk_ref_(NULL),
31 interface_walk_ref_(NULL), vn_listener_id_(
DBTableBase::kInvalidId),
34 physical_device_listener_id_(
DBTableBase::kInvalidId),
36 *(agent_->event_manager())->io_service(),
"UveDBWalkTimer",
151 UveVrouterAgent::Send(uve);
155 VrouterAgent vrouter_agent;
157 vrouter_agent.set_virtual_machine_list(*(list.get()));
158 VrouterAgentObjectCount vm_count;
159 vm_count.set_active(list.get()->size());
160 vrouter_agent.set_vm_count(vm_count);
178 std::ostringstream ostr;
180 list.get()->push_back(ostr.str());
223 VrouterAgent vrouter_agent;
225 vrouter_agent.set_connected_networks(*(list.get()));
226 vrouter_agent.set_vn_count((*list).size());
253 list.get()->push_back(vn->
GetName());
300 VrouterAgent vrouter_agent;
302 vrouter_agent.set_interface_list(*(if_list.get()));
303 vrouter_agent.set_error_intf_list(*(err_if_list.get()));
304 vrouter_agent.set_no_config_intf_list(*(nova_if_list.get()));
306 vrouter_agent.set_unmanaged_if_list(*(unmanaged_list.get()));
307 prev_vrouter_.set_unmanaged_if_list(*(unmanaged_list.get()));
310 VrouterAgentObjectCount vmi_count;
311 vmi_count.set_active((if_list.get()->size() + nova_if_list.get()->size()));
312 vrouter_agent.set_vmi_count(vmi_count);
313 vrouter_agent.set_down_interface_count((err_if_list.get()->size() +
314 nova_if_list.get()->size()));
320 prev_vrouter_.set_no_config_intf_list(*(nova_if_list.get()));
323 (*err_if_list).clear();
324 (*nova_if_list).clear();
325 (*unmanaged_list).clear();
349 if (!pd || !pd->
master()) {
350 unmanaged_list.get()->push_back(port->
cfg_name());
367 bond_childIntf_map.begin();
368 for(; it != bond_childIntf_map.end(); it++) {
370 bond_intf = it->second;
372 err_if_list.get()->push_back(it->first);
383 intf_list.get()->push_back(port->
cfg_name());
385 err_if_list.get()->push_back(port->
cfg_name());
392 if (u == boost::uuids::nil_uuid()) {
432 intf_list, err_if_list, nova_if_list, unmanaged_list),
434 intf_list, err_if_list, nova_if_list, unmanaged_list));
444 bool set_state =
false, reset_state =
false;
448 bool vmport_active =
false;
450 switch(intf->
type()) {
491 bond_childIntf_map.begin();
492 for(; it != bond_childIntf_map.end(); it++) {
494 bond_intf = it->second;
499 std::vector<std::string> prev_err_if_list =
501 if (std::find(prev_err_if_list.begin(),
502 prev_err_if_list.end(), it->first)
503 != prev_err_if_list.end()) {
517 }
else if (reset_state) {
526 VirtualGatewayConfig::SubnetList::iterator subnet_it =
528 while (subnet_it != source_list.end()) {
529 string subnet_str = subnet_it->ip_.to_string() +
"/" +
531 target_list.push_back(subnet_str);
537 AgentVhostConfig vhost_cfg;
538 AgentXenConfig xen_cfg;
539 AgentVmwareConfig vmware_cfg;
541 vector<AgentVgwConfig> gw_cfg_list;
545 vrouter_agent.set_log_file(param->
log_file());
546 vrouter_agent.set_config_file(param->
config_file());
547 vrouter_agent.set_log_local(param->
log_local());
548 vrouter_agent.set_log_flow(param->
log_flow());
550 vrouter_agent.set_log_level(param->
log_level());
552 vrouter_agent.set_tunnel_type(param->
tunnel_type());
553 vrouter_agent.set_hostname_cfg(param->
host_name());
561 vrouter_agent.set_control_ip(param->
mgmt_ip().to_string());
565 vhost_cfg.set_ip(param->
vhost_addr().to_string());
566 vhost_cfg.set_ip_prefix_len(param->
vhost_plen());
568 vhost_cfg.set_gateway(param->
gateway_list()[0].to_string());
571 vrouter_agent.set_vhost_cfg(vhost_cfg);
580 xen_cfg.set_xen_ll_ip(param->
xen_ll_addr().to_string());
581 xen_cfg.set_xen_ll_prefix_len(param->
xen_ll_plen());
582 vrouter_agent.set_xen_cfg(xen_cfg);
584 hypervisor =
"vmware";
586 vrouter_agent.set_vmware_cfg(vmware_cfg);
588 vrouter_agent.set_hypervisor(hypervisor);
591 VirtualGatewayConfigTable::Table::iterator it = table->
table().begin();
592 while (it != table->
table().end()) {
593 AgentVgwConfig gw_cfg;
596 vector<string> ip_blocks_list;
597 vector<string> route_str_list;
602 gw_cfg.set_interface_name(it->interface_name());
603 gw_cfg.set_vrf_name(it->vrf_name());
604 gw_cfg.set_ip_blocks_list(ip_blocks_list);
605 gw_cfg.set_route_list(route_str_list);
607 gw_cfg_list.push_back(gw_cfg);
610 vrouter_agent.set_gateway_cfg_list(gw_cfg_list);
611 vrouter_agent.set_headless_mode_cfg(
true);
613 vrouter_agent.set_bgpaas_enabled(
616 vrouter_agent.set_loopback_ip(param->
loopback_ip().to_string());
617 std::vector<string> gateway_list;
618 for (std::vector<Ip4Address>::const_iterator iter = param->
gateway_list().begin();
620 gateway_list.push_back((*iter).to_string());
622 vrouter_agent.set_gateway_list(gateway_list);
627 VrouterAgent vrouter_agent;
628 bool changed =
false, bgp_aas, port_mirror;
629 static bool first =
true, build_info =
false;
632 vector<string> ip_list;
633 vector<string> dns_list;
637 vnsConstants vnsVrouterType;
642 vitf.set_name(vhost->
name());
644 vrouter_agent.set_vhost_if(vitf);
653 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
654 (VrouterAgentType::VROUTER_AGENT_TOR));
656 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
657 (VrouterAgentType::VROUTER_AGENT_TSN));
659 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
660 (VrouterAgentType::VROUTER_AGENT_EMBEDDED));
664 vrouter_agent.set_platform(vnsVrouterType.
665 VrouterAgentPlatformTypeMap.at
666 (VrouterAgentPlatformType::
667 VROUTER_AGENT_ON_NIC));
669 vrouter_agent.set_platform(vnsVrouterType.
670 VrouterAgentPlatformTypeMap.at
671 (VrouterAgentPlatformType::
672 VROUTER_AGENT_ON_HOST_DPDK));
674 vrouter_agent.set_platform(vnsVrouterType.
675 VrouterAgentPlatformTypeMap.at
676 (VrouterAgentPlatformType::
677 VROUTER_AGENT_ON_HOST));
688 VrouterObjectLimits prev_vr_limits =
prev_vrouter_.get_vr_limits();
689 if (vr_limits != prev_vr_limits) {
690 vrouter_agent.set_vr_limits(vr_limits);
696 string build_info_str;
699 vrouter_agent.set_build_info(build_info_str);
708 vrouter_agent.set_bgpaas_enabled(bgp_aas);
714 if (
prev_vrouter_.get_port_mirror_enabled() != port_mirror) {
715 vrouter_agent.set_port_mirror_enabled(port_mirror);
720 vector<AgentInterface> phy_if_list;
727 pitf.set_name(intf->
name());
729 phy_if_list.push_back(pitf);
733 vrouter_agent.set_phy_if(phy_if_list);
738 std::vector<AgentXmppPeer> xmpp_list;
752 peer.set_status(
true);
754 peer.set_status(
false);
758 peer.set_primary(
true);
760 peer.set_primary(
false);
762 xmpp_list.push_back(peer);
768 vrouter_agent.set_xmpp_peer_list(xmpp_list);
774 ip_list.push_back(rid.to_string());
778 vrouter_agent.set_self_ip_list(ip_list);
793 vrouter_agent.set_dns_servers(dns_list);
798 std::vector<VrouterAgentResUsage> limit_exceeded_list;
799 VrouterAgentResUsage
usage;
800 bool limit_exceeded =
false;
801 bool table_limit =
false;
803 for(VrLimitExceeded::iterator res_map_it = res_usage_map.begin();
804 res_map_it != res_usage_map.end(); ++res_map_it ) {
805 if (res_map_it->second !=
"Normal") {
806 usage.set_name(res_map_it->first);
807 usage.set_status(res_map_it->second);
808 limit_exceeded_list.push_back(
usage);
809 if (res_map_it->second ==
"TableLimit" && !table_limit) {
811 limit_exceeded =
true;
812 }
else if (res_map_it->second ==
"Exceeded" && !limit_exceeded ) {
813 limit_exceeded =
true;
820 prev_vrouter_.get_vr_limit_exceeded_list() != limit_exceeded_list) {
821 vrouter_agent.set_vr_limit_exceeded_list(limit_exceeded_list);
822 prev_vrouter_.set_vr_limit_exceeded_list(limit_exceeded_list);
823 vrouter_agent.set_res_limit(limit_exceeded);
824 vrouter_agent.set_res_table_limit(table_limit);
829 std::vector<L3mhPhysicalInterfaceStatus> vr_l3mh_intf_list;
830 bool l3mh_phy_interface_down =
false;
833 L3mhPhysicalInterfaceStatus l3mh_interface_status;
835 l3mh_interface_status.set_name(intf->
name());
837 vr_l3mh_intf_list.push_back(l3mh_interface_status);
839 l3mh_phy_interface_down =
true;
844 prev_vrouter_.get_vr_l3mh_intf_list() != vr_l3mh_intf_list) {
845 vrouter_agent.set_vr_l3mh_intf_list(vr_l3mh_intf_list);
847 vrouter_agent.set_l3mh_phy_interface_down(l3mh_phy_interface_down);
856 VrouterStatsAgent stats;
863 static bool cpu_first =
true;
864 CpuLoadInfo cpu_load_info;
866 if (
prev_stats_.get_cpu_info() != cpu_load_info || cpu_first) {
867 stats.set_cpu_info(cpu_load_info);
883 (
const vector<string> &list) {
884 VrouterAgent vrouter_agent;
887 vrouter_agent.set_tor_prouter_list(list);
889 vrouter_agent.set_tsn_prouter_list(list);
891 vrouter_agent.set_embedded_prouter_list(list);
901 VrouterStats::Send(uve);
905 ComputeCpuStateTrace::Send(ccs);
909 ComputeCpuState astate;
910 VrouterCpuInfo ainfo;
911 vector<VrouterCpuInfo> aciv;
914 ainfo.set_cpu_share(info.get_cpu_share());
915 ainfo.set_mem_virt(info.get_meminfo().get_virt());
916 ainfo.set_mem_res(info.get_meminfo().get_res());
917 const SysMemInfo &sys_mem_info(info.get_sys_mem_info());
918 ainfo.set_used_sys_mem(sys_mem_info.get_used() -
919 sys_mem_info.get_buffers() - sys_mem_info.get_cached());
920 ainfo.set_one_min_cpuload(info.get_cpuload().get_one_min_avg());
921 aciv.push_back(ainfo);
922 astate.set_cpu_info(aciv);
boost::asio::ip::address_v4 Ip4Address
std::map< std::string, std::string > VrLimitExceeded
bool GetBuildInfo(std::string &build_info_str)
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)