New error type for Acloud config error.
Define new error type ACLOUD_CONFIG_ERROR for the cases that Acloud
configuration missing some fields.
Bug: 182801649
Test: acloud-dev create --report-file report.json
Change-Id: Id309fbe13503c1c13261ef0bde4901b162203880
diff --git a/public/config.py b/public/config.py
index 51517a5..e7eb8e1 100755
--- a/public/config.py
+++ b/public/config.py
@@ -311,7 +311,7 @@
def Verify(self):
"""Verify configuration fields."""
- missing = [f for f in self.REQUIRED_FIELD if not getattr(self, f)]
+ missing = self.GetMissingFields(self.REQUIRED_FIELD)
if missing:
raise errors.ConfigError(
"Missing required configuration fields: %s" % missing)
@@ -322,6 +322,17 @@
"invalid value: %d" % (self.precreated_data_image_map.keys(),
self.extra_data_disk_size_gb))
+ def GetMissingFields(self, fields):
+ """Get missing required fields.
+
+ Args:
+ fields: List of field names.
+
+ Returns:
+ List of missing field names.
+ """
+ return [f for f in fields if not getattr(self, f)]
+
def SupportRemoteInstance(self):
"""Return True if gcp project is provided in config."""
return bool(self.project)