server/serverctl.py
changeset 6724 24bf6f181d0e
parent 6700 accb7290a31c
child 6782 b5d6f5391695
equal deleted inserted replaced
6723:a2ccbcbb08a6 6724:24bf6f181d0e
   895         config = ServerConfiguration.config_for(appid)
   895         config = ServerConfiguration.config_for(appid)
   896         mih = config.migration_handler()
   896         mih = config.migration_handler()
   897         mih.cmd_synchronize_schema()
   897         mih.cmd_synchronize_schema()
   898 
   898 
   899 
   899 
   900 class CheckMappingCommand(Command):
       
   901     """Check content of the mapping file of an external source.
       
   902 
       
   903     The mapping is checked against the instance's schema, searching for
       
   904     inconsistencies or stuff you may have forgotten. It's higly recommanded to
       
   905     run it when you setup a multi-sources instance.
       
   906 
       
   907     <instance>
       
   908       the identifier of the instance.
       
   909 
       
   910     <mapping file>
       
   911       the mapping file to check.
       
   912     """
       
   913     name = 'check-mapping'
       
   914     arguments = '<instance> <mapping file>'
       
   915     min_args = max_args = 2
       
   916 
       
   917     def run(self, args):
       
   918         from cubicweb.server.checkintegrity import check_mapping
       
   919         from cubicweb.server.sources.pyrorql import load_mapping_file
       
   920         appid, mappingfile = args
       
   921         config = ServerConfiguration.config_for(appid)
       
   922         config.quick_start = True
       
   923         mih = config.migration_handler(connect=False, verbosity=1)
       
   924         repo = mih.repo_connect() # necessary to get cubes
       
   925         check_mapping(config.load_schema(), load_mapping_file(mappingfile))
       
   926 
       
   927 for cmdclass in (CreateInstanceDBCommand, InitInstanceCommand,
   900 for cmdclass in (CreateInstanceDBCommand, InitInstanceCommand,
   928                  GrantUserOnInstanceCommand, ResetAdminPasswordCommand,
   901                  GrantUserOnInstanceCommand, ResetAdminPasswordCommand,
   929                  StartRepositoryCommand,
   902                  StartRepositoryCommand,
   930                  DBDumpCommand, DBRestoreCommand, DBCopyCommand,
   903                  DBDumpCommand, DBRestoreCommand, DBCopyCommand,
   931                  AddSourceCommand, CheckRepositoryCommand, RebuildFTICommand,
   904                  AddSourceCommand, CheckRepositoryCommand, RebuildFTICommand,
   932                  SynchronizeInstanceSchemaCommand,
   905                  SynchronizeInstanceSchemaCommand,
   933                  CheckMappingCommand,
       
   934                  ):
   906                  ):
   935     CWCTL.register(cmdclass)
   907     CWCTL.register(cmdclass)