Merge "New function of Acloud restart AVD."
diff --git a/create/create.py b/create/create.py
index f15c605..3953a46 100644
--- a/create/create.py
+++ b/create/create.py
@@ -172,7 +172,7 @@
args.force = False
args.update_config = None
# Remote image/instance requires the GCP config setup.
- if not args.local_instance or args.local_image == "":
+ if args.local_instance is None or args.local_image is None:
gcp_setup = gcp_setup_runner.GcpTaskRunner(args.config_file)
if gcp_setup.ShouldRun():
args.gcp_init = True
@@ -183,7 +183,7 @@
# The following local instance create will trigger this if statment and go
# through the whole setup again even though it's already done because the
# user groups aren't set until the user logs out and back in.
- if args.local_instance:
+ if args.local_instance is not None:
host_pkg_setup = host_setup_runner.AvdPkgInstaller()
if host_pkg_setup.ShouldRun():
args.host = True
diff --git a/create/create_test.py b/create/create_test.py
index 7ab4b27..da69da1 100644
--- a/create/create_test.py
+++ b/create/create_test.py
@@ -112,6 +112,47 @@
create._CheckForSetup(args)
setup.Run.assert_called_once()
+ # Should or not run gcp_setup or install packages.
+ # Test with remote instance remote image case.
+ self.Patch(gcp_setup_runner.GcpTaskRunner,
+ "ShouldRun")
+ self.Patch(host_setup_runner.AvdPkgInstaller,
+ "ShouldRun")
+ args.local_instance = None
+ args.local_image = None
+ create._CheckForSetup(args)
+ self.assertEqual(gcp_setup_runner.GcpTaskRunner.ShouldRun.call_count, 1)
+ self.assertEqual(host_setup_runner.AvdPkgInstaller.ShouldRun.call_count, 0)
+ gcp_setup_runner.GcpTaskRunner.ShouldRun.reset_mock()
+ host_setup_runner.AvdPkgInstaller.ShouldRun.reset_mock()
+
+ # Test with remote instance local image case.
+ args.local_instance = None
+ args.local_image = ""
+ create._CheckForSetup(args)
+ self.assertEqual(gcp_setup_runner.GcpTaskRunner.ShouldRun.call_count, 1)
+ self.assertEqual(host_setup_runner.AvdPkgInstaller.ShouldRun.call_count, 0)
+ gcp_setup_runner.GcpTaskRunner.ShouldRun.reset_mock()
+ host_setup_runner.AvdPkgInstaller.ShouldRun.reset_mock()
+
+ # Test with local instance remote image case.
+ args.local_instance = 0
+ args.local_image = None
+ create._CheckForSetup(args)
+ self.assertEqual(gcp_setup_runner.GcpTaskRunner.ShouldRun.call_count, 1)
+ self.assertEqual(host_setup_runner.AvdPkgInstaller.ShouldRun.call_count, 1)
+ gcp_setup_runner.GcpTaskRunner.ShouldRun.reset_mock()
+ host_setup_runner.AvdPkgInstaller.ShouldRun.reset_mock()
+
+ # Test with local instance local image case.
+ args.local_instance = 0
+ args.local_image = ""
+ create._CheckForSetup(args)
+ self.assertEqual(gcp_setup_runner.GcpTaskRunner.ShouldRun.call_count, 0)
+ self.assertEqual(host_setup_runner.AvdPkgInstaller.ShouldRun.call_count, 1)
+ gcp_setup_runner.GcpTaskRunner.ShouldRun.reset_mock()
+ host_setup_runner.AvdPkgInstaller.ShouldRun.reset_mock()
+
# pylint: disable=no-member
def testRun(self):
"""Test Run."""
diff --git a/internal/lib/cvd_compute_client_multi_stage.py b/internal/lib/cvd_compute_client_multi_stage.py
index 49dc2cf..6e7137d 100644
--- a/internal/lib/cvd_compute_client_multi_stage.py
+++ b/internal/lib/cvd_compute_client_multi_stage.py
@@ -222,12 +222,8 @@
system_branch, system_build_target, kernel_build_id,
kernel_branch, kernel_build_target, bootloader_build_id,
bootloader_branch, bootloader_build_target)
- kernel_build = self._build_api.GetKernelBuild(kernel_build_id,
- kernel_branch,
- kernel_build_target)
self.LaunchCvd(instance,
blank_data_disk_size_gb=blank_data_disk_size_gb,
- kernel_build=kernel_build,
boot_timeout_secs=self._boot_timeout_secs)
return instance
@@ -273,14 +269,12 @@
# pylint: disable=too-many-branches
def _GetLaunchCvdArgs(self, avd_spec=None, blank_data_disk_size_gb=None,
- kernel_build=None, decompress_kernel=None,
- instance=None):
+ decompress_kernel=None, instance=None):
"""Get launch_cvd args.
Args:
avd_spec: An AVDSpec instance.
blank_data_disk_size_gb: Size of the blank data disk in GB.
- kernel_build: String, kernel build info.
decompress_kernel: Boolean, if true decompress the kernel.
instance: String, instance name.
@@ -369,7 +363,7 @@
@utils.TimeExecute(function_description="Launching AVD(s) and waiting for boot up",
result_evaluator=utils.BootEvaluator)
def LaunchCvd(self, instance, avd_spec=None,
- blank_data_disk_size_gb=None, kernel_build=None,
+ blank_data_disk_size_gb=None,
decompress_kernel=None,
boot_timeout_secs=None):
"""Launch CVD.
@@ -381,7 +375,6 @@
instance: String, instance name.
avd_spec: An AVDSpec instance.
blank_data_disk_size_gb: Size of the blank data disk in GB.
- kernel_build: String, kernel build info.
decompress_kernel: Boolean, if true decompress the kernel.
boot_timeout_secs: Integer, the maximum time to wait for the
command to respond.
@@ -395,7 +388,6 @@
error_msg = ""
launch_cvd_args = self._GetLaunchCvdArgs(avd_spec,
blank_data_disk_size_gb,
- kernel_build,
decompress_kernel,
instance)
boot_timeout_secs = boot_timeout_secs or constants.DEFAULT_CF_BOOT_TIMEOUT
diff --git a/public/actions/remote_instance_cf_device_factory.py b/public/actions/remote_instance_cf_device_factory.py
index 4aa265d..5623f9e 100644
--- a/public/actions/remote_instance_cf_device_factory.py
+++ b/public/actions/remote_instance_cf_device_factory.py
@@ -319,18 +319,11 @@
boot_timeout_secs: Integer, the maximum time to wait for the
command to respond.
"""
- kernel_build = None
# TODO(b/140076771) Support kernel image for local image mode.
- if self._avd_spec.image_source == constants.IMAGE_SRC_REMOTE:
- kernel_build = self._compute_client.build_api.GetKernelBuild(
- self._avd_spec.kernel_build_info[constants.BUILD_ID],
- self._avd_spec.kernel_build_info[constants.BUILD_BRANCH],
- self._avd_spec.kernel_build_info[constants.BUILD_TARGET])
self._compute_client.LaunchCvd(
instance,
self._avd_spec,
self._cfg.extra_data_disk_size_gb,
- kernel_build,
decompress_kernel,
boot_timeout_secs)