server/serverctl.py
branchstable
changeset 3904 dc7d315165fc
parent 3893 74f216b69628
child 3954 56a8b14d68aa
equal deleted inserted replaced
3903:7967d3766ecf 3904:dc7d315165fc
    12 
    12 
    13 from logilab.common.configuration import Configuration
    13 from logilab.common.configuration import Configuration
    14 from logilab.common.clcommands import register_commands, cmd_run, pop_arg
    14 from logilab.common.clcommands import register_commands, cmd_run, pop_arg
    15 from logilab.common.shellutils import ASK
    15 from logilab.common.shellutils import ASK
    16 
    16 
    17 from cubicweb import AuthenticationError, ExecutionError, ConfigurationError, underline_title
    17 from cubicweb import (AuthenticationError, ExecutionError, ConfigurationError,
       
    18                       underline_title)
    18 from cubicweb.toolsutils import Command, CommandHandler
    19 from cubicweb.toolsutils import Command, CommandHandler
    19 from cubicweb.server import SOURCE_TYPES
    20 from cubicweb.server import SOURCE_TYPES
    20 from cubicweb.server.utils import ask_source_config
    21 from cubicweb.server.utils import ask_source_config
    21 from cubicweb.server.serverconfig import USER_OPTIONS, ServerConfiguration
    22 from cubicweb.server.serverconfig import (USER_OPTIONS, ServerConfiguration,
       
    23                                           SourceConfiguration)
    22 
    24 
    23 # utility functions ###########################################################
    25 # utility functions ###########################################################
    24 
    26 
    25 def source_cnx(source, dbname=None, special_privs=False, verbose=True):
    27 def source_cnx(source, dbname=None, special_privs=False, verbose=True):
    26     """open and return a connection to the system database defined in the
    28     """open and return a connection to the system database defined in the
   111             print '-> Error: wrong user/password.'
   113             print '-> Error: wrong user/password.'
   112             # reset cubes else we'll have an assertion error on next retry
   114             # reset cubes else we'll have an assertion error on next retry
   113             config._cubes = None
   115             config._cubes = None
   114         login, pwd = manager_userpasswd()
   116         login, pwd = manager_userpasswd()
   115 
   117 
       
   118 
   116 # repository specific command handlers ########################################
   119 # repository specific command handlers ########################################
   117 
   120 
   118 class RepositoryCreateHandler(CommandHandler):
   121 class RepositoryCreateHandler(CommandHandler):
   119     cmdname = 'create'
   122     cmdname = 'create'
   120     cfgname = 'repository'
   123     cfgname = 'repository'
   133             config.input_config('pyro', inputlevel)
   136             config.input_config('pyro', inputlevel)
   134         print '\n'+underline_title('Configuring the sources')
   137         print '\n'+underline_title('Configuring the sources')
   135         sourcesfile = config.sources_file()
   138         sourcesfile = config.sources_file()
   136         # XXX hack to make Method('default_instance_id') usable in db option
   139         # XXX hack to make Method('default_instance_id') usable in db option
   137         # defs (in native.py)
   140         # defs (in native.py)
   138         Configuration.default_instance_id = staticmethod(lambda: config.appid)
   141         sconfig = SourceConfiguration(config.appid,
   139         sconfig = Configuration(options=SOURCE_TYPES['native'].options)
   142                                       options=SOURCE_TYPES['native'].options)
   140         sconfig.adapter = 'native'
   143         sconfig.adapter = 'native'
   141         sconfig.input_config(inputlevel=inputlevel)
   144         sconfig.input_config(inputlevel=inputlevel)
   142         sourcescfg = {'system': sconfig}
   145         sourcescfg = {'system': sconfig}
   143         for cube in cubes:
   146         for cube in cubes:
   144             # if a source is named as the cube containing it, we need the
   147             # if a source is named as the cube containing it, we need the