|
@@ -100,42 +100,52 @@ def set_conf(name, args):
|
100
|
100
|
Selected interface is not the web iterface")
|
101
|
101
|
if 'lodel.webui' in config:
|
102
|
102
|
del(config['lodel2.webui'])
|
103
|
|
- #Now config should be OK to be written again in conffile
|
104
|
|
- with open(conffile, 'w+') as cfp:
|
105
|
|
- config.write(cfp)
|
106
|
|
-
|
107
|
103
|
|
108
|
104
|
if args.datasource_connectors is not None:
|
109
|
105
|
darg = args.datasource_connectors
|
|
106
|
+ if darg not in ('dummy', 'mongodb'):
|
|
107
|
+ raise ValueError("Allowed connectors are : 'dummy' and 'mongodb'")
|
110
|
108
|
if darg not in ('mongodb',):
|
111
|
109
|
raise TypeError("Datasource_connectors can only be of : 'mongodb'")
|
112
|
110
|
if darg.lower() == 'mongodb':
|
113
|
|
- darg = 'mongodb_datasource dummy_datasource'
|
|
111
|
+ dconf = 'mongodb_datasource'
|
|
112
|
+ toadd = 'mongodb_datasource'
|
|
113
|
+ todel = 'dummy_datasource'
|
114
|
114
|
else:
|
115
|
|
- darg = 'dummy_datasource'
|
116
|
|
- config['lodel2']['datasource_connectors'] = darg
|
117
|
|
- datasource_connectors = config['lodel2']['datasource_connectors']
|
118
|
|
- if datasource_connectors == 'mongodb_datasource':
|
119
|
|
- if (('lodle2.datasources.default' not in config) or ('lodel2.datasources.dummy2' not in config)):
|
120
|
|
- config['lodel2.datasources.default'] = dict()
|
121
|
|
- config['lodel2.datasources.default']['identifier'] = 'mongodb_datasource.default'
|
122
|
|
- config['lodel2.datasources.dummy2'] = dict()
|
123
|
|
- config['lodel2.datasources.dummy2']['identifier'] = 'mongodb_datasource.default'
|
124
|
|
- if 'lodel2.datasource.mongodb_datasource.default' not in config:
|
125
|
|
- config['lodel2.datasource.mongodb_datasource.default'] = dict()
|
126
|
|
- if args.host is not None:
|
127
|
|
- config['lodel2.datasource.mongodb_datasource.default']['host'] = str(args.host)
|
128
|
|
- if args.user is not None:
|
129
|
|
- config['lodel2.datasource.mongodb_datasource.default']['username'] = str(args.user)
|
130
|
|
- if args.password is not None:
|
131
|
|
- config['lodel2.datasource.mongodb_datasource.default']['password'] = str(args.password)
|
132
|
|
- if args.db_name is not None:
|
133
|
|
- config['lodel2.datasource.mongodb_datasource.default']['db_name'] = str(args.db_name)
|
134
|
|
- #if 'lodel2.datasource.mongodb_datasource.default' in config:
|
135
|
|
- # del(config['lodel2.datasource.mongodb_datasource.default'])
|
|
115
|
+ dconf = 'dummy_datasource'
|
|
116
|
+ todel = 'mongodb_datasource'
|
|
117
|
+ toadd = 'dummy_datasource'
|
|
118
|
+ config['lodel2']['datasource_connectors'] = dconf
|
|
119
|
+ #Delete old default & dummy2 conn
|
|
120
|
+ kdel = 'lodel2.datasource.%s.%s' % (todel, 'default')
|
|
121
|
+ if kdel in config:
|
|
122
|
+ del(config[kdel])
|
|
123
|
+ #Add the new default & dummy2 conn
|
|
124
|
+ kadd = 'lodel2.datasource.%s.%s' % (toadd, 'default')
|
|
125
|
+ if kadd not in config:
|
|
126
|
+ config[kadd] = dict()
|
|
127
|
+ #Bind to current conn
|
|
128
|
+ for dsn in ('default', 'dummy2'):
|
|
129
|
+ config['lodel2.datasources.%s' %dsn ]= {
|
|
130
|
+ 'identifier':'%s.default' % toadd}
|
|
131
|
+ #Set the conf for mongodb
|
|
132
|
+ if darg == 'mongodb':
|
|
133
|
+ dbconfname = 'lodel2.datasource.mongodb_datasource.default'
|
|
134
|
+ if args.host is not None:
|
|
135
|
+ config[dbconfname]['host'] = str(args.host)
|
|
136
|
+ if args.user is not None:
|
|
137
|
+ config[dbconfname]['username'] = str(args.user)
|
|
138
|
+ if args.password is not None:
|
|
139
|
+ config[dbconfname]['password'] = str(args.password)
|
|
140
|
+ if args.db_name is not None:
|
|
141
|
+ config[dbconfname]['db_name'] = str(args.db_name)
|
|
142
|
+ else:
|
|
143
|
+ config['lodel2.datasource.dummy_datasource.default'] = {'dummy':''}
|
|
144
|
+ #Now config should be OK to be written again in conffile
|
136
|
145
|
with open(conffile, 'w+') as cfp:
|
137
|
146
|
config.write(cfp)
|
138
|
147
|
|
|
148
|
+
|
139
|
149
|
|
140
|
150
|
|
141
|
151
|
##@brief If the name is not valid raise
|