author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 10 Jun 2009 12:09:06 +0200 | |
branch | stable |
changeset 2087 | 88fa02f50e71 |
parent 1980 | 35394365b6c1 |
child 2105 | 92ea410806fe |
permissions | -rw-r--r-- |
0 | 1 |
"""cubicweb-ctl commands and command handlers specific to the server.serverconfig |
2 |
||
3 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1912
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1912
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
9 |
||
1912
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
10 |
import sys |
0 | 11 |
import os |
12 |
||
13 |
from logilab.common.configuration import REQUIRED, Configuration, ini_format_section |
|
1132 | 14 |
from logilab.common.clcommands import register_commands, cmd_run, pop_arg |
0 | 15 |
|
16 |
from cubicweb import AuthenticationError, ExecutionError, ConfigurationError |
|
1132 | 17 |
from cubicweb.toolsutils import (Command, CommandHandler, confirm, |
18 |
restrict_perms_to_user) |
|
0 | 19 |
from cubicweb.server.serverconfig import ServerConfiguration |
20 |
||
21 |
||
22 |
# utility functions ########################################################### |
|
23 |
||
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
24 |
def source_cnx(source, dbname=None, special_privs=False, verbose=True): |
0 | 25 |
"""open and return a connection to the system database defined in the |
26 |
given server.serverconfig |
|
27 |
""" |
|
28 |
from getpass import getpass |
|
29 |
from logilab.common.db import get_connection |
|
30 |
dbhost = source['db-host'] |
|
31 |
if dbname is None: |
|
32 |
dbname = source['db-name'] |
|
33 |
driver = source['db-driver'] |
|
34 |
print '**** connecting to %s database %s@%s' % (driver, dbname, dbhost), |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
35 |
if not verbose or (not special_privs and source.get('db-user')): |
0 | 36 |
user = source['db-user'] |
37 |
print 'as', user |
|
38 |
if source.get('db-password'): |
|
39 |
password = source['db-password'] |
|
40 |
else: |
|
41 |
password = getpass('password: ') |
|
42 |
else: |
|
43 |
print |
|
44 |
if special_privs: |
|
45 |
print 'WARNING' |
|
46 |
print 'the user will need the following special access rights on the database:' |
|
47 |
print special_privs |
|
48 |
print |
|
49 |
default_user = source.get('db-user', os.environ.get('USER', '')) |
|
50 |
user = raw_input('user (%r by default): ' % default_user) |
|
51 |
user = user or default_user |
|
52 |
if user == source.get('db-user') and source.get('db-password'): |
|
53 |
password = source['db-password'] |
|
54 |
else: |
|
55 |
password = getpass('password: ') |
|
56 |
return get_connection(driver, dbhost, dbname, user, password=password, |
|
57 |
port=source.get('db-port')) |
|
58 |
||
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
59 |
def system_source_cnx(source, dbms_system_base=False, |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
60 |
special_privs='CREATE/DROP DATABASE', verbose=True): |
0 | 61 |
"""shortcut to get a connextion to the application system database |
62 |
defined in the given config. If <dbms_system_base> is True, |
|
63 |
connect to the dbms system database instead (for task such as |
|
64 |
create/drop the application database) |
|
65 |
""" |
|
66 |
if dbms_system_base: |
|
67 |
from logilab.common.adbh import get_adv_func_helper |
|
68 |
system_db = get_adv_func_helper(source['db-driver']).system_database() |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
69 |
return source_cnx(source, system_db, special_privs=special_privs, verbose=verbose) |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
70 |
return source_cnx(source, special_privs=special_privs, verbose=verbose) |
0 | 71 |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
72 |
def _db_sys_cnx(source, what, db=None, user=None, verbose=True): |
0 | 73 |
"""return a connection on the RDMS system table (to create/drop a user |
74 |
or a database |
|
75 |
""" |
|
76 |
from logilab.common.adbh import get_adv_func_helper |
|
77 |
special_privs = '' |
|
78 |
driver = source['db-driver'] |
|
79 |
helper = get_adv_func_helper(driver) |
|
80 |
if user is not None and helper.users_support: |
|
81 |
special_privs += '%s USER' % what |
|
82 |
if db is not None: |
|
83 |
special_privs += ' %s DATABASE' % what |
|
84 |
# connect on the dbms system base to create our base |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
85 |
cnx = system_source_cnx(source, True, special_privs=special_privs, verbose=verbose) |
0 | 86 |
# disable autocommit (isolation_level(1)) because DROP and |
87 |
# CREATE DATABASE can't be executed in a transaction |
|
88 |
try: |
|
89 |
cnx.set_isolation_level(0) |
|
90 |
except AttributeError: |
|
91 |
# set_isolation_level() is psycopg specific |
|
92 |
pass |
|
93 |
return cnx |
|
1469 | 94 |
|
0 | 95 |
def generate_sources_file(sourcesfile, sourcescfg, keys=None): |
96 |
"""serialize repository'sources configuration into a INI like file |
|
97 |
||
98 |
the `keys` parameter may be used to sort sections |
|
99 |
""" |
|
100 |
from cubicweb.server.sources import SOURCE_TYPES |
|
101 |
if keys is None: |
|
102 |
keys = sourcescfg.keys() |
|
103 |
else: |
|
104 |
for key in sourcescfg: |
|
105 |
if not key in keys: |
|
106 |
keys.append(key) |
|
107 |
stream = open(sourcesfile, 'w') |
|
108 |
for uri in keys: |
|
109 |
sconfig = sourcescfg[uri] |
|
110 |
if isinstance(sconfig, dict): |
|
111 |
# get a Configuration object |
|
112 |
_sconfig = Configuration(options=SOURCE_TYPES[sconfig['adapter']].options) |
|
113 |
for attr, val in sconfig.items(): |
|
1469 | 114 |
if attr == 'uri': |
0 | 115 |
continue |
116 |
if attr == 'adapter': |
|
117 |
_sconfig.adapter = val |
|
118 |
else: |
|
119 |
_sconfig.set_option(attr, val) |
|
120 |
sconfig = _sconfig |
|
121 |
optsbysect = list(sconfig.options_by_section()) |
|
1980
35394365b6c1
nicer error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
122 |
assert len(optsbysect) == 1, 'all options for a source should be in the same group' |
0 | 123 |
ini_format_section(stream, uri, optsbysect[0][1]) |
124 |
if hasattr(sconfig, 'adapter'): |
|
125 |
print >> stream |
|
126 |
print >> stream, '# adapter for this source (YOU SHOULD NOT CHANGE THIS)' |
|
127 |
print >> stream, 'adapter=%s' % sconfig.adapter |
|
128 |
print >> stream |
|
129 |
||
130 |
def repo_cnx(config): |
|
131 |
"""return a in-memory repository and a db api connection it""" |
|
132 |
from cubicweb.dbapi import in_memory_cnx |
|
133 |
from cubicweb.server.utils import manager_userpasswd |
|
134 |
try: |
|
135 |
login = config.sources()['admin']['login'] |
|
136 |
pwd = config.sources()['admin']['password'] |
|
137 |
except KeyError: |
|
138 |
login, pwd = manager_userpasswd() |
|
139 |
while True: |
|
140 |
try: |
|
141 |
return in_memory_cnx(config, login, pwd) |
|
142 |
except AuthenticationError: |
|
143 |
print 'wrong user/password' |
|
1682
36bd5cba09de
must reset cubes before next authentication
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1469
diff
changeset
|
144 |
# reset cubes else we'll have an assertion error on next retry |
36bd5cba09de
must reset cubes before next authentication
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1469
diff
changeset
|
145 |
config._cubes = None |
0 | 146 |
login, pwd = manager_userpasswd() |
1469 | 147 |
|
0 | 148 |
# repository specific command handlers ######################################## |
149 |
||
150 |
class RepositoryCreateHandler(CommandHandler): |
|
151 |
cmdname = 'create' |
|
152 |
cfgname = 'repository' |
|
153 |
||
154 |
def bootstrap(self, cubes, inputlevel=0): |
|
155 |
"""create an application by copying files from the given cube and by |
|
156 |
asking information necessary to build required configuration files |
|
157 |
""" |
|
158 |
from cubicweb.server.sources import SOURCE_TYPES |
|
159 |
config = self.config |
|
160 |
print 'application\'s repository configuration' |
|
161 |
print '-' * 72 |
|
162 |
config.input_config('email', inputlevel) |
|
163 |
if config.pyro_enabled(): |
|
164 |
config.input_config('pyro-server', inputlevel) |
|
165 |
print |
|
166 |
print 'repository sources configuration' |
|
167 |
print '-' * 72 |
|
168 |
sourcesfile = config.sources_file() |
|
169 |
sconfig = Configuration(options=SOURCE_TYPES['native'].options) |
|
170 |
sconfig.adapter = 'native' |
|
171 |
sconfig.input_config(inputlevel=inputlevel) |
|
172 |
sourcescfg = {'system': sconfig} |
|
173 |
while raw_input('enter another source [y/N]: ').strip().lower() == 'y': |
|
174 |
sourcetype = raw_input('source type (%s): ' % ', '.join(SOURCE_TYPES.keys())) |
|
175 |
sconfig = Configuration(options=SOURCE_TYPES[sourcetype].options) |
|
176 |
sconfig.adapter = sourcetype |
|
177 |
sourceuri = raw_input('source uri: ').strip() |
|
178 |
assert not sourceuri in sourcescfg |
|
179 |
sconfig.input_config(inputlevel=inputlevel) |
|
180 |
sourcescfg[sourceuri] = sconfig |
|
181 |
# module names look like cubes.mycube.themodule |
|
182 |
sourcecube = SOURCE_TYPES[sourcetype].module.split('.', 2)[1] |
|
183 |
# if the source adapter is coming from an external component, ensure |
|
184 |
# it's specified in used cubes |
|
185 |
if sourcecube != 'cubicweb' and not sourcecube in cubes: |
|
186 |
cubes.append(sourcecube) |
|
187 |
sconfig = Configuration(options=USER_OPTIONS) |
|
188 |
sconfig.input_config(inputlevel=inputlevel) |
|
189 |
sourcescfg['admin'] = sconfig |
|
190 |
generate_sources_file(sourcesfile, sourcescfg, ['admin', 'system']) |
|
191 |
restrict_perms_to_user(sourcesfile) |
|
192 |
# remember selected cubes for later initialization of the database |
|
193 |
config.write_bootstrap_cubes_file(cubes) |
|
1469 | 194 |
|
0 | 195 |
def postcreate(self): |
196 |
if confirm('do you want to create repository\'s system database?'): |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
197 |
verbosity = (self.config.mode == 'installed') and 'y' or 'n' |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
198 |
cmd_run('db-create', self.config.appid, '--verbose=%s' % verbosity) |
0 | 199 |
else: |
200 |
print 'nevermind, you can do it later using the db-create command' |
|
1469 | 201 |
|
0 | 202 |
USER_OPTIONS = ( |
203 |
('login', {'type' : 'string', |
|
204 |
'default': REQUIRED, |
|
205 |
'help': "cubicweb manager account's login " |
|
206 |
'(this user will be created)', |
|
207 |
'inputlevel': 0, |
|
208 |
}), |
|
209 |
('password', {'type' : 'password', |
|
210 |
'help': "cubicweb manager account's password", |
|
211 |
'inputlevel': 0, |
|
212 |
}), |
|
213 |
) |
|
214 |
||
215 |
||
216 |
class RepositoryDeleteHandler(CommandHandler): |
|
217 |
cmdname = 'delete' |
|
218 |
cfgname = 'repository' |
|
219 |
||
220 |
def cleanup(self): |
|
221 |
"""remove application's configuration and database""" |
|
222 |
from logilab.common.adbh import get_adv_func_helper |
|
223 |
source = self.config.sources()['system'] |
|
224 |
dbname = source['db-name'] |
|
225 |
helper = get_adv_func_helper(source['db-driver']) |
|
226 |
if confirm('delete database %s ?' % dbname): |
|
227 |
user = source['db-user'] or None |
|
228 |
cnx = _db_sys_cnx(source, 'DROP DATABASE', user=user) |
|
229 |
cursor = cnx.cursor() |
|
230 |
try: |
|
231 |
cursor.execute('DROP DATABASE %s' % dbname) |
|
232 |
print 'database %s dropped' % dbname |
|
233 |
# XXX should check we are not connected as user |
|
234 |
if user and helper.users_support and \ |
|
235 |
confirm('delete user %s ?' % user, default_is_yes=False): |
|
236 |
cursor.execute('DROP USER %s' % user) |
|
237 |
print 'user %s dropped' % user |
|
238 |
cnx.commit() |
|
239 |
except: |
|
240 |
cnx.rollback() |
|
241 |
raise |
|
242 |
||
1469 | 243 |
|
0 | 244 |
class RepositoryStartHandler(CommandHandler): |
245 |
cmdname = 'start' |
|
246 |
cfgname = 'repository' |
|
247 |
||
248 |
def start_command(self, ctlconf, debug): |
|
249 |
command = ['cubicweb-ctl start-repository '] |
|
250 |
if debug: |
|
251 |
command.append('--debug') |
|
252 |
command.append(self.config.appid) |
|
253 |
return ' '.join(command) |
|
1469 | 254 |
|
0 | 255 |
|
256 |
class RepositoryStopHandler(CommandHandler): |
|
257 |
cmdname = 'stop' |
|
258 |
cfgname = 'repository' |
|
259 |
||
260 |
def poststop(self): |
|
261 |
"""if pyro is enabled, ensure the repository is correctly |
|
262 |
unregistered |
|
263 |
""" |
|
264 |
if self.config.pyro_enabled(): |
|
265 |
from cubicweb.server.repository import pyro_unregister |
|
266 |
pyro_unregister(self.config) |
|
1469 | 267 |
|
0 | 268 |
|
269 |
# repository specific commands ################################################ |
|
270 |
class CreateApplicationDBCommand(Command): |
|
271 |
"""Create the system database of an application (run after 'create'). |
|
1469 | 272 |
|
0 | 273 |
You will be prompted for a login / password to use to connect to |
274 |
the system database. The given user should have almost all rights |
|
275 |
on the database (ie a super user on the dbms allowed to create |
|
276 |
database, users, languages...). |
|
277 |
||
278 |
<application> |
|
279 |
the identifier of the application to initialize. |
|
280 |
""" |
|
281 |
name = 'db-create' |
|
282 |
arguments = '<application>' |
|
1469 | 283 |
|
0 | 284 |
options = ( |
285 |
("create-db", |
|
286 |
{'short': 'c', 'type': "yn", 'metavar': '<y or n>', |
|
287 |
'default': True, |
|
288 |
'help': 'create the database (yes by default)'}), |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
289 |
("verbose", |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
290 |
{'short': 'v', 'type' : 'yn', 'metavar': '<verbose>', |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
291 |
'default': 'n', |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
292 |
'help': 'verbose mode: will ask all possible configuration questions', |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
293 |
} |
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
294 |
), |
0 | 295 |
) |
296 |
def run(self, args): |
|
297 |
"""run the command with its specific arguments""" |
|
298 |
from logilab.common.adbh import get_adv_func_helper |
|
299 |
from indexer import get_indexer |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
300 |
verbose = self.get('verbose') |
0 | 301 |
appid = pop_arg(args, msg="No application specified !") |
302 |
config = ServerConfiguration.config_for(appid) |
|
303 |
create_db = self.config.create_db |
|
304 |
source = config.sources()['system'] |
|
305 |
driver = source['db-driver'] |
|
306 |
helper = get_adv_func_helper(driver) |
|
307 |
if create_db: |
|
308 |
# connect on the dbms system base to create our base |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
309 |
dbcnx = _db_sys_cnx(source, 'CREATE DATABASE and / or USER', verbose=verbose) |
0 | 310 |
cursor = dbcnx.cursor() |
311 |
try: |
|
312 |
if helper.users_support: |
|
313 |
user = source['db-user'] |
|
314 |
if not helper.user_exists(cursor, user) and \ |
|
315 |
confirm('create db user %s ?' % user, default_is_yes=False): |
|
316 |
helper.create_user(source['db-user'], source['db-password']) |
|
317 |
print 'user %s created' % user |
|
318 |
dbname = source['db-name'] |
|
319 |
if dbname in helper.list_databases(cursor): |
|
320 |
if confirm('DB %s already exists -- do you want to drop it ?' % dbname): |
|
321 |
cursor.execute('DROP DATABASE %s' % dbname) |
|
322 |
else: |
|
323 |
return |
|
324 |
if dbcnx.logged_user != source['db-user']: |
|
325 |
helper.create_database(cursor, dbname, source['db-user'], |
|
326 |
source['db-encoding']) |
|
327 |
else: |
|
328 |
helper.create_database(cursor, dbname, |
|
329 |
encoding=source['db-encoding']) |
|
330 |
dbcnx.commit() |
|
331 |
print 'database %s created' % source['db-name'] |
|
332 |
except: |
|
333 |
dbcnx.rollback() |
|
334 |
raise |
|
1469 | 335 |
cnx = system_source_cnx(source, special_privs='LANGUAGE C', verbose=verbose) |
0 | 336 |
cursor = cnx.cursor() |
337 |
indexer = get_indexer(driver) |
|
338 |
indexer.init_extensions(cursor) |
|
1469 | 339 |
# postgres specific stuff |
0 | 340 |
if driver == 'postgres': |
341 |
# install plpythonu/plpgsql language if not installed by the cube |
|
342 |
for extlang in ('plpythonu', 'plpgsql'): |
|
343 |
helper.create_language(cursor, extlang) |
|
344 |
cursor.close() |
|
345 |
cnx.commit() |
|
346 |
print 'database for application %s created and necessary extensions installed' % appid |
|
347 |
print |
|
348 |
if confirm('do you want to initialize the system database?'): |
|
349 |
cmd_run('db-init', config.appid) |
|
350 |
else: |
|
351 |
print 'nevermind, you can do it later using the db-init command' |
|
352 |
||
1469 | 353 |
|
0 | 354 |
class InitApplicationCommand(Command): |
355 |
"""Initialize the system database of an application (run after 'db-create'). |
|
1469 | 356 |
|
0 | 357 |
You will be prompted for a login / password to use to connect to |
358 |
the system database. The given user should have the create tables, |
|
359 |
and grant permissions. |
|
360 |
||
361 |
<application> |
|
362 |
the identifier of the application to initialize. |
|
363 |
""" |
|
364 |
name = 'db-init' |
|
365 |
arguments = '<application>' |
|
1469 | 366 |
|
0 | 367 |
options = ( |
368 |
("drop", |
|
369 |
{'short': 'd', 'action': 'store_true', |
|
370 |
'default': False, |
|
371 |
'help': 'insert drop statements to remove previously existant \ |
|
372 |
tables, indexes... (no by default)'}), |
|
373 |
) |
|
374 |
||
375 |
def run(self, args): |
|
376 |
from cubicweb.server import init_repository |
|
377 |
appid = pop_arg(args, msg="No application specified !") |
|
378 |
config = ServerConfiguration.config_for(appid) |
|
379 |
init_repository(config, drop=self.config.drop) |
|
380 |
||
381 |
||
382 |
class GrantUserOnApplicationCommand(Command): |
|
383 |
"""Grant a database user on a repository system database. |
|
1469 | 384 |
|
0 | 385 |
<application> |
386 |
the identifier of the application |
|
387 |
<user> |
|
388 |
the database's user requiring grant access |
|
389 |
""" |
|
390 |
name = 'db-grant-user' |
|
391 |
arguments = '<application> <user>' |
|
392 |
||
393 |
options = ( |
|
394 |
("set-owner", |
|
1469 | 395 |
{'short': 'o', 'type' : "yn", 'metavar' : '<yes or no>', |
0 | 396 |
'default' : False, |
397 |
'help': 'Set the user as tables owner if yes (no by default).'} |
|
398 |
), |
|
399 |
) |
|
400 |
def run(self, args): |
|
401 |
"""run the command with its specific arguments""" |
|
402 |
from cubicweb.server.sqlutils import sqlexec, sqlgrants |
|
403 |
appid = pop_arg(args, 1, msg="No application specified !") |
|
404 |
user = pop_arg(args, msg="No user specified !") |
|
405 |
config = ServerConfiguration.config_for(appid) |
|
406 |
source = config.sources()['system'] |
|
407 |
set_owner = self.config.set_owner |
|
408 |
cnx = system_source_cnx(source, special_privs='GRANT') |
|
409 |
cursor = cnx.cursor() |
|
410 |
schema = config.load_schema() |
|
411 |
try: |
|
412 |
sqlexec(sqlgrants(schema, source['db-driver'], user, |
|
413 |
set_owner=set_owner), cursor) |
|
414 |
except Exception, ex: |
|
415 |
cnx.rollback() |
|
416 |
import traceback |
|
417 |
traceback.print_exc() |
|
418 |
print 'An error occured:', ex |
|
419 |
else: |
|
420 |
cnx.commit() |
|
421 |
print 'grants given to %s on application %s' % (appid, user) |
|
422 |
||
1912
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
423 |
class ResetAdminPasswordCommand(Command): |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
424 |
"""Reset the administrator password. |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
425 |
|
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
426 |
<application> |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
427 |
the identifier of the application |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
428 |
""" |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
429 |
name = 'reset-admin-pwd' |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
430 |
arguments = '<application>' |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
431 |
|
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
432 |
def run(self, args): |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
433 |
"""run the command with its specific arguments""" |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
434 |
from cubicweb.server.sqlutils import sqlexec, SQL_PREFIX |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
435 |
from cubicweb.server.utils import crypt_password, manager_userpasswd |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
436 |
appid = pop_arg(args, 1, msg="No application specified !") |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
437 |
config = ServerConfiguration.config_for(appid) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
438 |
sourcescfg = config.sources() |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
439 |
try: |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
440 |
adminlogin = sourcescfg['admin']['login'] |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
441 |
except KeyError: |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
442 |
print 'could not get cubicweb administrator login' |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
443 |
sys.exit(1) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
444 |
cnx = source_cnx(sourcescfg['system']) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
445 |
cursor = cnx.cursor() |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
446 |
_, passwd = manager_userpasswd(adminlogin, confirm=True, |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
447 |
passwdmsg='new password for %s' % adminlogin) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
448 |
try: |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
449 |
sqlexec("UPDATE %(sp)sCWUser SET %(sp)supassword='%(p)s' WHERE %(sp)slogin='%(l)s'" |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
450 |
% {'sp': SQL_PREFIX, |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
451 |
'p': crypt_password(passwd), 'l': adminlogin}, |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
452 |
cursor, withpb=False) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
453 |
sconfig = Configuration(options=USER_OPTIONS) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
454 |
sconfig['login'] = adminlogin |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
455 |
sconfig['password'] = passwd |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
456 |
sourcescfg['admin'] = sconfig |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
457 |
sourcesfile = config.sources_file() |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
458 |
generate_sources_file(sourcesfile, sourcescfg) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
459 |
restrict_perms_to_user(sourcesfile) |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
460 |
except Exception, ex: |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
461 |
cnx.rollback() |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
462 |
import traceback |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
463 |
traceback.print_exc() |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
464 |
print 'An error occured:', ex |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
465 |
else: |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
466 |
cnx.commit() |
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
467 |
print 'password reset, sources file regenerated' |
0 | 468 |
|
1469 | 469 |
|
0 | 470 |
class StartRepositoryCommand(Command): |
471 |
"""Start an CubicWeb RQL server for a given application. |
|
1469 | 472 |
|
0 | 473 |
The server will be accessible through pyro |
474 |
||
475 |
<application> |
|
476 |
the identifier of the application to initialize. |
|
477 |
""" |
|
478 |
name = 'start-repository' |
|
479 |
arguments = '<application>' |
|
1469 | 480 |
|
0 | 481 |
options = ( |
482 |
("debug", |
|
483 |
{'short': 'D', 'action' : 'store_true', |
|
484 |
'help': 'start server in debug mode.'}), |
|
485 |
) |
|
486 |
||
487 |
def run(self, args): |
|
488 |
from cubicweb.server.server import RepositoryServer |
|
489 |
appid = pop_arg(args, msg="No application specified !") |
|
490 |
config = ServerConfiguration.config_for(appid) |
|
491 |
debug = self.config.debug |
|
492 |
# create the server |
|
493 |
server = RepositoryServer(config, debug) |
|
494 |
# go ! (don't daemonize in debug mode) |
|
495 |
if not debug and server.daemonize(config['pid-file']) == -1: |
|
496 |
return |
|
497 |
uid = config['uid'] |
|
498 |
if uid is not None: |
|
499 |
try: |
|
500 |
uid = int(uid) |
|
501 |
except ValueError: |
|
502 |
from pwd import getpwnam |
|
503 |
uid = getpwnam(uid).pw_uid |
|
504 |
os.setuid(uid) |
|
505 |
server.install_sig_handlers() |
|
506 |
server.connect(config['host'], 0) |
|
507 |
server.run() |
|
508 |
||
509 |
||
510 |
def _remote_dump(host, appid, output, sudo=False): |
|
511 |
dmpcmd = 'cubicweb-ctl db-dump -o /tmp/%s.dump %s' % (appid, appid) |
|
512 |
if sudo: |
|
513 |
dmpcmd = 'sudo %s' % (dmpcmd) |
|
514 |
dmpcmd = 'ssh -t %s "%s"' % (host, dmpcmd) |
|
515 |
print dmpcmd |
|
516 |
if os.system(dmpcmd): |
|
517 |
raise ExecutionError('Error while dumping the database') |
|
518 |
if output is None: |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
519 |
from datetime import date |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
520 |
date = date.today().strftime('%Y-%m-%d') |
0 | 521 |
output = '%s-%s.dump' % (appid, date) |
522 |
cmd = 'scp %s:/tmp/%s.dump %s' % (host, appid, output) |
|
523 |
print cmd |
|
524 |
if os.system(cmd): |
|
525 |
raise ExecutionError('Error while retrieving the dump') |
|
526 |
rmcmd = 'ssh -t %s "rm -f /tmp/%s.dump"' % (host, appid) |
|
527 |
print rmcmd |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
528 |
if os.system(rmcmd) and not confirm( |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
529 |
'an error occured while deleting remote dump. Continue anyway?'): |
0 | 530 |
raise ExecutionError('Error while deleting remote dump') |
531 |
||
532 |
def _local_dump(appid, output): |
|
533 |
config = ServerConfiguration.config_for(appid) |
|
534 |
# schema=1 to avoid unnecessary schema loading |
|
535 |
mih = config.migration_handler(connect=False, schema=1) |
|
536 |
mih.backup_database(output, askconfirm=False) |
|
537 |
||
538 |
def _local_restore(appid, backupfile, drop): |
|
539 |
config = ServerConfiguration.config_for(appid) |
|
540 |
# schema=1 to avoid unnecessary schema loading |
|
541 |
mih = config.migration_handler(connect=False, schema=1) |
|
542 |
mih.restore_database(backupfile, drop) |
|
543 |
repo = mih.repo_connect() |
|
544 |
# version of the database |
|
545 |
dbversions = repo.get_versions() |
|
546 |
mih.shutdown() |
|
547 |
if not dbversions: |
|
548 |
print "bad or missing version information in the database, don't upgrade file system" |
|
549 |
return |
|
550 |
# version of installed software |
|
551 |
eversion = dbversions['cubicweb'] |
|
552 |
status = application_status(config, eversion, dbversions) |
|
553 |
# * database version > installed software |
|
554 |
if status == 'needsoftupgrade': |
|
555 |
print "database is using some earlier version than installed software!" |
|
556 |
print "please upgrade your software and then upgrade the instance" |
|
557 |
print "using command 'cubicweb-ctl upgrade %s'" % config.appid |
|
558 |
return |
|
559 |
# * database version < installed software, an upgrade will be necessary |
|
560 |
# anyway, just rewrite vc.conf and warn user he has to upgrade |
|
561 |
if status == 'needapplupgrade': |
|
562 |
print "database is using some older version than installed software." |
|
563 |
print "You'll have to upgrade the instance using command" |
|
564 |
print "'cubicweb-ctl upgrade %s'" % config.appid |
|
565 |
return |
|
566 |
# * database version = installed software, database version = instance fs version |
|
567 |
# ok! |
|
568 |
||
569 |
||
570 |
def application_status(config, cubicwebapplversion, vcconf): |
|
571 |
cubicwebversion = config.cubicweb_version() |
|
572 |
if cubicwebapplversion > cubicwebversion: |
|
573 |
return 'needsoftupgrade' |
|
574 |
if cubicwebapplversion < cubicwebversion: |
|
575 |
return 'needapplupgrade' |
|
576 |
for cube in config.cubes(): |
|
577 |
try: |
|
578 |
softversion = config.cube_version(cube) |
|
579 |
except ConfigurationError: |
|
580 |
print "no cube version information for %s, is the cube installed?" % cube |
|
581 |
continue |
|
582 |
try: |
|
583 |
applversion = vcconf[cube] |
|
584 |
except KeyError: |
|
585 |
print "no cube version information for %s in version configuration" % cube |
|
1469 | 586 |
continue |
0 | 587 |
if softversion == applversion: |
588 |
continue |
|
589 |
if softversion > applversion: |
|
590 |
return 'needsoftupgrade' |
|
591 |
elif softversion < applversion: |
|
592 |
return 'needapplupgrade' |
|
593 |
return None |
|
1469 | 594 |
|
0 | 595 |
|
596 |
class DBDumpCommand(Command): |
|
597 |
"""Backup the system database of an application. |
|
1469 | 598 |
|
0 | 599 |
<application> |
600 |
the identifier of the application to backup |
|
601 |
format [[user@]host:]appname |
|
602 |
""" |
|
603 |
name = 'db-dump' |
|
604 |
arguments = '<application>' |
|
605 |
||
606 |
options = ( |
|
607 |
("output", |
|
1469 | 608 |
{'short': 'o', 'type' : "string", 'metavar' : '<file>', |
0 | 609 |
'default' : None, |
610 |
'help': 'Specify the backup file where the backup will be stored.'} |
|
611 |
), |
|
612 |
('sudo', |
|
613 |
{'short': 's', 'action' : 'store_true', |
|
614 |
'default' : False, |
|
615 |
'help': 'Use sudo on the remote host.'} |
|
616 |
), |
|
617 |
) |
|
618 |
||
619 |
def run(self, args): |
|
620 |
appid = pop_arg(args, 1, msg="No application specified !") |
|
621 |
if ':' in appid: |
|
622 |
host, appid = appid.split(':') |
|
623 |
_remote_dump(host, appid, self.config.output, self.config.sudo) |
|
624 |
else: |
|
625 |
_local_dump(appid, self.config.output) |
|
626 |
||
627 |
||
628 |
class DBRestoreCommand(Command): |
|
629 |
"""Restore the system database of an application. |
|
1469 | 630 |
|
0 | 631 |
<application> |
632 |
the identifier of the application to restore |
|
633 |
""" |
|
634 |
name = 'db-restore' |
|
635 |
arguments = '<application> <backupfile>' |
|
636 |
||
637 |
options = ( |
|
638 |
("no-drop", |
|
1469 | 639 |
{'short': 'n', 'action' : 'store_true', |
0 | 640 |
'default' : False, |
641 |
'help': 'for some reason the database doesn\'t exist and so ' |
|
642 |
'should not be dropped.'} |
|
643 |
), |
|
644 |
) |
|
645 |
||
646 |
def run(self, args): |
|
647 |
appid = pop_arg(args, 1, msg="No application specified !") |
|
648 |
backupfile = pop_arg(args, msg="No backup file specified !") |
|
649 |
_local_restore(appid, backupfile, not self.config.no_drop) |
|
650 |
||
651 |
||
652 |
class DBCopyCommand(Command): |
|
653 |
"""Copy the system database of an application (backup and restore). |
|
1469 | 654 |
|
0 | 655 |
<src-application> |
656 |
the identifier of the application to backup |
|
657 |
format [[user@]host:]appname |
|
658 |
||
659 |
<dest-application> |
|
660 |
the identifier of the application to restore |
|
661 |
""" |
|
662 |
name = 'db-copy' |
|
663 |
arguments = '<src-application> <dest-application>' |
|
664 |
||
665 |
options = ( |
|
666 |
("no-drop", |
|
1469 | 667 |
{'short': 'n', 'action' : 'store_true', |
0 | 668 |
'default' : False, |
669 |
'help': 'For some reason the database doesn\'t exist and so ' |
|
670 |
'should not be dropped.'} |
|
671 |
), |
|
672 |
("keep-dump", |
|
673 |
{'short': 'k', 'action' : 'store_true', |
|
674 |
'default' : False, |
|
675 |
'help': 'Specify that the dump file should not be automatically removed.'} |
|
676 |
), |
|
677 |
('sudo', |
|
678 |
{'short': 's', 'action' : 'store_true', |
|
679 |
'default' : False, |
|
680 |
'help': 'Use sudo on the remote host.'} |
|
681 |
), |
|
682 |
) |
|
683 |
||
684 |
def run(self, args): |
|
685 |
import tempfile |
|
686 |
srcappid = pop_arg(args, 1, msg="No source application specified !") |
|
687 |
destappid = pop_arg(args, msg="No destination application specified !") |
|
688 |
output = tempfile.mktemp() |
|
689 |
if ':' in srcappid: |
|
690 |
host, srcappid = srcappid.split(':') |
|
691 |
_remote_dump(host, srcappid, output, self.config.sudo) |
|
692 |
else: |
|
693 |
_local_dump(srcappid, output) |
|
694 |
_local_restore(destappid, output, not self.config.no_drop) |
|
695 |
if self.config.keep_dump: |
|
696 |
print 'you can get the dump file at', output |
|
697 |
else: |
|
698 |
os.remove(output) |
|
699 |
||
1469 | 700 |
|
0 | 701 |
class CheckRepositoryCommand(Command): |
702 |
"""Check integrity of the system database of an application. |
|
1469 | 703 |
|
0 | 704 |
<application> |
705 |
the identifier of the application to check |
|
706 |
""" |
|
707 |
name = 'db-check' |
|
708 |
arguments = '<application>' |
|
709 |
||
710 |
options = ( |
|
711 |
("checks", |
|
1469 | 712 |
{'short': 'c', 'type' : "csv", 'metavar' : '<check list>', |
0 | 713 |
'default' : ('entities', 'relations', 'metadata', 'schema', 'text_index'), |
714 |
'help': 'Comma separated list of check to run. By default run all \ |
|
715 |
checks, i.e. entities, relations, text_index and metadata.'} |
|
716 |
), |
|
1469 | 717 |
|
0 | 718 |
("autofix", |
1469 | 719 |
{'short': 'a', 'type' : "yn", 'metavar' : '<yes or no>', |
0 | 720 |
'default' : False, |
721 |
'help': 'Automatically correct integrity problems if this option \ |
|
722 |
is set to "y" or "yes", else only display them'} |
|
723 |
), |
|
724 |
("reindex", |
|
1469 | 725 |
{'short': 'r', 'type' : "yn", 'metavar' : '<yes or no>', |
0 | 726 |
'default' : False, |
727 |
'help': 're-indexes the database for full text search if this \ |
|
728 |
option is set to "y" or "yes" (may be long for large database).'} |
|
729 |
), |
|
1469 | 730 |
|
0 | 731 |
) |
732 |
||
733 |
def run(self, args): |
|
734 |
from cubicweb.server.checkintegrity import check |
|
735 |
appid = pop_arg(args, 1, msg="No application specified !") |
|
736 |
config = ServerConfiguration.config_for(appid) |
|
737 |
repo, cnx = repo_cnx(config) |
|
738 |
check(repo, cnx, |
|
739 |
self.config.checks, self.config.reindex, self.config.autofix) |
|
740 |
||
741 |
||
742 |
class RebuildFTICommand(Command): |
|
743 |
"""Rebuild the full-text index of the system database of an application. |
|
1469 | 744 |
|
0 | 745 |
<application> |
746 |
the identifier of the application to rebuild |
|
747 |
""" |
|
748 |
name = 'db-rebuild-fti' |
|
749 |
arguments = '<application>' |
|
750 |
||
751 |
options = () |
|
752 |
||
753 |
def run(self, args): |
|
754 |
from cubicweb.server.checkintegrity import reindex_entities |
|
755 |
appid = pop_arg(args, 1, msg="No application specified !") |
|
756 |
config = ServerConfiguration.config_for(appid) |
|
757 |
repo, cnx = repo_cnx(config) |
|
758 |
session = repo._get_session(cnx.sessionid, setpool=True) |
|
759 |
reindex_entities(repo.schema, session) |
|
760 |
cnx.commit() |
|
761 |
||
1469 | 762 |
|
0 | 763 |
class SynchronizeApplicationSchemaCommand(Command): |
764 |
"""Synchronize persistent schema with cube schema. |
|
1469 | 765 |
|
0 | 766 |
Will synchronize common stuff between the cube schema and the |
767 |
actual persistent schema, but will not add/remove any entity or relation. |
|
768 |
||
769 |
<application> |
|
770 |
the identifier of the application to synchronize. |
|
771 |
""" |
|
772 |
name = 'schema-sync' |
|
773 |
arguments = '<application>' |
|
774 |
||
775 |
def run(self, args): |
|
776 |
appid = pop_arg(args, msg="No application specified !") |
|
777 |
config = ServerConfiguration.config_for(appid) |
|
778 |
mih = config.migration_handler() |
|
779 |
mih.cmd_synchronize_schema() |
|
780 |
||
781 |
||
1469 | 782 |
register_commands( (CreateApplicationDBCommand, |
0 | 783 |
InitApplicationCommand, |
784 |
GrantUserOnApplicationCommand, |
|
1912
2b9432262240
[server] provide a new reset-admin-pwd command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1682
diff
changeset
|
785 |
ResetAdminPasswordCommand, |
0 | 786 |
StartRepositoryCommand, |
787 |
DBDumpCommand, |
|
788 |
DBRestoreCommand, |
|
789 |
DBCopyCommand, |
|
790 |
CheckRepositoryCommand, |
|
791 |
RebuildFTICommand, |
|
792 |
SynchronizeApplicationSchemaCommand, |
|
793 |
) ) |