Merge "Support to create OpenWrt devices for local instance mode."
diff --git a/internal/lib/base_cloud_client.py b/internal/lib/base_cloud_client.py
index 52b54d7..6e4400c 100755
--- a/internal/lib/base_cloud_client.py
+++ b/internal/lib/base_cloud_client.py
@@ -83,38 +83,19 @@
An apiclient.discovery.Resource object
"""
http_auth = oauth2_credentials.authorize(httplib2.Http())
- try:
- return utils.RetryExceptionType(
- exception_types=cls.RETRIABLE_AUTH_ERRORS,
- max_retries=cls.RETRY_COUNT,
- functor=build,
- sleep_multiplier=cls.RETRY_SLEEP_MULTIPLIER,
- retry_backoff_factor=cls.RETRY_BACKOFF_FACTOR,
- serviceName=cls.API_NAME,
- version=cls.API_VERSION,
- # This is workaround for a known issue of some veriosn
- # of api client.
- # https://github.com/google/google-api-python-client/issues/435
- cache_discovery=False,
- # This is workaround for the errors.UnknownApiNameOrVersion
- # https://github.com/googleapis/google-api-python-client/issues/1263
- static_discovery=False,
- http=http_auth)
- except TypeError:
- # TODO(154879379): The change should be merged before the googleapi
- # upgraded to compatible with old googleapi version which does not
- # support the argument 'static discovery'. The retry should be
- # deleted afterward.
- return utils.RetryExceptionType(
- exception_types=cls.RETRIABLE_AUTH_ERRORS,
- max_retries=cls.RETRY_COUNT,
- functor=build,
- sleep_multiplier=cls.RETRY_SLEEP_MULTIPLIER,
- retry_backoff_factor=cls.RETRY_BACKOFF_FACTOR,
- serviceName=cls.API_NAME,
- version=cls.API_VERSION,
- cache_discovery=False,
- http=http_auth)
+ return utils.RetryExceptionType(
+ exception_types=cls.RETRIABLE_AUTH_ERRORS,
+ max_retries=cls.RETRY_COUNT,
+ functor=build,
+ sleep_multiplier=cls.RETRY_SLEEP_MULTIPLIER,
+ retry_backoff_factor=cls.RETRY_BACKOFF_FACTOR,
+ serviceName=cls.API_NAME,
+ version=cls.API_VERSION,
+ # This is workaround for a known issue of some veriosn
+ # of api client.
+ # https://github.com/google/google-api-python-client/issues/435
+ cache_discovery=False,
+ http=http_auth)
@staticmethod
def _ShouldRetry(exception, retry_http_codes,
diff --git a/internal/lib/base_cloud_client_test.py b/internal/lib/base_cloud_client_test.py
index 7fabfd5..fc75358 100644
--- a/internal/lib/base_cloud_client_test.py
+++ b/internal/lib/base_cloud_client_test.py
@@ -44,7 +44,6 @@
serviceName=base_cloud_client.BaseCloudApiClient.API_NAME,
version=base_cloud_client.BaseCloudApiClient.API_VERSION,
cache_discovery=False,
- static_discovery=False,
http=mock.ANY)
def _SetupInitMocks(self):
diff --git a/public/actions/remote_host_gf_device_factory.py b/public/actions/remote_host_gf_device_factory.py
index 0f21ddd..8f74311 100644
--- a/public/actions/remote_host_gf_device_factory.py
+++ b/public/actions/remote_host_gf_device_factory.py
@@ -295,7 +295,12 @@
system_image_zip_path = self._RetrieveSystemImageZip(
download_dir, build_api)
boot_image_path = self._RetrieveBootImage(download_dir, build_api)
- ota_tools_zip_path = self._RetrieveOtaToolsZip(download_dir, build_api)
+ # Retrieve OTA tools from the goldfish build which contains
+ # mk_combined_img.
+ ota_tools_zip_path = (
+ self._RetrieveArtifact(download_dir, build_api, build_target,
+ build_id, _OTA_TOOLS_ZIP_NAME)
+ if system_image_zip_path or boot_image_path else None)
return ArtifactPaths(image_zip_path, emu_zip_path,
ota_tools_zip_path, system_image_zip_path,
@@ -345,32 +350,6 @@
download_dir, build_api, build_target, build_id, image_name)
return None
- def _RetrieveOtaToolsZip(self, download_dir, build_api):
- """Retrieve OTA tools zip if needed.
-
- This class uses OTA tools to convert images into goldfish-specific
- formats. We don't have a use case where the system and the kernel
- require different sets of OTA tools. When both kernel and system builds
- are specified, this method downloads OTA tools from one of them.
-
- Args:
- download_dir: The download cache directory.
- build_api: An AndroidBuildClient object.
-
- Returns:
- The path to the OTA tools zip in download_dir.
- None if the kernel and the system build infos are empty.
- """
- for build_info in (self._avd_spec.system_build_info,
- self._avd_spec.kernel_build_info):
- build_id = build_info.get(constants.BUILD_ID)
- build_target = build_info.get(constants.BUILD_TARGET)
- if build_id and build_target:
- return self._RetrieveArtifact(
- download_dir, build_api, build_target, build_id,
- _OTA_TOOLS_ZIP_NAME)
- return None
-
@staticmethod
def _GetSubdirNameInZip(zip_path):
"""Get the name of the only subdirectory in a zip.
diff --git a/public/actions/remote_host_gf_device_factory_test.py b/public/actions/remote_host_gf_device_factory_test.py
index 2bd6dd3..545988d 100644
--- a/public/actions/remote_host_gf_device_factory_test.py
+++ b/public/actions/remote_host_gf_device_factory_test.py
@@ -221,7 +221,7 @@
"aosp_x86_64-userdebug", "111111",
"aosp_x86_64-img-111111.zip", mock.ANY, mock.ANY)
self._mock_android_build_client.DownloadArtifact.assert_any_call(
- "aosp_x86_64-userdebug", "111111",
+ "sdk_x86_64-sdk", "123456",
"otatools.zip", mock.ANY, mock.ANY)
self.assertEqual(
5, self._mock_android_build_client.DownloadArtifact.call_count)
@@ -257,7 +257,7 @@
"aosp_x86_64-userdebug", "111111",
"boot-5.10.img", mock.ANY, mock.ANY)
self._mock_android_build_client.DownloadArtifact.assert_any_call(
- "aosp_x86_64-userdebug", "111111",
+ "sdk_x86_64-sdk", "123456",
"otatools.zip", mock.ANY, mock.ANY)
self.assertEqual(
5, self._mock_android_build_client.DownloadArtifact.call_count)