Merge "Update data policy to enable customize disk size for AVDs."
diff --git a/internal/lib/cvd_compute_client_multi_stage.py b/internal/lib/cvd_compute_client_multi_stage.py
index bb1b7ce..e42b29e 100644
--- a/internal/lib/cvd_compute_client_multi_stage.py
+++ b/internal/lib/cvd_compute_client_multi_stage.py
@@ -81,6 +81,8 @@
"""Client that manages Android Virtual Device."""
DATA_POLICY_CREATE_IF_MISSING = "create_if_missing"
+ # Data policy to customize disk size.
+ DATA_POLICY_ALWAYS_CREATE = "always_create"
def __init__(self,
acloud_config,
@@ -102,7 +104,7 @@
external ip.
gpu: String, GPU to attach to the device.
"""
- super(CvdComputeClient, self).__init__(acloud_config, oauth2_credentials)
+ super().__init__(acloud_config, oauth2_credentials)
self._fetch_cvd_version = acloud_config.fetch_cvd_version
self._build_api = (
@@ -292,7 +294,7 @@
"-dpi=" + avd_spec.hw_property[constants.HW_ALIAS_DPI])
if constants.HW_ALIAS_DISK in avd_spec.hw_property:
launch_cvd_args.append(
- "-data_policy=" + self.DATA_POLICY_CREATE_IF_MISSING)
+ "-data_policy=" + self.DATA_POLICY_ALWAYS_CREATE)
launch_cvd_args.append(
"-blank_data_image_mb="
+ avd_spec.hw_property[constants.HW_ALIAS_DISK])
diff --git a/internal/lib/cvd_compute_client_multi_stage_test.py b/internal/lib/cvd_compute_client_multi_stage_test.py
index 3550fc9..566733b 100644
--- a/internal/lib/cvd_compute_client_multi_stage_test.py
+++ b/internal/lib/cvd_compute_client_multi_stage_test.py
@@ -80,7 +80,7 @@
def setUp(self):
"""Set up the test."""
- super(CvdComputeClientTest, self).setUp()
+ super().setUp()
self.Patch(cvd_compute_client_multi_stage.CvdComputeClient, "InitResourceHandle")
self.Patch(cvd_compute_client_multi_stage.CvdComputeClient, "_VerifyZoneByQuota",
return_value=True)
@@ -99,7 +99,7 @@
self.args.avd_type = constants.TYPE_CF
self.args.flavor = "phone"
self.args.adb_port = None
- self.args.hw_property = "cpu:2,resolution:1080x1920,dpi:240,memory:4g"
+ self.args.hw_property = "cpu:2,resolution:1080x1920,dpi:240,memory:4g,disk:10g"
self.args.num_avds_per_instance = 2
self.args.remote_host = False
@@ -110,9 +110,11 @@
"""test GetLaunchCvdArgs."""
# test GetLaunchCvdArgs with avd_spec
fake_avd_spec = avd_spec.AVDSpec(self.args)
- expeted_args = ["-x_res=1080", "-y_res=1920", "-dpi=240", "-cpus=2",
- "-memory_mb=4096", "-num_instances=2", "--setupwizard_mode=REQUIRED",
- "-gpu_mode=auto", "-undefok=report_anonymous_usage_stats",
+ expeted_args = ["-x_res=1080", "-y_res=1920", "-dpi=240",
+ "-data_policy=always_create", "-blank_data_image_mb=10240",
+ "-cpus=2", "-memory_mb=4096", "-num_instances=2",
+ "--setupwizard_mode=REQUIRED", "-gpu_mode=auto",
+ "-undefok=report_anonymous_usage_stats",
"-report_anonymous_usage_stats=y"]
launch_cvd_args = self.cvd_compute_client_multi_stage._GetLaunchCvdArgs(fake_avd_spec)
self.assertEqual(launch_cvd_args, expeted_args)