Skip to content

Commit

Permalink
Send Interface information in UVE of its own.
Browse files Browse the repository at this point in the history
-Defined new UVEs for VM interface, Logical interface and Physical interface. The parent object for these interfaces will have only the key value. All the attributes for interfaces will go in UVE of its own.
-Update VM UVE to send only keys of VMIs belonging to VM
-Update VN UVE to not send aggregate statistics per VN. This is not required because VM Interface UVE stats can now be queried on a per VN basis.
-Update Prouter UVE to send only keys in lists of logical_interface and physical_interface
-Update viz.sandesh to define new tables for new UVEs (changes on behalf of sundar)

Partial-Bug: #1449433
(cherry picked from commit 49371d8)

Change-Id: I0e096a8b27cf5e9247b89ef7dbbdcb68131d5067
  • Loading branch information
ashoksr committed May 6, 2015
1 parent 284941a commit aeb1895
Show file tree
Hide file tree
Showing 48 changed files with 2,865 additions and 1,822 deletions.
52 changes: 52 additions & 0 deletions src/analytics/viz.sandesh
Expand Up @@ -54,6 +54,7 @@ const string OBJECT_TABLE = "ObjectTable"
//The following are the object tables and some of them are UVEs
const string VN_TABLE = "ObjectVNTable"
const string VM_TABLE = "ObjectVMTable"
const string VMI_TABLE = "ObjectVMITable"
const string SI_TABLE = "ObjectSITable"
const string VROUTER_TABLE = "ObjectVRouter"
const string BGP_PEER_TABLE = "ObjectBgpPeer"
Expand All @@ -76,9 +77,12 @@ const string DISK_TABLE = "ObjectDiskTable"
const string SERVER_TABLE = "ObjectServerTable"
const string PROUTER_TABLE = "ObjectPRouter"
const string CONFIG_OBJECT_TABLE_USER = "ConfigObjectTableByUser"
const string PHYSICAL_IF_TABLE = "ObjectPhysicalInterfaceTable"
const string LOGICAL_IF_TABLE = "ObjectLogicalInterfaceTable"

const string VN_DISPLAY_NAME = "Virtual Network"
const string VM_DISPLAY_NAME = "Virtual Machine"
const string VMI_DISPLAY_NAME = "Virtual Machine Interface"
const string SI_DISPLAY_NAME = "Service Instance"
const string VROUTER_DISPLAY_NAME = "vRouter"
const string BGP_PEER_DISPLAY_NAME = "BGP Peer"
Expand All @@ -101,6 +105,8 @@ const string STORAGE_DISK_DISPLAY_NAME = "Storage RawDisk"
const string SERVER_TABLE_DISPLAY_NAME = "Server Table Info"
const string PROUTER_DISPLAY_NAME = "pRouter"
const string CONFIG_OBJECT_USER_DISPLAY_NAME = "Config Object by User Table"
const string LOGICAL_IF_DISPLAY_NAME = "Logical Interface"
const string PHYSICAL_IF_DISPLAY_NAME = "Physical Interface"

const string SYSTEM_LOG = "SystemLog"
const string OBJECT_LOG = "ObjectLog"
Expand Down Expand Up @@ -329,6 +335,7 @@ const i32 AnalyticsTTL = 48
const map<string, string> UVE_MAP = {
"virtual-network" : VN_TABLE,
"virtual-machine" : VM_TABLE,
"virtual-machine-interface" : VMI_TABLE,
"service-instance" : SI_TABLE,
"vrouter" : VROUTER_TABLE,
"control-node" : BGP_ROUTER_TABLE,
Expand All @@ -345,6 +352,8 @@ const map<string, string> UVE_MAP = {
"storage-disk" : DISK_TABLE,
"server" : SERVER_TABLE,
"prouter" : PROUTER_TABLE,
"physical-interface" : PHYSICAL_IF_TABLE,
"logical-interface" : LOGICAL_IF_TABLE
}

struct objtable_info {
Expand All @@ -365,6 +374,10 @@ const map<string, objtable_info> _OBJECT_TABLES = {
'objtable_display_name' : VM_DISPLAY_NAME
'log_query_name' : "virtual-machine"
}
VMI_TABLE : {
'objtable_display_name' : VMI_DISPLAY_NAME
'log_query_name' : "virtual-machine-interface"
}
SI_TABLE : {
'objtable_display_name' : SI_DISPLAY_NAME
'log_query_name' : "service-instance"
Expand Down Expand Up @@ -445,6 +458,14 @@ const map<string, objtable_info> _OBJECT_TABLES = {
'objtable_display_name' : CONFIG_OBJECT_USER_DISPLAY_NAME
'log_query_name' : "config-user"
}
PHYSICAL_IF_TABLE : {
'objtable_display_name' : PHYSICAL_IF_DISPLAY_NAME
'log_query_name' : "physical-interface"
}
LOGICAL_IF_TABLE : {
'objtable_display_name' : LOGICAL_IF_DISPLAY_NAME
'log_query_name' : "logical-interface"
}
}

// Analytics table schema defination
Expand Down Expand Up @@ -1217,6 +1238,37 @@ const list<stat_table> _STAT_TABLES = [
{ 'name' : 'disk_usage_info.partition_space_available_1k', 'datatype' : 'int', 'index' : false },
]
},
{
'display_name' : 'Virtual Machine Floating IP Statistics',
'stat_type' : 'UveVMInterfaceAgent'
'stat_attr' : 'fip_diff_stats',
'obj_table' : VMI_TABLE,
'attributes': [
{ 'name' : 'virtual_network', 'datatype' : 'string', 'index' : true },
{ 'name' : 'fip_diff_stats.other_vn', 'datatype' : 'string', 'index' : true },
{ 'name' : 'fip_diff_stats.ip_address', 'datatype' : 'string', 'index' : true },
{ 'name' : 'fip_diff_stats.in_pkts', 'datatype' : 'int', 'index' : false },
{ 'name' : 'fip_diff_stats.in_bytes', 'datatype' : 'int', 'index' : false },
{ 'name' : 'fip_diff_stats.out_pkts', 'datatype' : 'int', 'index' : false },
{ 'name' : 'fip_diff_stats.out_bytes', 'datatype' : 'int', 'index' : false }
]
},
{
'display_name' : 'Virtual Machine Interface Statistics',
'stat_type' : 'UveVMInterfaceAgent'
'stat_attr' : 'if_stats',
'obj_table' : VMI_TABLE,
'attributes': [
{ 'name' : 'vm_name', 'datatype' : 'string', 'index' : true },
{ 'name' : 'virtual_network', 'datatype' : 'string', 'index' : true },
{ 'name' : 'if_stats.in_pkts', 'datatype' : 'int', 'index' : false },
{ 'name' : 'if_stats.in_bytes', 'datatype' : 'int', 'index' : false },
{ 'name' : 'if_stats.out_pkts', 'datatype' : 'int', 'index' : false },
{ 'name' : 'if_stats.out_bytes', 'datatype' : 'int', 'index' : false },
{ 'name' : 'if_stats.in_bw_usage', 'datatype' : 'int', 'index' : false },
{ 'name' : 'if_stats.out_bw_usage', 'datatype' : 'int', 'index' : false }
]
}
]

const list<query_table> _TABLES = [
Expand Down
4 changes: 4 additions & 0 deletions src/base/timer.h
Expand Up @@ -92,6 +92,10 @@ class Timer {
return (state_ == Fired);
}

int time() const {
return time_;
}

bool cancelled() const {
tbb::mutex::scoped_lock lock(mutex_);
return (state_ == Cancelled);
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/test/SConscript
Expand Up @@ -45,6 +45,7 @@ test_lib_srcs = ['test_agent_init.cc',
'../uve/test/agent_param_test.cc',
'../uve/test/agent_uve_test.cc',
'../uve/test/agent_stats_collector_test.cc',
'../uve/test/interface_uve_table_test.cc',
'../uve/test/prouter_uve_table_test.cc',
'../uve/test/vm_uve_table_test.cc',
'../uve/test/vn_uve_table_test.cc',
Expand Down
22 changes: 0 additions & 22 deletions src/vnsw/agent/test/test_util.cc
Expand Up @@ -793,28 +793,6 @@ bool VrfStatsMatchPrev(int vrf_id, uint64_t discards, uint64_t resolves,
return false;
}

bool VnStatsMatch(char *vn, uint64_t in_bytes, uint64_t in_pkts,
uint64_t out_bytes, uint64_t out_pkts) {
VnUveTableTest *vnut = static_cast<VnUveTableTest *>
(Agent::GetInstance()->uve()->vn_uve_table());
const VnUveEntry* entry = vnut->GetVnUveEntry(string(vn));
if (!entry) {
LOG(DEBUG, "Vn " << string(vn) << " NOT FOUND");
return false;
}
uint64_t match_in_bytes, match_out_bytes, match_in_pkts, match_out_pkts;
entry->GetInStats(&match_in_bytes, &match_in_pkts);
entry->GetOutStats(&match_out_bytes, &match_out_pkts);

if (match_in_bytes == in_bytes && match_in_pkts == in_pkts &&
match_out_bytes == out_bytes && match_out_pkts == out_pkts) {
return true;
}
LOG(DEBUG, "in_bytes " << match_in_bytes << " in_tpkts " << match_in_pkts <<
"out bytes " << match_out_bytes << " out_tpkts " << match_out_pkts);
return false;
}

bool VmPortStats(PortInfo *input, int id, uint32_t bytes, uint32_t pkts) {
Interface *intf;
VmInterfaceKey key(AgentKey::ADD_DEL_CHANGE, MakeUuid(input[id].intf_id),
Expand Down
5 changes: 4 additions & 1 deletion src/vnsw/agent/uve/SConscript
Expand Up @@ -69,7 +69,8 @@ env.Default(sdist_gen)
env.Alias("vrouter:node_mgr", sdist_gen)

# Generate the C++ source files
SandeshGenFiles = env.SandeshGenCpp('port_bmap.sandesh')
SandeshGenFiles = env.SandeshGenCpp('interface.sandesh')
SandeshGenFiles += env.SandeshGenCpp('port_bmap.sandesh')
SandeshGenFiles += env.SandeshGenCpp('vrouter.sandesh')
SandeshGenFiles += env.SandeshGenCpp('virtual_machine.sandesh')
SandeshGenFiles += env.SandeshGenCpp('virtual_network.sandesh')
Expand All @@ -91,6 +92,7 @@ libuve = env.Library('uve',
SandeshGenObjs +
[
'agent_uve_base.cc',
'interface_uve_table.cc',
'l4_port_bitmap.cc',
'prouter_uve_table.cc',
'vm_uve_entry_base.cc',
Expand All @@ -105,6 +107,7 @@ libstatsuve = env.Library('statsuve',
StatsSandeshGenObjs +
[
'agent_uve.cc',
'interface_uve_stats_table.cc',
'stats_manager.cc',
'vm_stat.cc',
'vm_uve_entry.cc',
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/uve/agent_uve.cc
Expand Up @@ -17,6 +17,7 @@
#include <uve/vm_uve_table.h>
#include <uve/vn_uve_table.h>
#include <uve/vrouter_uve_entry.h>
#include <uve/interface_uve_stats_table.h>

AgentUve::AgentUve(Agent *agent, uint64_t intvl, uint32_t default_intvl,
uint32_t incremental_intvl)
Expand All @@ -26,6 +27,8 @@ AgentUve::AgentUve(Agent *agent, uint64_t intvl, uint32_t default_intvl,
vn_uve_table_.reset(new VnUveTable(agent, default_intvl));
vm_uve_table_.reset(new VmUveTable(agent, default_intvl));
vrouter_uve_entry_.reset(new VrouterUveEntry(agent));
interface_uve_table_.reset(new InterfaceUveStatsTable(agent,
default_intvl));
}

AgentUve::~AgentUve() {
Expand Down
4 changes: 4 additions & 0 deletions src/vnsw/agent/uve/agent_uve_base.cc
Expand Up @@ -31,6 +31,7 @@ AgentUveBase::AgentUveBase(Agent *agent, uint64_t intvl, bool create_objects,
uint32_t default_intvl, uint32_t incremental_intvl)
: vn_uve_table_(NULL), vm_uve_table_(NULL), vrouter_uve_entry_(NULL),
prouter_uve_table_(new ProuterUveTable(agent, default_intvl)),
interface_uve_table_(NULL),
default_interval_(default_intvl),
incremental_interval_(incremental_intvl),
agent_(agent), bandwidth_intvl_(intvl),
Expand All @@ -41,6 +42,7 @@ AgentUveBase::AgentUveBase(Agent *agent, uint64_t intvl, bool create_objects,
vn_uve_table_.reset(new VnUveTableBase(agent, default_intvl));
vm_uve_table_.reset(new VmUveTableBase(agent, default_intvl));
vrouter_uve_entry_.reset(new VrouterUveEntryBase(agent));
interface_uve_table_.reset(new InterfaceUveTable(agent, default_intvl));
}
singleton_ = this;
}
Expand All @@ -53,6 +55,7 @@ void AgentUveBase::Shutdown() {
vm_uve_table_.get()->Shutdown();
vrouter_uve_entry_.get()->Shutdown();
prouter_uve_table_.get()->Shutdown();
interface_uve_table_.get()->Shutdown();
connection_state_manager_->Shutdown();
vrouter_stats_collector_->Shutdown();
}
Expand Down Expand Up @@ -189,5 +192,6 @@ void AgentUveBase::RegisterDBClients() {
vm_uve_table_.get()->RegisterDBClients();
vrouter_uve_entry_.get()->RegisterDBClients();
prouter_uve_table_.get()->RegisterDBClients();
interface_uve_table_.get()->RegisterDBClients();
}

9 changes: 8 additions & 1 deletion src/vnsw/agent/uve/agent_uve_base.h
Expand Up @@ -10,6 +10,7 @@
#include <uve/vm_uve_table_base.h>
#include <uve/vrouter_uve_entry_base.h>
#include <uve/prouter_uve_table.h>
#include <uve/interface_uve_table.h>
#include <boost/scoped_ptr.hpp>

class VrouterStatsCollector;
Expand Down Expand Up @@ -41,7 +42,12 @@ class AgentUveBase {
VrouterUveEntryBase* vrouter_uve_entry() const {
return vrouter_uve_entry_.get();
}
ProuterUveTable* prouter_uve_table() const { return prouter_uve_table_.get(); }
ProuterUveTable* prouter_uve_table() const {
return prouter_uve_table_.get();
}
InterfaceUveTable* interface_uve_table() const {
return interface_uve_table_.get();
}
VrouterStatsCollector *vrouter_stats_collector() const {
return vrouter_stats_collector_.get();
}
Expand All @@ -57,6 +63,7 @@ class AgentUveBase {
boost::scoped_ptr<VmUveTableBase> vm_uve_table_;
boost::scoped_ptr<VrouterUveEntryBase> vrouter_uve_entry_;
boost::scoped_ptr<ProuterUveTable> prouter_uve_table_;
boost::scoped_ptr<InterfaceUveTable> interface_uve_table_;
uint32_t default_interval_;
uint32_t incremental_interval_;
static AgentUveBase *singleton_;
Expand Down
59 changes: 59 additions & 0 deletions src/vnsw/agent/uve/interface.sandesh
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
*/

include "vnsw/agent/uve/port_bmap.sandesh"

struct VmFloatingIPAgent {
1: string virtual_network;
2: string ip_address;
}

struct VmFloatingIPStats {
1: string virtual_network;
2: string ip_address;
3: u64 in_pkts;
4: u64 in_bytes;
5: u64 out_pkts;
6: u64 out_bytes;
}

/*
* VM's interfaces' stats samples (diff stats)
*/
struct VmInterfaceStats {
1: u64 in_pkts;
2: u64 in_bytes;
3: u64 out_pkts;
4: u64 out_bytes;
5: u64 in_bw_usage;
6: u64 out_bw_usage;
}

struct UveVMInterfaceAgent {
1: string name (key="ObjectVMITable")
2: optional bool deleted
3: optional string ip_address;
4: string virtual_network;
5: optional string mac_address;
6: optional u32 label;
7: optional bool active;
8: string vm_name;
9: optional string gateway;
10: optional bool l2_active;
11: optional string uuid;
12: optional string ip6_address;
13: optional bool ip6_active;
14: optional port_bmap.PortBucketBitmap port_bucket_bmap;
15: optional list<VmFloatingIPAgent> floating_ips;
/* List of Floating Ips along with total stats */
16: optional list<VmFloatingIPStats> fip_agg_stats;
17: optional list<VmFloatingIPStats> fip_diff_stats (tags=".virtual_network,.ip_address")
/* Will have only 1 element if_stats list. Made as list because of analytics
* stats infra restriction */
18: optional list<VmInterfaceStats> if_stats (tags="vm_name, virtual_network")
}

uve sandesh UveVMInterfaceAgentTrace {
1: UveVMInterfaceAgent data;
}

0 comments on commit aeb1895

Please sign in to comment.