| OLD | NEW |
| 1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Task queues for the GCE Backend.""" | 5 """Task queues for the GCE Backend.""" |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 | 9 |
| 10 from google.appengine.ext import ndb | 10 from google.appengine.ext import ndb |
| 11 import webapp2 | 11 import webapp2 |
| 12 | 12 |
| 13 from components import decorators | 13 from components import decorators |
| 14 | 14 |
| 15 import catalog | 15 import catalog |
| 16 import cleanup | 16 import cleanup |
| 17 import instance_group_managers | 17 import instance_group_managers |
| 18 import instance_templates | 18 import instance_templates |
| 19 import instances | 19 import instances |
| 20 import metadata | 20 import metadata |
| 21 import pubsub | |
| 22 | 21 |
| 23 | 22 |
| 24 class CatalogedInstanceRemovalHandler(webapp2.RequestHandler): | 23 class CatalogedInstanceRemovalHandler(webapp2.RequestHandler): |
| 25 """Worker for removing cataloged instances.""" | 24 """Worker for removing cataloged instances.""" |
| 26 | 25 |
| 27 @decorators.require_taskqueue('remove-cataloged-instance') | 26 @decorators.require_taskqueue('remove-cataloged-instance') |
| 28 def post(self): | 27 def post(self): |
| 29 """Removes a cataloged instance. | 28 """Removes a cataloged instance. |
| 30 | 29 |
| 31 Params: | 30 Params: |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 """Deletes the instance template for the given InstanceTemplateRevision. | 268 """Deletes the instance template for the given InstanceTemplateRevision. |
| 270 | 269 |
| 271 Params: | 270 Params: |
| 272 key: URL-safe key for a models.InstanceTemplateRevision. | 271 key: URL-safe key for a models.InstanceTemplateRevision. |
| 273 """ | 272 """ |
| 274 key = ndb.Key(urlsafe=self.request.get('key')) | 273 key = ndb.Key(urlsafe=self.request.get('key')) |
| 275 assert key.kind() == 'InstanceTemplateRevision', key | 274 assert key.kind() == 'InstanceTemplateRevision', key |
| 276 instance_templates.delete(key) | 275 instance_templates.delete(key) |
| 277 | 276 |
| 278 | 277 |
| 279 class PubSubMessageProcessHandler(webapp2.RequestHandler): | |
| 280 """Worker for polling and processing Pub/Sub messages.""" | |
| 281 | |
| 282 @decorators.require_taskqueue('process-pubsub-messages') | |
| 283 def post(self): | |
| 284 """Polls and processes Pub/Sub messages.""" | |
| 285 pubsub.poll() | |
| 286 | |
| 287 | |
| 288 def create_queues_app(): | 278 def create_queues_app(): |
| 289 return webapp2.WSGIApplication([ | 279 return webapp2.WSGIApplication([ |
| 290 ('/internal/queues/catalog-instance', InstanceCatalogHandler), | 280 ('/internal/queues/catalog-instance', InstanceCatalogHandler), |
| 291 ('/internal/queues/check-deleted-instance', | 281 ('/internal/queues/check-deleted-instance', |
| 292 DeletedInstanceCheckHandler), | 282 DeletedInstanceCheckHandler), |
| 293 ('/internal/queues/check-instance-metadata-operation', | 283 ('/internal/queues/check-instance-metadata-operation', |
| 294 InstanceMetadataOperationCheckHandler), | 284 InstanceMetadataOperationCheckHandler), |
| 295 ('/internal/queues/cleanup-deleted-instance', | 285 ('/internal/queues/cleanup-deleted-instance', |
| 296 DeletedInstanceCleanupHandler), | 286 DeletedInstanceCleanupHandler), |
| 297 ('/internal/queues/cleanup-drained-instance', | 287 ('/internal/queues/cleanup-drained-instance', |
| 298 DrainedInstanceCleanupHandler), | 288 DrainedInstanceCleanupHandler), |
| 299 ('/internal/queues/compress-instance-metadata-updates', | 289 ('/internal/queues/compress-instance-metadata-updates', |
| 300 InstanceMetadataUpdatesCompressionHandler), | 290 InstanceMetadataUpdatesCompressionHandler), |
| 301 ('/internal/queues/create-instance-group-manager', | 291 ('/internal/queues/create-instance-group-manager', |
| 302 InstanceGroupManagerCreationHandler), | 292 InstanceGroupManagerCreationHandler), |
| 303 ('/internal/queues/create-instance-template', | 293 ('/internal/queues/create-instance-template', |
| 304 InstanceTemplateCreationHandler), | 294 InstanceTemplateCreationHandler), |
| 305 ('/internal/queues/delete-drained-instance', | 295 ('/internal/queues/delete-drained-instance', |
| 306 DrainedInstanceDeletionHandler), | 296 DrainedInstanceDeletionHandler), |
| 307 ('/internal/queues/delete-instance-group-manager', | 297 ('/internal/queues/delete-instance-group-manager', |
| 308 InstanceGroupManagerDeletionHandler), | 298 InstanceGroupManagerDeletionHandler), |
| 309 ('/internal/queues/delete-instance-pending-deletion', | 299 ('/internal/queues/delete-instance-pending-deletion', |
| 310 InstancePendingDeletionDeletionHandler), | 300 InstancePendingDeletionDeletionHandler), |
| 311 ('/internal/queues/delete-instance-template', | 301 ('/internal/queues/delete-instance-template', |
| 312 InstanceTemplateDeletionHandler), | 302 InstanceTemplateDeletionHandler), |
| 313 ('/internal/queues/fetch-instances', InstanceFetchHandler), | 303 ('/internal/queues/fetch-instances', InstanceFetchHandler), |
| 314 ('/internal/queues/process-pubsub-messages', PubSubMessageProcessHandler), | |
| 315 ('/internal/queues/remove-cataloged-instance', | 304 ('/internal/queues/remove-cataloged-instance', |
| 316 CatalogedInstanceRemovalHandler), | 305 CatalogedInstanceRemovalHandler), |
| 317 ('/internal/queues/resize-instance-group', InstanceGroupResizeHandler), | 306 ('/internal/queues/resize-instance-group', InstanceGroupResizeHandler), |
| 318 ('/internal/queues/update-cataloged-instance', | 307 ('/internal/queues/update-cataloged-instance', |
| 319 CatalogedInstanceUpdateHandler), | 308 CatalogedInstanceUpdateHandler), |
| 320 ('/internal/queues/update-instance-metadata', | 309 ('/internal/queues/update-instance-metadata', |
| 321 InstanceMetadataUpdateHandler), | 310 InstanceMetadataUpdateHandler), |
| 322 ]) | 311 ]) |
| OLD | NEW |