summaryrefslogtreecommitdiff
path: root/compute/gcloud.py
diff options
context:
space:
mode:
authorPrathmesh Prabhu <pprabhu@chromium.org>2015-03-24 14:22:39 -0700
committerPrathmesh Prabhu <pprabhu@chromium.org>2015-03-24 22:21:59 +0000
commit68a7e367ad747a6520f06a0815ceb7ce0e311a8b (patch)
tree3ee209a81c493b0ecfcbd3aefce47bdb871416f5 /compute/gcloud.py
parent04ee26332c48cd21b6ae034b790b3eb1ebaacfe4 (diff)
downloadchromite-68a7e367ad747a6520f06a0815ceb7ce0e311a8b.tar.gz
cros_compute: Tag instances with the seed image.
We currently have no way of knowing which cros_compute image any bot on our GCE build farm is running. Add custom metadata when creating instances to remember the image used to create an instance. We could later use this tag to automate deployment. BUG=chromium:470240 TEST=Create a new instance, manually verify metadata. Change-Id: I02b146f42ae9c0f6c8110b85be74a452326f6955 Reviewed-on: https://chromium-review.googlesource.com/262257 Reviewed-by: Fang Deng <fdeng@chromium.org> Reviewed-by: Aviv Keshet <akeshet@chromium.org> Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Diffstat (limited to 'compute/gcloud.py')
-rw-r--r--compute/gcloud.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/compute/gcloud.py b/compute/gcloud.py
index 8273491df..a9c10f8bd 100644
--- a/compute/gcloud.py
+++ b/compute/gcloud.py
@@ -6,6 +6,7 @@
from __future__ import print_function
+from chromite.compute import compute_configs
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import timeout_util
@@ -164,6 +165,9 @@ class GCContext(object):
scopes=None, **kwargs):
"""Creates an |instance|.
+ Additionally, if an image is provided, adds a custom metadata pair to
+ identify the the image used to create the instance.
+
Args:
instance: The name of the instance to create.
image: The source image to create |instance| from.
@@ -177,6 +181,8 @@ class GCContext(object):
cmd = ['instances', 'create', instance]
if image:
cmd += ['--image', image]
+ cmd += ['--metadata',
+ '%s="%s"' % (compute_configs.METADATA_IMAGE_NAME, image)]
if address:
cmd += ['--address', address]
if machine_type: