Skip to content

Commit

Permalink
Removal of discovery client library references from all daemons.
Browse files Browse the repository at this point in the history
Change-Id: Ie95ee2fd1a0fe20fac3abecc7c56347b8c47e8db
Depends-On:I0a80d792e66403ee02b8db5eedaa2165ad434e13
Partial-Bug:1636319
  • Loading branch information
nipak committed Mar 1, 2017
1 parent aa38e5a commit 89170cc
Show file tree
Hide file tree
Showing 166 changed files with 198 additions and 6,756 deletions.
1 change: 0 additions & 1 deletion SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env.Alias('controller/test', [
'controller/src/bgp:test',
'controller/src/control-node:test',
'controller/src/db:test',
'controller/src/discovery:test',
'controller/src/dns:test',
'controller/src/database/gendb:test',
'controller/src/ifmap:test',
Expand Down
2 changes: 0 additions & 2 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ BuildEnv['SANDESH_DOC_FILES'] = sandesh_doc_files
# Discovery client
discovery_client_doc_files = []
discovery_client_doc_target = BuildEnv['TOP'] + '/discovery/client/'
discovery_client_doc_files += BuildEnv.SandeshGenDoc('#controller/src/discovery/client/discovery_client_stats.sandesh', discovery_client_doc_target)
discovery_client_doc_files += BuildEnv.SandeshGenDoc('#controller/src/discovery/client/discovery_client.sandesh', discovery_client_doc_target)
discovery_client_doc_files += BuildEnv.SandeshGenDoc('#controller/src/discovery/discovery_introspect.sandesh', discovery_client_doc_target)
BuildEnv['DISCOVERY_CLIENT_DOC_FILES'] = discovery_client_doc_files

Expand Down
8 changes: 3 additions & 5 deletions src/analytics/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ def MapBuildDir(list):
return map(lambda x: '#/' + Dir('.').path + '/../' + x, list)

AnalyticsEnv.Prepend(LIBS=['cpuinfo',
'ds',
'io',
'vncapi',
'sandesh',
'httpc',
'http',
'vncapi',
'http_parser',
'curl',
'ruleparser',
Expand Down Expand Up @@ -78,7 +77,6 @@ if sys.platform != 'darwin':

libs = MapBuildDir(['sandesh',
'analytics/ruleparser',
'discovery/client',
'http/client',
'xml',
'database',
Expand All @@ -87,7 +85,8 @@ libs = MapBuildDir(['sandesh',
'net'])
AnalyticsEnv.Append(LIBPATH=libs)

includes = MapBuildDir(['http/client', 'discovery/client', 'analytics'])
includes = MapBuildDir(['http/client', 'analytics'])

AnalyticsEnv.Append(CPPPATH = [
includes,
AnalyticsEnv['TOP'],
Expand Down Expand Up @@ -241,7 +240,6 @@ CollectorDocFiles = []
CollectorDocFiles += AnalyticsEnv['BASE_DOC_FILES']
CollectorDocFiles += AnalyticsEnv['IO_DOC_FILES']
CollectorDocFiles += AnalyticsEnv['SANDESH_DOC_FILES']
CollectorDocFiles += AnalyticsEnv['DISCOVERY_CLIENT_DOC_FILES']
CollectorDocFiles += AnalyticsEnv['ANALYTICS_DOC_FILES']
CollectorDocFiles += AnalyticsEnv.SandeshGenDoc('collector_uve.sandesh')
CollectorDocFiles += AnalyticsEnv.SandeshGenDoc('uflow.sandesh')
Expand Down
30 changes: 0 additions & 30 deletions src/analytics/collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <sandesh/sandesh_connection.h>
#include <sandesh/sandesh_state_machine.h>
#include <sandesh/sandesh_message_builder.h>
#include <discovery/client/discovery_client.h>
#include <discovery_client_stats_types.h>
#include "collector.h"
#include "viz_collector.h"
#include "viz_sandesh.h"
Expand All @@ -48,7 +46,6 @@ using process::ConnectionStatus;

std::string Collector::prog_name_;
std::string Collector::self_ip_;
DiscoveryServiceClient *Collector::ds_client_;

bool Collector::task_policy_set_ = false;
const std::string Collector::kDbTask = "analytics::DbHandler";
Expand Down Expand Up @@ -602,33 +599,6 @@ void SmQueueParamsStatus::HandleRequest() const {
SendQueueParamsResponse(Collector::QueueType::Sm, collector, context());
}

void DiscoveryClientSubscriberStatsReq::HandleRequest() const {

DiscoveryClientSubscriberStatsResponse *resp =
new DiscoveryClientSubscriberStatsResponse();
resp->set_context(context());

resp->set_more(false);
resp->Response();
}

void DiscoveryClientPublisherStatsReq::HandleRequest() const {

DiscoveryClientPublisherStatsResponse *resp =
new DiscoveryClientPublisherStatsResponse();
resp->set_context(context());

std::vector<DiscoveryClientPublisherStats> stats_list;
DiscoveryServiceClient *ds = Collector::GetCollectorDiscoveryServiceClient();
if (ds) {
ds->FillDiscoveryServicePublisherStats(stats_list);
}

resp->set_publisher(stats_list);
resp->set_more(false);
resp->Response();
}

static void SendFlowCollectionStatusResponse(std::string context) {
FlowCollectionStatusResponse *fcsr(new FlowCollectionStatusResponse);
fcsr->set_disable(Sandesh::IsFlowCollectionDisabled());
Expand Down
10 changes: 0 additions & 10 deletions src/analytics/collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ class Collector : public SandeshServer {
const CollectorStats &GetStats() const { return stats_; }
void SendGeneratorStatistics();

static void SetDiscoveryServiceClient(DiscoveryServiceClient *ds) {
ds_client_ = ds;
}

static DiscoveryServiceClient *GetCollectorDiscoveryServiceClient() {
return ds_client_;
}

std::string DbGlobalName(bool dup=false);
protected:
virtual SslSession *AllocSession(SslSocket *socket);
Expand Down Expand Up @@ -176,8 +168,6 @@ class Collector : public SandeshServer {
static const std::vector<Sandesh::QueueWaterMarkInfo> kDbQueueWaterMarkInfo;
static const std::vector<Sandesh::QueueWaterMarkInfo> kSmQueueWaterMarkInfo;

static DiscoveryServiceClient *ds_client_;

DISALLOW_COPY_AND_ASSIGN(Collector);
};

Expand Down
10 changes: 4 additions & 6 deletions src/analytics/configdb_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ boost::shared_ptr<VncApi> ConfigDBConnection::GetVnc() {
return vnc_;
}

void
ConfigDBConnection::Update(Options *o, DiscoveryServiceClient *c) {
c->Subscribe(g_vns_constants.API_SERVER_DISCOVERY_SERVICE_NAME,
0, boost::bind(&ConfigDBConnection::APIfromDisc, this, o, _1));
}

#if SUNDAR_TOFIX_PARSING_APISERVER_FROM_CONFIG
void
ConfigDBConnection::APIfromDisc(Options *o, std::vector<DSResponse> response) {
tbb::mutex::scoped_lock lock(mutex_);
Expand All @@ -63,10 +58,12 @@ ConfigDBConnection::APIfromDisc(Options *o, std::vector<DSResponse> response) {
api_svr_list_ = response;
}
}
#endif

void
ConfigDBConnection::RetryNextApi() {
tbb::mutex::scoped_lock lock(mutex_);
#if SUNDAR_TOFIX_PARSING_APISERVER_FROM_CONFIG
if (!api_svr_list_.empty()) {
DSResponse api = api_svr_list_.back();
api_svr_list_.pop_back();
Expand All @@ -75,4 +72,5 @@ ConfigDBConnection::RetryNextApi() {
vnccfg_.cfg_srv_port = api.ep.port();
InitVnc(evm_, &vnccfg_);
}
#endif
}
5 changes: 0 additions & 5 deletions src/analytics/configdb_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,23 @@
#include <tbb/atomic.h>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
#include "discovery/client/discovery_client.h"
#include "http/client/vncapi.h"
#include "parser_util.h"

class Options;
//class DiscoveryServiceClient;

class ConfigDBConnection {
public:
ConfigDBConnection(EventManager *evm, VncApiConfig *vnccfg);
~ConfigDBConnection();
void Update(Options *o, DiscoveryServiceClient *c);
boost::shared_ptr<VncApi> GetVnc();
void RetryNextApi();

private:
void InitVnc(EventManager *evm, VncApiConfig *vnccfg);
void APIfromDisc(Options *o, std::vector<DSResponse> response);
boost::shared_ptr<VncApi> vnc_;
EventManager *evm_;
VncApiConfig vnccfg_;
std::vector<DSResponse> api_svr_list_;
mutable tbb::mutex mutex_;
};

Expand Down
1 change: 0 additions & 1 deletion src/analytics/contrail-broadview/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ stevedore
../tools/sandesh/library/python/dist/sandesh-0.1dev.tar.gz
../config/common/dist/cfgm_common-0.1dev.tar.gz
../api-lib/dist/vnc_api-0.1dev.tar.gz
../discovery/client/dist/discoveryclient-0.1dev.tar.gz
../config/common/dist/cfgm_common-0.1dev.tar.gz
8 changes: 0 additions & 8 deletions src/analytics/contrail-collector.conf
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ log_local=1
#high_watermark2.message_severity_level=SYS_DEBUG
#low_watermark2.message_severity_level=INVALID

[DISCOVERY]
# Port to connect to for communicating with discovery server
# port=5998
# server=127.0.0.1

# IP address of discovery server
# server=127.0.0.1

[REDIS]
# Port to connect to for communicating with redis-server
# port=6379
Expand Down
4 changes: 1 addition & 3 deletions src/analytics/contrail-snmp-collector/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ usage: contrail-snmp-collector [-h] [-c FILE]
[--syslog_facility SYSLOG_FACILITY]
[--scan_frequency SCAN_FREQUENCY]
[--http_server_port HTTP_SERVER_PORT]
(--file FILE | --api_serever API_SEREVER | --discovery_serever DISCOVERY_SEREVER)
(--file FILE | --api_serever API_SEREVER )

optional arguments:
-h, --help show this help message and exit
Expand All @@ -49,8 +49,6 @@ optional arguments:
--file FILE where to look for snmp credentials
--api_serever API_SEREVER
ip:port of api-server for snmp credentials
--discovery_serever DISCOVERY_SEREVER
ip:port of dicovery to get api-sever snmp credentials


Device File
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
[DEFAULTS]
#api_server=127.0.0.1:8082

#collectors=127.0.0.1:8086

#collectors=ip1:8086 ip2:8086
#fast_scan_frequency=60

#http_server_port=5920

log_local=1
log_level=SYS_NOTICE
log_file=/var/log/contrail/contrail-snmp-collector.log

#scan_frequency=600

#zookeeper=127.0.0.1:2181

[DISCOVERY]
#disc_server_ip=127.0.0.1
#disc_server_port=5998

[KEYSTONE]
#keystone parameters come from contrail-keystone-auth.conf
#auth_host=127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
from pysandesh.sandesh_base import *
from pysandesh.gen_py.sandesh.ttypes import SandeshLevel
from device_config import DeviceConfig
import discoveryclient.client as client
from sandesh_common.vns.ttypes import Module
from sandesh_common.vns.constants import ModuleNames, \
API_SERVER_DISCOVERY_SERVICE_NAME, HttpPortSnmpCollector, \
HttpPortSnmpCollector, \
ServicesDefaultConfigurationFiles, SERVICE_SNMP_COLLECTOR

class CfgParser(object):
Expand All @@ -20,7 +19,6 @@ def __init__(self, argv):
self.__pat = None
self._argv = argv or ' '.join(sys.argv[1:])
self._name = ModuleNames[Module.CONTRAIL_SNMP_COLLECTOR]
self._disc = None
self._cb = None

def set_cb(self, cb=None):
Expand All @@ -35,8 +33,6 @@ def parse(self):
--log_file <stdout>
--use_syslog
--syslog_facility LOG_USER
--disc_server_ip 127.0.0.1
--disc_server_port 5998
--conf_file /etc/contrail/contrail-snmp-scanner.conf
conf file example:
Expand Down Expand Up @@ -101,10 +97,6 @@ def parse(self):
'admin_password': 'password1',
'admin_tenant_name': 'default-domain'
}
disc_opts = {
'disc_server_ip' : '127.0.0.1',
'disc_server_port' : 5998,
}
sandesh_opts = {
'sandesh_keyfile': '/etc/contrail/ssl/private/server-privkey.pem',
'sandesh_certfile': '/etc/contrail/ssl/certs/server.pem',
Expand All @@ -122,8 +114,6 @@ def parse(self):
defaults.update(dict(config.items("DEFAULTS")))
if 'KEYSTONE' in config.sections():
ksopts.update(dict(config.items("KEYSTONE")))
if 'DISCOVERY' in config.sections():
disc_opts.update(dict(config.items('DISCOVERY')))
if 'SANDESH' in config.sections():
sandesh_opts.update(dict(config.items('SANDESH')))
if 'sandesh_ssl_enable' in config.options('SANDESH'):
Expand All @@ -143,7 +133,6 @@ def parse(self):
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
defaults.update(ksopts)
defaults.update(disc_opts)
defaults.update(sandesh_opts)
parser.set_defaults(**defaults)
parser.add_argument("--collectors",
Expand Down Expand Up @@ -187,10 +176,6 @@ def parse(self):
help="ip:port of zookeeper server")
parser.add_argument("--cluster_id",
help="Used for database keyspace separation")
parser.add_argument("--disc_server_ip",
help="Discovery Server IP address")
parser.add_argument("--disc_server_port", type=int,
help="Discovery Server port")
parser.add_argument("--sandesh_keyfile",
help="Sandesh ssl private key")
parser.add_argument("--sandesh_certfile",
Expand All @@ -213,7 +198,6 @@ def parse(self):
self._args.collectors = self._args.collectors.split()
self._args.config_sections = config
self._args.conf_file = args.conf_file
self._disc = client.DiscoveryClient(*self.discovery_params())

def devices(self):
if self._args.device_config_file:
Expand All @@ -226,38 +210,9 @@ def devices(self):
self._args.admin_tenant_name,
self._args.auth_host, self._args.auth_port,
self._args.auth_protocol, self._cb)
elif self._args.disc_server_port:
apis = self.get_api_svrs()
if apis:
self._devices = DeviceConfig.fom_api_server(
self.get_api_svrs(), self._args.admin_user,
self._args.admin_password, self._args.admin_tenant_name,
self._args.auth_host, self._args.auth_port,
self._args.auth_protocol, self._cb)
else:
self._devices = []
#TODO SUNDAR_TO_ADD_API_SERVERS_LIST
return self._devices

def get_api_svrs(self):
if self._disc is None:
p = self.discovery_params()
try:
self._disc = client.DiscoveryClient(*p)
except Exception as e:
import traceback; traceback.print_exc()
return []
a = self._disc.subscribe(API_SERVER_DISCOVERY_SERVICE_NAME, 0)
x = a.read()
return map(lambda d:d['ip-address'] + ':' + d['port'], x)

def discovery_params(self):
if self._args.disc_server_ip:
ip, port = self._args.disc_server_ip, \
self._args.disc_server_port
else:
ip, port = '127.0.0.1', self._args.disc_server_port
return ip, port, self._name

def collectors(self):
return self._args.collectors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __init__(self, conf, instance='0'):
self._node_type_name,
self._conf.http_port(),
['contrail_snmp_collector.sandesh'],
self._conf._disc,
config=self._conf.sandesh_config())
sandesh_global.set_logging_params(
enable_local_log=self._conf.log_local(),
Expand All @@ -66,7 +65,6 @@ def __init__(self, conf, instance='0'):
def map_svc(self, svc):
return {
'api' : ConnectionType.APISERVER,
'discovery' : ConnectionType.DISCOVERY,
'zookeeper' : ConnectionType.ZOOKEEPER,
}[svc]

Expand All @@ -84,8 +82,6 @@ def conn_state_notify(self, svc, msg='', up=True, servers=''):

def killall(self):
sandesh_global.uninit()
if self._conf._disc:
self._conf._disc.uninit()

def delete(self, dev):
PRouterUVE(data=PRouterEntry(**dict(
Expand Down

0 comments on commit 89170cc

Please sign in to comment.