1103 |
1103 |
1104 # extend configure command to set options in sources config file ############### |
1104 # extend configure command to set options in sources config file ############### |
1105 |
1105 |
1106 db_options = ( |
1106 db_options = ( |
1107 ('db', |
1107 ('db', |
1108 {'short': 'd', 'type' : 'named', 'metavar' : 'key1:value1,key2:value2', |
1108 {'short': 'd', 'type' : 'named', 'metavar' : '[section1.]key1:value1,[section2.]key2:value2', |
1109 'default': None, |
1109 'default': None, |
1110 'help': 'set <key> to <value> in "source" configuration file.', |
1110 'help': '''set <key> in <section> to <value> in "source" configuration file. If <section> is not specified, it defaults to "system". |
|
1111 |
|
1112 Beware that changing admin.login or admin.password using this command |
|
1113 will NOT update the database with new admin credentials. Use the |
|
1114 reset-admin-pwd command instead. |
|
1115 ''', |
1111 }), |
1116 }), |
1112 ) |
1117 ) |
1113 |
1118 |
1114 ConfigureInstanceCommand.options = merge_options( |
1119 ConfigureInstanceCommand.options = merge_options( |
1115 ConfigureInstanceCommand.options + db_options) |
1120 ConfigureInstanceCommand.options + db_options) |
1119 configure_instance(self, appid) |
1124 configure_instance(self, appid) |
1120 if self.config.db is not None: |
1125 if self.config.db is not None: |
1121 appcfg = ServerConfiguration.config_for(appid) |
1126 appcfg = ServerConfiguration.config_for(appid) |
1122 srccfg = appcfg.read_sources_file() |
1127 srccfg = appcfg.read_sources_file() |
1123 for key, value in self.config.db.iteritems(): |
1128 for key, value in self.config.db.iteritems(): |
|
1129 if '.' in key: |
|
1130 section, key = key.split('.', 1) |
|
1131 else: |
|
1132 section = 'system' |
1124 try: |
1133 try: |
1125 srccfg['system'][key] = value |
1134 srccfg[section][key] = value |
1126 except KeyError: |
1135 except KeyError: |
1127 raise ConfigurationError('unknown configuration key "%s" for source' % key) |
1136 raise ConfigurationError('unknown configuration key "%s" in section "%s" for source' % (key, section)) |
1128 admcfg = Configuration(options=USER_OPTIONS) |
1137 admcfg = Configuration(options=USER_OPTIONS) |
1129 admcfg['login'] = srccfg['admin']['login'] |
1138 admcfg['login'] = srccfg['admin']['login'] |
1130 admcfg['password'] = srccfg['admin']['password'] |
1139 admcfg['password'] = srccfg['admin']['password'] |
1131 srccfg['admin'] = admcfg |
1140 srccfg['admin'] = admcfg |
1132 appcfg.write_sources_file(srccfg) |
1141 appcfg.write_sources_file(srccfg) |