Skip to content

Commit

Permalink
Using cassandra authentication in discovery
Browse files Browse the repository at this point in the history
Cassandra authentication can be enabled by specifying username and password in
testbed.py. All the services accessing cassandra should use those credentials
Partial-Bug: 1551969

Change-Id: I662b90a1c68822de13c234d3a2500aad778f7518
  • Loading branch information
bansalnikhil committed May 1, 2016
1 parent 1280a2e commit b2ff13f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/discovery/disc_cassdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def get_db_info(cls):
return db_info
# end get_db_info

def __init__(self, module, cass_srv_list, config_log, reset_config=False, db_prefix=None):
def __init__(self, module, cass_srv_list, config_log, reset_config=False,
db_prefix=None, cass_credential=None):

self._debug = {
'db_upd_oper_state': 0,
'db_upd_admin_state': 0,
Expand All @@ -44,7 +46,7 @@ def __init__(self, module, cass_srv_list, config_log, reset_config=False, db_pre

super(DiscoveryCassandraClient, self).__init__(
cass_srv_list, db_prefix, keyspaces, None,
config_log, reset_config=reset_config)
config_log, reset_config=reset_config, credential=cass_credential)

DiscoveryCassandraClient._disco_cf = self._cf_dict[self._DISCOVERY_CF_NAME]
#end __init__
Expand Down
7 changes: 6 additions & 1 deletion src/discovery/disc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,14 @@ def get_service_config(self, service_type, item):
# end

def _db_connect(self, reset_config):
cred = None
if 'cassandra' in self.cassandra_config.keys():
cred = {'username':self.cassandra_config['cassandra']\
['cassandra_user'],'password':self.cassandra_config\
['cassandra']['cassandra_password']}
self._db_conn = DiscoveryCassandraClient("discovery",
self._args.cassandra_server_list, self.config_log, reset_config,
self._args.cluster_id)
self._args.cluster_id, cred)
# end _db_connect

def cleanup(self):
Expand Down

0 comments on commit b2ff13f

Please sign in to comment.