Merge "Support dynamic mysql port via config file"
This commit is contained in:
commit
9983c5afbc
|
@ -28,6 +28,15 @@ class MysqlRepo(BaseRepo):
|
|||
else:
|
||||
self._mysql_ssl = None
|
||||
|
||||
if 'port' in config['mysql']:
|
||||
self._mysql_port = config['mysql']['port']
|
||||
else:
|
||||
#
|
||||
# If port isn't specified in the config file,
|
||||
# set it to the default value.
|
||||
#
|
||||
self._mysql_port = 3306
|
||||
|
||||
self._mysql_host = config['mysql']['host']
|
||||
self._mysql_user = config['mysql']['user']
|
||||
self._mysql_passwd = config['mysql']['passwd']
|
||||
|
@ -38,6 +47,7 @@ class MysqlRepo(BaseRepo):
|
|||
self._mysql = None
|
||||
try:
|
||||
self._mysql = pymysql.connect(host=self._mysql_host,
|
||||
port=self._mysql_port,
|
||||
user=self._mysql_user,
|
||||
passwd=unicode(self._mysql_passwd).encode('utf-8'),
|
||||
db=self._mysql_dbname,
|
||||
|
|
|
@ -15,6 +15,7 @@ database:
|
|||
|
||||
mysql:
|
||||
host: 192.168.10.4
|
||||
port: 3306
|
||||
user: notification
|
||||
passwd: password
|
||||
db: mon
|
||||
|
|
|
@ -57,6 +57,7 @@ class TestAlarmProcessor(unittest.TestCase):
|
|||
|
||||
mysql_config = {'mysql': {'ssl': None,
|
||||
'host': 'mysql_host',
|
||||
'port': 'mysql_port',
|
||||
'user': 'mysql_user',
|
||||
'db': 'dbname',
|
||||
'passwd': 'mysql_passwd'}}
|
||||
|
|
|
@ -33,6 +33,7 @@ class TestMySqlRepo(unittest.TestCase):
|
|||
mock_mysql.Error = pymysql.Error
|
||||
|
||||
config = {'mysql': {'host': 'foo',
|
||||
'port': '3306',
|
||||
'user': 'bar',
|
||||
'passwd': '1',
|
||||
'db': '2'}}
|
||||
|
|
Loading…
Reference in New Issue