Revision ce9ccb40 kamaki/cli/__init__.py

b/kamaki/cli/__init__.py
192 192
    kloger = logger.get_logger(__name__)
193 193

  
194 194

  
195
def _check_config_version(cnf):
196
    guess = cnf.guess_version()
197
    if guess < 3.0:
198
        print('Configuration file "%s" is not updated to v3.0' % (
199
            cnf.path))
200
        print('Calculating changes while preserving information ...')
201
        lost_terms = cnf.rescue_old_file()
202
        if lost_terms:
203
            print 'The following information will not be preserved:'
204
            print '...', '\n... '.join(lost_terms)
205
        print('... DONE')
206
        print('Kamaki is ready to transform config file to version 3.0')
207
        stdout.write('Overwrite file %s ? [Y, y] ' % cnf.path)
208
        from sys import stdin
209
        reply = stdin.readline()
210
        if reply in ('Y\n', 'y\n'):
211
            cnf.write()
212
            print('... DONE')
213
        else:
214
            print('... ABORTING')
215
            raise CLIError(
216
                'Invalid format for config file %s' % cnf.path,
217
                importance=3, details=['Please, update config file to v3.0'])
218

  
219

  
195 220
def _init_session(arguments):
196 221
    global _help
197 222
    _help = arguments['help'].value
......
202 227
    global _verbose
203 228
    _verbose = arguments['verbose'].value
204 229
    _cnf = arguments['config']
205

  
206
    guess = _cnf.value.guess_version()
207
    if guess < 3.0:
208
        print('Missing an updated configuration file')
209
        print('Updating configuration file without missing any information')
210
        #_cnf.value.rescue_old_file()
211
        print('... ... ... DONE')
212
        raise CLIError(
213
            'Invalid configuration file %s' % _cnf.value.path,
214
            importance=2, details=[
215
                'Kamaki is now using a single authentication URL and token',
216
                'To check if the single authentication URL is set:',
217
                '  /config get remote.default.token',
218
                'To check if the single authentication token is set:',
219
                '  /config get remote.default.token',
220
                'To set the default authentication URL and token:'
221
                '  /config set remote.default.url <URL>',
222
                '  /config set remote.default.token <token>'])
230
    _check_config_version(_cnf.value)
223 231
    raise CLIError(
224
        'Your file is OK, but kamaki is under contruction, sorry',
232
        'Your file is OK, but i am not ready to proceed',
225 233
        importance=3, details=['DO NOT PANIC, EXIT THE BUILDING QUIETLY'])
226 234

  
227 235
    global _colors

Also available in: Unified diff