Pārlūkot izejas kodu

Various bugfix on mass_deploy and slim about mongodb connections

Yann Weber 8 gadus atpakaļ
vecāks
revīzija
2bfba3be30

+ 1
- 1
plugins/dummy_datasource/datasource.py Parādīt failu

@@ -26,7 +26,7 @@ class DummyDatasource(AbstractDatasource):
26 26
     #@param offset int: used with limit to choose the start record
27 27
     #@param instanciate bool : If true, the records are returned as instances, else they are returned as dict
28 28
     #@return list
29
-    def select(self, target, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0,
29
+    def select(self, target, field_list, filters, relational_filters=None, order=None, group=None, limit=None, offset=0,
30 30
                instanciate=True):
31 31
         pass
32 32
 

+ 2
- 2
progs/mass_deploy.sh Parādīt failu

@@ -117,11 +117,11 @@ do
117 117
 
118 118
 	#Mongo db database creation
119 119
 	dbname="${MONGODB_DB_PREFIX}_$iname"
120
-	dbuser="lodel2_$i"
120
+	dbuser="lodel2_$iname"
121 121
 	dbpass=$($rnd_pass_cmd)
122 122
 	mongo $MONGODB_HOST -u "$MONGODB_ADMIN_USER" -p "$MONGODB_ADMIN_PASSWORD" admin <<EOF
123 123
 use $dbname
124
-db.addUser('$dbname', '$dbpass', ['readWrite', '$dbname'])
124
+db.addUser('$dbuser', '$dbpass', ['readWrite', '$dbname'])
125 125
 exit
126 126
 EOF
127 127
 	#Append created db to instance conf

+ 3
- 5
progs/slim/install_model/conf.d/lodel2.ini Parādīt failu

@@ -11,14 +11,12 @@ emfile = editorial_model.pickle
11 11
 dyncode = leapi_dyncode.py
12 12
 
13 13
 [lodel2.datasources.default]
14
-identifier = dummy_datasource.example
14
+identifier = dummy_datasource.default
15 15
 
16 16
 [lodel2.datasources.dummy2]
17
-identifier = dummy_datasource.dummy2
17
+identifier = dummy_datasource.default
18 18
 
19
-[lodel2.datasource.dummy_datasource.example]
20
-dummy =
21
-[lodel2.datasource.dummy_datasource.dummy2]
19
+[lodel2.datasource.dummy_datasource.default]
22 20
 dummy =
23 21
 
24 22
 [lodel2.logging.stderr]

+ 36
- 26
progs/slim/slim.py Parādīt failu

@@ -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

Notiek ielāde…
Atcelt
Saglabāt