acloud create: If setup was skipped, tell the user to do it, nicely.
We can tell if the user needs a config file or host setup based on the
create action they specified so instead of raising an exception
somewhere and confusing them, point them to run acloud setup.
Bug: 110383583
Test: acloud create with no ~/.config/acloud/acloud.config
Change-Id: Id0aabbea821f9d9f6f5fc3c5d0ea277284e5bdd7
diff --git a/setup/gcp_setup_runner.py b/setup/gcp_setup_runner.py
index f50b2c0..30074a5 100644
--- a/setup/gcp_setup_runner.py
+++ b/setup/gcp_setup_runner.py
@@ -198,11 +198,7 @@
self.storage_bucket_name = cfg.storage_bucket_name
self.ssh_private_key_path = cfg.ssh_private_key_path
self.ssh_public_key_path = cfg.ssh_public_key_path
-
- # Write default stable_host_image_name with dummy value.
- # TODO(113091773): An additional step to create the host image.
- if not cfg.stable_host_image_name:
- UpdateConfigFile(self.config_path, "stable_host_image_name", "")
+ self.stable_host_image_name = cfg.stable_host_image_name
def ShouldRun(self):
"""Check if we actually need to run GCP setup.
@@ -236,9 +232,18 @@
google_sdk_runner = GoogleSDKBins(google_sdk_init.GetSDKBinPath())
self._SetupProject(google_sdk_runner)
self._EnableGcloudServices(google_sdk_runner)
+ self._CreateStableHostImage()
finally:
google_sdk_init.CleanUp()
+ def _CreateStableHostImage(self):
+ """Create the stable host image."""
+ # Write default stable_host_image_name with dummy value.
+ # TODO(113091773): An additional step to create the host image.
+ if not self.stable_host_image_name:
+ UpdateConfigFile(self.config_path, "stable_host_image_name", "")
+
+
def _NeedProjectSetup(self):
"""Confirm project setup should run or not.