|
@@ -65,6 +65,7 @@ def init_all_dbs():
|
65
|
65
|
import loader
|
66
|
66
|
loader.start()
|
67
|
67
|
import leapi_dyncode as dyncode
|
|
68
|
+ from lodel.plugin.datasource_plugin import DatasourcePlugin
|
68
|
69
|
from lodel.settings.utils import SettingsError
|
69
|
70
|
from lodel.leapi.leobject import LeObject
|
70
|
71
|
from lodel.plugin import Plugin
|
|
@@ -78,36 +79,11 @@ def init_all_dbs():
|
78
|
79
|
else:
|
79
|
80
|
ds_cls[ds].append(cls)
|
80
|
81
|
|
81
|
|
- for ds_name in ds_cls:
|
82
|
|
- # Fetching datasource plugin name and datasource connection
|
83
|
|
- # identifier
|
84
|
|
- try:
|
85
|
|
- plugin_name, ds_identifier = LeObject._get_ds_plugin_name(
|
86
|
|
- ds_name, False)
|
87
|
|
- except (NameError, ValueError, RuntimeError):
|
88
|
|
- raise SettingsError("Datasource configuration error")
|
89
|
|
- # Fetching datasource connection option
|
90
|
|
- con_conf=LeObject._get_ds_connection_conf(ds_identifier, plugin_name)
|
91
|
|
- # Fetching migration handler class from plugin
|
92
|
|
- plugin_module = Plugin.get(plugin_name).loader_module()
|
93
|
|
- try:
|
94
|
|
- mh_cls = plugin_module.migration_handler_class()
|
95
|
|
- except NameError as e:
|
96
|
|
- raise RuntimeError("Malformed plugin '%s'. Missing \
|
97
|
|
-migration_handler_class() function in loader file" % ds_name)
|
98
|
|
- #Instanciate the migrationhandler and start db initialisation
|
99
|
|
- if con_conf['read_only'] is True:
|
100
|
|
- raise SettingsError("Trying to instanciate a migration handler \
|
101
|
|
-with a read only datasource")
|
102
|
|
- try:
|
103
|
|
- if 'read_only' in con_conf:
|
104
|
|
- del(con_conf['read_only'])
|
105
|
|
- mh = mh_cls(**con_conf)
|
106
|
|
- except Exception as e:
|
107
|
|
- msg = "Migration failed for datasource %s(%s.%s) at migration \
|
108
|
|
-handler instanciation : %s"
|
109
|
|
- msg %= (ds_name, plugin_name, ds_identifier, e)
|
110
|
|
- raise RuntimeError(msg)
|
|
82
|
+ for ds_name in ds_cls:
|
|
83
|
+ mh = DatasourcePlugin.init_migration_handler(ds_name)
|
|
84
|
+ #Retrieve plugin_name & ds_identifier for logging purpose
|
|
85
|
+ plugin_name, ds_identifier = DatasourcePlugin.plugin_name(
|
|
86
|
+ ds_name, False)
|
111
|
87
|
try:
|
112
|
88
|
mh.init_db(ds_cls[ds_name])
|
113
|
89
|
except Exception as e:
|