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()) {
398 (agent_->interface_table()->FindActiveEntry(&key));
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_max_vm_flows_cfg((uint32_t)param->
max_vm_flows());
562 vrouter_agent.set_control_ip(param->
mgmt_ip().to_string());
566 vhost_cfg.set_ip(param->
vhost_addr().to_string());
567 vhost_cfg.set_ip_prefix_len(param->
vhost_plen());
569 vhost_cfg.set_gateway(param->
gateway_list()[0].to_string());
572 vrouter_agent.set_vhost_cfg(vhost_cfg);
581 xen_cfg.set_xen_ll_ip(param->
xen_ll_addr().to_string());
582 xen_cfg.set_xen_ll_prefix_len(param->
xen_ll_plen());
583 vrouter_agent.set_xen_cfg(xen_cfg);
585 hypervisor =
"vmware";
587 vrouter_agent.set_vmware_cfg(vmware_cfg);
589 vrouter_agent.set_hypervisor(hypervisor);
592 VirtualGatewayConfigTable::Table::iterator it = table->
table().begin();
593 while (it != table->
table().end()) {
594 AgentVgwConfig gw_cfg;
597 vector<string> ip_blocks_list;
598 vector<string> route_str_list;
603 gw_cfg.set_interface_name(it->interface_name());
604 gw_cfg.set_vrf_name(it->vrf_name());
605 gw_cfg.set_ip_blocks_list(ip_blocks_list);
606 gw_cfg.set_route_list(route_str_list);
608 gw_cfg_list.push_back(gw_cfg);
611 vrouter_agent.set_gateway_cfg_list(gw_cfg_list);
612 vrouter_agent.set_headless_mode_cfg(
true);
614 vrouter_agent.set_bgpaas_enabled(
617 vrouter_agent.set_loopback_ip(param->
loopback_ip().to_string());
618 std::vector<string> gateway_list;
619 for (std::vector<Ip4Address>::const_iterator iter = param->
gateway_list().begin();
621 gateway_list.push_back((*iter).to_string());
623 vrouter_agent.set_gateway_list(gateway_list);
628 VrouterAgent vrouter_agent;
629 bool changed =
false, bgp_aas, port_mirror;
630 static bool first =
true, build_info =
false;
633 vector<string> ip_list;
634 vector<string> dns_list;
638 vnsConstants vnsVrouterType;
643 vitf.set_name(vhost->
name());
645 vrouter_agent.set_vhost_if(vitf);
654 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
655 (VrouterAgentType::VROUTER_AGENT_TOR));
657 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
658 (VrouterAgentType::VROUTER_AGENT_TSN));
660 vrouter_agent.set_mode(vnsVrouterType.VrouterAgentTypeMap.at
661 (VrouterAgentType::VROUTER_AGENT_EMBEDDED));
665 vrouter_agent.set_platform(vnsVrouterType.
666 VrouterAgentPlatformTypeMap.at
667 (VrouterAgentPlatformType::
668 VROUTER_AGENT_ON_NIC));
670 vrouter_agent.set_platform(vnsVrouterType.
671 VrouterAgentPlatformTypeMap.at
672 (VrouterAgentPlatformType::
673 VROUTER_AGENT_ON_HOST_DPDK));
675 vrouter_agent.set_platform(vnsVrouterType.
676 VrouterAgentPlatformTypeMap.at
677 (VrouterAgentPlatformType::
678 VROUTER_AGENT_ON_HOST));
689 VrouterObjectLimits prev_vr_limits =
prev_vrouter_.get_vr_limits();
690 if (vr_limits != prev_vr_limits) {
691 vrouter_agent.set_vr_limits(vr_limits);
697 string build_info_str;
700 vrouter_agent.set_build_info(build_info_str);
709 vrouter_agent.set_bgpaas_enabled(bgp_aas);
715 if (
prev_vrouter_.get_port_mirror_enabled() != port_mirror) {
716 vrouter_agent.set_port_mirror_enabled(port_mirror);
721 vector<AgentInterface> phy_if_list;
728 pitf.set_name(intf->
name());
730 phy_if_list.push_back(pitf);
734 vrouter_agent.set_phy_if(phy_if_list);
739 std::vector<AgentXmppPeer> xmpp_list;
753 peer.set_status(
true);
755 peer.set_status(
false);
759 peer.set_primary(
true);
761 peer.set_primary(
false);
763 xmpp_list.push_back(peer);
769 vrouter_agent.set_xmpp_peer_list(xmpp_list);
775 ip_list.push_back(rid.to_string());
779 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;
886 vrouter_agent.set_name(agent_->agent_name());
887 if (agent_->tor_agent_enabled()) {
888 vrouter_agent.set_tor_prouter_list(list);
889 }
else if (agent_->tsn_enabled()) {
890 vrouter_agent.set_tsn_prouter_list(list);
892 vrouter_agent.set_embedded_prouter_list(list);
894 DispatchVrouterMsg(vrouter_agent);
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);
std::string GetMacAddress(const MacAddress &mac) const
XmppChannel * GetXmppChannel()
const std::string & subcluster_name() const
void InterfaceWalkDone(DBTableBase *base, StringVectorPtr if_l, StringVectorPtr err_if_l, StringVectorPtr nova_if_l, StringVectorPtr unmanaged_list)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
const std::string & vhost_name() const
virtual void DispatchComputeCpuStateMsg(const ComputeCpuState &ccs)
DBState * GetState(DBTableBase *tbl_base, ListenerId listener) const
bool tor_agent_enabled() const
DBTable::DBTableWalkRef vm_walk_ref_
const boost::uuids::uuid & GetUuid() const
uint32_t flow_cache_timeout() const
const std::string & vmware_physical_port() const
const Interface * vhost_interface() const
bool vrouter_on_host_dpdk() const
const std::vector< std::string > collector_server_list() const
PhysicalDeviceTable * physical_device_table() const
VrouterStatsAgent prev_stats_
void SetState(DBTableBase *tbl_base, ListenerId listener, DBState *state)
const AddressList & gateway_list() const
const std::string & dns_server(uint8_t idx) const
void PhysicalDeviceNotify(DBTablePartBase *partition, DBEntryBase *e)
const Ip4Address & loopback_ip() const
const std::vector< std::string > controller_server_list() const
std::map< std::string, std::string > VrLimitExceeded
DBTableWalkRef AllocWalker(WalkFn walk_fn, WalkCompleteFn walk_complete)
virtual void DispatchVrouterStatsMsg(const VrouterStatsAgent &uve)
InterfaceTable * interface_table() const
VnTable * vn_table() const
Interface * physical_interface() const
boost::shared_ptr< std::vector< std::string > > StringVectorPtr
void AppendInterfaceInternal(const VmInterface *port, StringVectorPtr intf_list, StringVectorPtr err_if_list)
const MacAddress & mac() const
static std::string UuidToString(const boost::uuids::uuid &id)
float vr_limit_high_watermark()
bool AppendInterface(DBTablePartBase *part, DBEntryBase *entry, StringVectorPtr intf_list, StringVectorPtr err_list, StringVectorPtr nova_if_list, StringVectorPtr unmanaged_list)
const Ip4Address & vhost_addr() const
const int vhost_plen() const
static void FillCpuInfo(CpuLoadInfo &info, bool system)
AgentXmppChannel * controller_xmpp_channel(uint8_t idx) const
const boost::uuids::uuid & GetUuid() const
PhysicalDevice * VmiToPhysicalDevice(const VmInterface *port)
const std::string & xen_ll_name() const
void VnNotify(DBTablePartBase *partition, DBEntryBase *e)
bool vrouter_on_nic_mode() const
virtual xmps::PeerState GetPeerState() const =0
virtual bool SendVrouterMsg()
void Unregister(ListenerId listener)
float vr_limit_low_watermark()
void ReleaseWalker(DBTableWalkRef &walk)
std::string ToString() const
void BuildAndSendComputeCpuStateMsg(const CpuLoadInfo &info)
ListenerId Register(ChangeCallback callback, const std::string &name="unspecified")
void WalkAgain(DBTableWalkRef walk)
const std::string & tunnel_type() const
BgpAsAService * bgp_as_a_service() const
void InterfaceNotify(DBTablePartBase *partition, DBEntryBase *e)
void VnWalkDone(DBTableBase *base, StringVectorPtr list)
const std::vector< std::string > dns_server_list() const
DBTableBase::ListenerId vn_listener_id_
VrouterUveEntryBase(Agent *agent)
static const std::string integerToString(const NumberType &num)
const BondChildIntfMap & getBondChildIntfMap() const
PhysicalDevice * InterfaceToPhysicalDevice(Interface *intf)
Ip4Address router_id() const
PhysicalDevice * physical_device() const
static const uint32_t kDefaultInterval
void SubnetToStringList(VirtualGatewayConfig::SubnetList &l1, std::vector< std::string > &l2)
uint16_t http_server_port() const
uint32_t linklocal_system_flows() const
bool isVmwareMode() const
static const std::string & NullString()
bool os_oper_state() const
bool vrouter_on_host() const
const Table & table() const
AgentParam * params() const
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
const Ip4Address & xen_ll_addr() const
const std::string & agent_name() const
void VmWalkDone(DBTableBase *base, StringVectorPtr list)
void ClearState(DBTableBase *tbl_base, ListenerId listener)
DBTableBase::ListenerId physical_device_listener_id_
BondChildIntfMap::const_iterator BondChildIntfMapIterator
boost::asio::ip::address_v4 Ip4Address
static MirrorTable * GetInstance()
const std::string & host_name() const
bool AppendVm(DBTablePartBase *part, DBEntryBase *e, StringVectorPtr l)
float max_vm_flows() const
const boost::uuids::uuid & logical_interface() const
bool router_id_configured()
bool AppendVn(DBTablePartBase *part, DBEntryBase *e, StringVectorPtr l)
const int xen_ll_plen() const
const std::string log_file() const
VrouterAgent prev_vrouter_
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
VrLimitExceeded & get_vr_limits_exceeded_map()
void SendVrouterProuterAssociation(const std::vector< std::string > &list)
const std::string & cfg_name() const
static const int kInvalidId
DBTableBase::ListenerId vm_listener_id_
void VmNotify(DBTablePartBase *partition, DBEntryBase *e)
const std::string & config_file() const
const std::string & name() const
PhysicalDevice * physical_device() const
std::vector< Subnet > SubnetList
const std::string & log_level() const
virtual ~VrouterUveEntryBase()
uint32_t linklocal_vm_flows() const
const string & GetName() const
void BuildAgentConfig(VrouterAgent &vrouter_agent)
const std::string & log_category() const
const uint64_t controller_xmpp_channel_setup_time(uint8_t idx) const
std::map< const std::string, Bond_ChildIntf > BondChildIntfMap
bool GetBuildInfo(std::string &build_info_str)
DBTable::DBTableWalkRef interface_walk_ref_
const Ip4Address & mgmt_ip() const
virtual void DispatchVrouterMsg(const VrouterAgent &uve)
const std::vector< std::string > & eth_port_list() const
VirtualGatewayConfigTable * vgw_config_table() const
VmTable * vm_table() const
PhysicalInterfaceSet phy_intf_set_
const int8_t & ifmap_active_xmpp_server_index() const
bool StartInterfaceWalk()
static bool DeleteTimer(Timer *Timer)
DBTableBase::ListenerId intf_listener_id_
DBTable::DBTableWalkRef vn_walk_ref_
VrouterObjectLimits GetVrouterObjectLimits()