| OLD | NEW |
| 1 # Copyright 2015 The Swarming Authors. All rights reserved. | 1 # Copyright 2015 The Swarming Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Imports config files stored in Gitiles. | 5 """Imports config files stored in Gitiles. |
| 6 | 6 |
| 7 If services_config_location is set in admin.GlobalConfig root entity, | 7 If services_config_location is set in admin.GlobalConfig root entity, |
| 8 each directory in the location is imported as services/<directory_name>. | 8 each directory in the location is imported as services/<directory_name>. |
| 9 | 9 |
| 10 For each project defined in the project registry with | 10 For each project defined in the project registry with |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 logging.error( | 171 logging.error( |
| 172 'Could not import config set %s from %s: urlfetch deadline exceeded', | 172 'Could not import config set %s from %s: urlfetch deadline exceeded', |
| 173 config_set, location) | 173 config_set, location) |
| 174 except net.AuthError: | 174 except net.AuthError: |
| 175 logging.error( | 175 logging.error( |
| 176 'Could not import config set %s from %s: permission denied', | 176 'Could not import config set %s from %s: permission denied', |
| 177 config_set, location) | 177 config_set, location) |
| 178 | 178 |
| 179 | 179 |
| 180 def import_services(location_root): | 180 def import_services(location_root): |
| 181 # TODO(nodir): import services from location specified in services.cfg |
| 181 assert location_root | 182 assert location_root |
| 182 tree = location_root.get_tree() | 183 tree = location_root.get_tree() |
| 183 | 184 |
| 184 for service_entry in tree.entries: | 185 for service_entry in tree.entries: |
| 185 service_id = service_entry.name | 186 service_id = service_entry.name |
| 186 if service_entry.type != 'tree': | 187 if service_entry.type != 'tree': |
| 187 continue | 188 continue |
| 188 if not config.validation.is_valid_service_id(service_id): | 189 if not config.validation.is_valid_service_id(service_id): |
| 189 logging.error('Invalid service id: %s', service_id) | 190 logging.error('Invalid service id: %s', service_id) |
| 190 continue | 191 continue |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 249 |
| 249 | 250 |
| 250 def cron_run_import(): # pragma: no cover | 251 def cron_run_import(): # pragma: no cover |
| 251 conf = admin.GlobalConfig.fetch() | 252 conf = admin.GlobalConfig.fetch() |
| 252 gitiles_type = admin.ServiceConfigStorageType.GITILES | 253 gitiles_type = admin.ServiceConfigStorageType.GITILES |
| 253 if (conf and conf.services_config_storage_type == gitiles_type and | 254 if (conf and conf.services_config_storage_type == gitiles_type and |
| 254 conf.services_config_location): | 255 conf.services_config_location): |
| 255 loc = gitiles.Location.parse_resolve(conf.services_config_location) | 256 loc = gitiles.Location.parse_resolve(conf.services_config_location) |
| 256 import_services(loc) | 257 import_services(loc) |
| 257 import_projects() | 258 import_projects() |
| OLD | NEW |