Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 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 """Utilities for interacting with the Machine Provider catalog.""" | 5 """Utilities for interacting with the Machine Provider catalog.""" |
| 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 from protorpc.remote import protojson | 11 from protorpc.remote import protojson |
| 12 | 12 |
| 13 from components import gce | 13 from components import gce |
| 14 from components import machine_provider | 14 from components import machine_provider |
| 15 from components import net | 15 from components import net |
| 16 from components import utils | 16 from components import utils |
| 17 | 17 |
| 18 import instances | 18 import instances |
| 19 import instance_group_managers | 19 import instance_group_managers |
| 20 import metrics | 20 import metrics |
| 21 import models | 21 import models |
| 22 import pubsub | |
| 23 | 22 |
| 24 | 23 |
| 25 def get_policies(key, service_account): | 24 def get_policies(key, service_account): |
| 26 """Returns Machine Provider policies governing the given instance. | 25 """Returns Machine Provider policies governing the given instance. |
| 27 | 26 |
| 28 Args: | 27 Args: |
| 29 key: ndb.Key for a models.Instance entity. | 28 key: ndb.Key for a models.Instance entity. |
| 30 service_account: Name of the service account the instance will use to | 29 service_account: Name of the service account the instance will use to |
| 31 talk to Machine Provider. | 30 talk to Machine Provider. |
| 32 """ | 31 """ |
| 33 return { | 32 return { |
| 34 'backend_attributes': { | 33 'backend_attributes': { |
| 35 'key': 'key', | 34 'key': 'key', |
| 36 'value': key.urlsafe(), | 35 'value': key.urlsafe(), |
| 37 }, | 36 }, |
| 38 'backend_project': pubsub.get_machine_provider_topic_project(), | |
| 39 'backend_topic': pubsub.get_machine_provider_topic(), | |
|
ryanmartens
2016/11/04 14:02:52
We should probably update the comment in the Polic
ryanmartens
2016/11/04 14:02:52
Also, are you planning on pulling out the notifica
smut
2016/11/04 21:09:21
Everything there is technically true, MP will stil
smut
2016/11/04 21:09:21
Right now backend notification is optional, if bac
| |
| 40 'machine_service_account': service_account, | 37 'machine_service_account': service_account, |
| 41 'on_reclamation': 'DELETE', | 38 'on_reclamation': 'DELETE', |
| 42 } | 39 } |
| 43 | 40 |
| 44 | 41 |
| 45 def extract_dimensions(instance, instance_template_revision): | 42 def extract_dimensions(instance, instance_template_revision): |
| 46 """Extracts Machine Provider dimensions. | 43 """Extracts Machine Provider dimensions. |
| 47 | 44 |
| 48 Args: | 45 Args: |
| 49 instance: models.Instance entity. | 46 instance: models.Instance entity. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 for instance in models.Instance.query(): | 251 for instance in models.Instance.query(): |
| 255 if instance.cataloged: | 252 if instance.cataloged: |
| 256 if not utils.enqueue_task( | 253 if not utils.enqueue_task( |
| 257 '/internal/queues/update-cataloged-instance', | 254 '/internal/queues/update-cataloged-instance', |
| 258 'update-cataloged-instance', | 255 'update-cataloged-instance', |
| 259 params={ | 256 params={ |
| 260 'key': instance.key.urlsafe(), | 257 'key': instance.key.urlsafe(), |
| 261 }, | 258 }, |
| 262 ): | 259 ): |
| 263 logging.warning('Failed to enqueue task for Instance: %s', instance.key) | 260 logging.warning('Failed to enqueue task for Instance: %s', instance.key) |
| OLD | NEW |