mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
DataDB default name to 10, dbsmerge small corrections
This commit is contained in:
@@ -87,7 +87,7 @@ const CGRATES_CFG_JSON = `
|
||||
"db_type": "redis", // data_db type: <redis|mongo>
|
||||
"db_host": "127.0.0.1", // data_db host address
|
||||
"db_port": 6379, // data_db port to reach the database
|
||||
"db_name": "11", // data_db database name to connect to
|
||||
"db_name": "10", // data_db database name to connect to
|
||||
"db_user": "", // username to use when connecting to data_db
|
||||
"db_password": "", // password to use when connecting to data_db
|
||||
"load_history_size": 10, // Number of records in the load history
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestDfDbJsonCfg(t *testing.T) {
|
||||
Db_type: utils.StringPointer("redis"),
|
||||
Db_host: utils.StringPointer("127.0.0.1"),
|
||||
Db_port: utils.IntPointer(6379),
|
||||
Db_name: utils.StringPointer("11"),
|
||||
Db_name: utils.StringPointer("10"),
|
||||
Db_user: utils.StringPointer(""),
|
||||
Db_password: utils.StringPointer(""),
|
||||
Load_history_size: utils.IntPointer(10),
|
||||
|
||||
@@ -217,7 +217,7 @@ func TestCgrCfgJSONDefaultsjsnDataDb(t *testing.T) {
|
||||
if cgrCfg.DataDbPort != "6379" {
|
||||
t.Error(cgrCfg.DataDbPort)
|
||||
}
|
||||
if cgrCfg.DataDbName != "11" {
|
||||
if cgrCfg.DataDbName != "10" {
|
||||
t.Error(cgrCfg.DataDbName)
|
||||
}
|
||||
if cgrCfg.DataDbUser != "" {
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
// "db_type": "redis", // data_db type: <redis|mongo>
|
||||
// "db_host": "127.0.0.1", // data_db host address
|
||||
// "db_port": 6379, // data_db port to reach the database
|
||||
// "db_name": "11", // data_db database name to connect to
|
||||
// "db_name": "10", // data_db database name to connect to
|
||||
// "db_user": "", // username to use when connecting to data_db
|
||||
// "db_password": "", // password to use when connecting to data_db
|
||||
// "load_history_size": 10, // Number of records in the load history
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# depends:
|
||||
# ^ pymongo
|
||||
# asserts:
|
||||
# ^ destination mongo database exists and the destination user can auth on it
|
||||
# ^ pymongo # install via: easy_install pymongo
|
||||
# behaviour:
|
||||
# ^ the script will "move" the collections if source and target server are the same
|
||||
# but will "copy" (dump/restore) if source and target servers are different
|
||||
|
||||
from_host = '127.0.0.1'
|
||||
from_port = '27017'
|
||||
from_db = 'cgrates2'
|
||||
from_db = '11'
|
||||
from_user = 'cgrates'
|
||||
from_pass = 'CGRateS.org'
|
||||
from_pass = ''
|
||||
|
||||
to_host = '127.0.0.1'
|
||||
to_port = '27017'
|
||||
to_db = 'cgrates2'
|
||||
to_db = '10'
|
||||
to_user = 'cgrates'
|
||||
to_pass = 'CGRateS.org'
|
||||
to_pass = ''
|
||||
|
||||
dump_folder = 'dump'
|
||||
|
||||
@@ -27,6 +25,8 @@ from urllib import quote_plus
|
||||
from collections import OrderedDict
|
||||
|
||||
mongo_from_url = 'mongodb://' + from_user + ':' + quote_plus(from_pass) + '@'+ from_host + ':' + from_port + '/' + from_db
|
||||
if from_pass == '': # disabled auth
|
||||
mongo_from_url = 'mongodb://' + from_host + ':' + from_port + '/' + from_db
|
||||
client = MongoClient(mongo_from_url)
|
||||
|
||||
db = client[from_db]
|
||||
@@ -39,10 +39,13 @@ if len(cols) > 0:
|
||||
print('Migrating on same server...')
|
||||
print('Found %d collections on source. Moving...' % len(cols))
|
||||
i = 0
|
||||
for col in db.collection_names():
|
||||
for col in cols:
|
||||
i += 1
|
||||
print('Moving colection %s (%d of %d)...' % (col, i, len(cols)))
|
||||
client.admin.command(OrderedDict([('renameCollection', from_db + '.' + col), ('to', to_db + '.' + col)]))
|
||||
try:
|
||||
client.admin.command(OrderedDict([('renameCollection', from_db + '.' + col), ('to', to_db + '.' + col)]))
|
||||
except:
|
||||
continue
|
||||
# different servers
|
||||
else:
|
||||
import subprocess
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# depends:
|
||||
# ^ redis
|
||||
# ^ redis # install via easy_install redis
|
||||
# asserts:
|
||||
# ^ destination redis is not password protected when connected from source redis server
|
||||
# (https://github.com/antirez/redis/pull/2507)
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
from_host = '127.0.0.1'
|
||||
from_port = 6379
|
||||
from_db = 0
|
||||
from_db = 11
|
||||
from_pass = ''
|
||||
|
||||
to_host = '127.0.0.1'
|
||||
to_port = 6380
|
||||
to_db = 0
|
||||
to_port = 6379
|
||||
to_db = 10
|
||||
to_pass = '' # Not used
|
||||
|
||||
keymask = '*'
|
||||
|
||||
Reference in New Issue
Block a user